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

add ip configure

parent 6b500761
......@@ -52,6 +52,15 @@
.allowPublicAcquisition("plDisablePage", function () {
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) {
// Hey, I want to display this page
return this.aq_pleasePublishMyState(param_list[0]);
......@@ -104,16 +113,7 @@
rJS(window)
.ready(function (g) {
return g.getDeclaredGadget("online")
.push(function (gadget) {
return gadget.createJio(
{ "type" : "http",
"database" : "http://192.168.242.63:8080/"}
);
})
.push(function () {
return g.getDeclaredGadget("localhost");
})
return g.getDeclaredGadget("localhost")
.push(function (gadget) {
return gadget.createJio(
{ "type" : "http",
......
......@@ -22,7 +22,11 @@
<script src="./playlist.js" type="text/javascript"></script>
<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..."/>
<div data-role="content">
......@@ -31,12 +35,12 @@
</div>
<div data-role="footer" data-position="fixed" data-theme="b">
<div data-role="navbar">
<div data-role="footer" data-position="fixed" data-theme="b">
<div data-role="navbar" >
<ul>
<li><a data-role="button" class="offline" data-icon="arrow-l">offline</a></li>
<li><a data-role="button" class="localhost" data-icon="arrow-r">localhost</a></li>
<li><a data-role="button" class="online" data-icon="arrow-r">online</a></li>
<li><a data-role="button" class="offline" data-icon="search">offline</a></li>
<li><a data-role="button" class="localhost" data-icon="search">localhost</a></li>
<li><a data-role="button" class="online" data-icon="search">online</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
......
/*global window, rJS, RSVP, console, jQuery, $, JSON, Handlebars,
promiseEventListener, RegExp */
loopEventListener, RegExp */
/*jslint maxlen:80, nomen: true */
(function (window, rJS, $, Handlebars, promiseEventListener) {
(function (window, rJS, $, Handlebars, loopEventListener) {
"use strict";
var gk = rJS(window),
rows_template_source = gk.__template_element
......@@ -12,6 +12,7 @@
gk.declareAcquiredMethod("allDocs", "allDocs")
.declareAcquiredMethod("displayThisPage", "displayThisPage")
.declareAcquiredMethod("displayThisTitle", "displayThisTitle")
.declareAcquiredMethod("plCreateHttpStorage", "plCreateHttpStorage")
.declareAcquiredMethod("plEnablePage", "plEnablePage")
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
.declareMethod('render', function (options) {
......@@ -43,13 +44,14 @@
return gadget.allDocs({"include_docs": true});
})
.push(function (e) {
var tmp = [],
var tmp = e.data.rows,
i,
j,
exp;
if (options.id !== undefined && options.id !== "offline"
&& options.id !== "localhost"
&& options.id !== "online") {
tmp = [];
for (i = 0, j = 0; i < e.data.rows.length; i += 1) {
exp = new RegExp(options.id, "i");
if (e.data.rows[i].doc.title.search(exp) !== -1) {
......@@ -57,22 +59,22 @@
j += 1;
}
}
e.data.rows = tmp;
gadget.id = options.id;
}
list.innerHTML = rows_template({
"rows" : e.data.rows
"rows" : tmp
});
$(list).listview("refresh");
})
.fail(function (error) {
document.getElementsByTagName('body')[0].textContent =
JSON.stringify(error);
"network error: ip maybe not set";
});
})
.declareMethod('startService', function () {
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) {
research.value = g.id;
}
......@@ -81,14 +83,21 @@
return g.plEnablePage();
})
.push(function () {
return promiseEventListener(research, "change", false);
})
.push(function (e) {
return g.displayThisPage({page: "playlist",
id: research.value});
})
.push(function (url) {
window.location = url;
});
});
}(window, rJS, jQuery, Handlebars, promiseEventListener));
return RSVP.any([
loopEventListener(research, "change", false, function () {
return new RSVP.Queue()
.push(function () {
return g.displayThisPage({page: "playlist",
id: research.value});
})
.push(function (url) {
window.location = url;
});
}),
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