Commit 8bce8679 authored by Xiaowu Zhang's avatar Xiaowu Zhang

add ip configure

parent 6b500761
...@@ -52,6 +52,15 @@ ...@@ -52,6 +52,15 @@
.allowPublicAcquisition("plDisablePage", function () { .allowPublicAcquisition("plDisablePage", function () {
disablePage(this); disablePage(this);
}) })
.allowPublicAcquisition("plCreateHttpStorage", function (list) {
return this.getDeclaredGadget("online")
.push(function (gadget) {
return gadget.createJio(
{ "type" : "http",
"database" : list[0]}
);
});
})
.allowPublicAcquisition("displayThisPage", function (param_list) { .allowPublicAcquisition("displayThisPage", function (param_list) {
// Hey, I want to display this page // Hey, I want to display this page
return this.aq_pleasePublishMyState(param_list[0]); return this.aq_pleasePublishMyState(param_list[0]);
...@@ -104,16 +113,7 @@ ...@@ -104,16 +113,7 @@
rJS(window) rJS(window)
.ready(function (g) { .ready(function (g) {
return g.getDeclaredGadget("online") return g.getDeclaredGadget("localhost")
.push(function (gadget) {
return gadget.createJio(
{ "type" : "http",
"database" : "http://192.168.242.63:8080/"}
);
})
.push(function () {
return g.getDeclaredGadget("localhost");
})
.push(function (gadget) { .push(function (gadget) {
return gadget.createJio( return gadget.createJio(
{ "type" : "http", { "type" : "http",
......
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
<script src="./playlist.js" type="text/javascript"></script> <script src="./playlist.js" type="text/javascript"></script>
<body> <body>
<div data-role="collapsible" data-collapsed-icon="gear" data-expanded-icon="minus">
<h1>online mode ip</h1>
<input type="text" class="inputIp" placeholder="http://xxx.xxx.xxx.xx:port/"/>
</div>
<input type="search" class="research" placeholder="research..."/> <input type="search" class="research" placeholder="research..."/>
...@@ -32,11 +36,11 @@ ...@@ -32,11 +36,11 @@
<div data-role="footer" data-position="fixed" data-theme="b"> <div data-role="footer" data-position="fixed" data-theme="b">
<div data-role="navbar"> <div data-role="navbar" >
<ul> <ul>
<li><a data-role="button" class="offline" data-icon="arrow-l">offline</a></li> <li><a data-role="button" class="offline" data-icon="search">offline</a></li>
<li><a data-role="button" class="localhost" data-icon="arrow-r">localhost</a></li> <li><a data-role="button" class="localhost" data-icon="search">localhost</a></li>
<li><a data-role="button" class="online" data-icon="arrow-r">online</a></li> <li><a data-role="button" class="online" data-icon="search">online</a></li>
</ul> </ul>
</div><!-- /navbar --> </div><!-- /navbar -->
</div><!-- /footer --> </div><!-- /footer -->
......
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars, /*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
promiseEventListener, RegExp */ loopEventListener, RegExp */
/*jslint maxlen:80, nomen: true */ /*jslint maxlen:80, nomen: true */
(function (window, rJS, $, Handlebars, promiseEventListener) { (function (window, rJS, $, Handlebars, loopEventListener) {
"use strict"; "use strict";
var gk = rJS(window), var gk = rJS(window),
rows_template_source = gk.__template_element rows_template_source = gk.__template_element
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
gk.declareAcquiredMethod("allDocs", "allDocs") gk.declareAcquiredMethod("allDocs", "allDocs")
.declareAcquiredMethod("displayThisPage", "displayThisPage") .declareAcquiredMethod("displayThisPage", "displayThisPage")
.declareAcquiredMethod("displayThisTitle", "displayThisTitle") .declareAcquiredMethod("displayThisTitle", "displayThisTitle")
.declareAcquiredMethod("plCreateHttpStorage", "plCreateHttpStorage")
.declareAcquiredMethod("plEnablePage", "plEnablePage") .declareAcquiredMethod("plEnablePage", "plEnablePage")
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash") .declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
...@@ -43,13 +44,14 @@ ...@@ -43,13 +44,14 @@
return gadget.allDocs({"include_docs": true}); return gadget.allDocs({"include_docs": true});
}) })
.push(function (e) { .push(function (e) {
var tmp = [], var tmp = e.data.rows,
i, i,
j, j,
exp; exp;
if (options.id !== undefined && options.id !== "offline" if (options.id !== undefined && options.id !== "offline"
&& options.id !== "localhost" && options.id !== "localhost"
&& options.id !== "online") { && options.id !== "online") {
tmp = [];
for (i = 0, j = 0; i < e.data.rows.length; i += 1) { for (i = 0, j = 0; i < e.data.rows.length; i += 1) {
exp = new RegExp(options.id, "i"); exp = new RegExp(options.id, "i");
if (e.data.rows[i].doc.title.search(exp) !== -1) { if (e.data.rows[i].doc.title.search(exp) !== -1) {
...@@ -57,22 +59,22 @@ ...@@ -57,22 +59,22 @@
j += 1; j += 1;
} }
} }
e.data.rows = tmp;
gadget.id = options.id; gadget.id = options.id;
} }
list.innerHTML = rows_template({ list.innerHTML = rows_template({
"rows" : e.data.rows "rows" : tmp
}); });
$(list).listview("refresh"); $(list).listview("refresh");
}) })
.fail(function (error) { .fail(function (error) {
document.getElementsByTagName('body')[0].textContent = document.getElementsByTagName('body')[0].textContent =
JSON.stringify(error); "network error: ip maybe not set";
}); });
}) })
.declareMethod('startService', function () { .declareMethod('startService', function () {
var g = this, var g = this,
research = g.__element.getElementsByClassName('research')[0]; research = g.__element.getElementsByClassName('research')[0],
ip = g.__element.getElementsByClassName('inputIp')[0];
if (g.id !== undefined) { if (g.id !== undefined) {
research.value = g.id; research.value = g.id;
} }
...@@ -81,14 +83,21 @@ ...@@ -81,14 +83,21 @@
return g.plEnablePage(); return g.plEnablePage();
}) })
.push(function () { .push(function () {
return promiseEventListener(research, "change", false); return RSVP.any([
}) loopEventListener(research, "change", false, function () {
.push(function (e) { return new RSVP.Queue()
.push(function () {
return g.displayThisPage({page: "playlist", return g.displayThisPage({page: "playlist",
id: research.value}); id: research.value});
}) })
.push(function (url) { .push(function (url) {
window.location = url; window.location = url;
}); });
}); }),
}(window, rJS, jQuery, Handlebars, promiseEventListener)); loopEventListener(ip, "change", false, function () {
return g.plCreateHttpStorage(ip.value);
})
]);//any
});//rsvp
});//startService
}(window, rJS, jQuery, Handlebars, loopEventListener));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment