Commit 89d5f937 authored by Xiaowu Zhang's avatar Xiaowu Zhang

improve ip check

parent 6fc714bf
CACHE MANIFEST
# v1
# v1.2
CACHE:
audioplayer.css
......@@ -10,10 +10,14 @@ audioplayer.js
../audioplayer_control/index.html
../audioplayer_control/control.js
../audioplayer_control/control.css
../audioplayer_playlist/index.html
../audioplayer_playlist/playlist.js
../audioplayer_playlist_online/index.html
../audioplayer_playlist_online/playlist.js
../audioplayer_playlist_offline/index.html
../audioplayer_playlist_offline/playlist.js
../audioplayer_playlist_local/index.html
../audioplayer_playlist_local/playlist.js
../audioplayer_upload/upload.js
../audioplayer_upload/index.js
../audioplayer_upload/index.html
../lib/URI.js
../lib/handlebars.min.js
../lib/jio.js
......@@ -22,4 +26,9 @@ audioplayer.js
../lib/jquerymobile.js
../lib/renderjs.min.js
../lib/rsvp.min.js
../lib/uritemplate.min.js
\ No newline at end of file
../lib/uritemplate.min.js
../lib/images/ajax-loader.gif
http://git.erp5.org/gitweb/dream.git/blob_plain/refs/heads/renderjs2:/dream/platform/src2/dream/mixin_promise.js
NETWORK:
*
\ No newline at end of file
<!DOCTYPE html>
<!--html manifest="audioPlayer.appcache"-->
<html manifest="audioPlayer.appcache">
<head>
<!-- renderjs -->
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
......
......@@ -47,16 +47,9 @@
.declareMethod('getAttachment', function () {
var storage = this.state_parameter_dict.jio_storage;
return storage.getAttachment.apply(storage, arguments)
// XXX Where to put this &@! blob reading
.then(function (response) {
return response.data;
//return jIO.util.readBlobAsText(response.data);
});
/*
.then(function (lala) {
console.log(lala.target.result);
return lala.target.result;
});*/
})
.declareMethod('putAttachment', function () {
var storage = this.state_parameter_dict.jio_storage;
......
......@@ -23,7 +23,7 @@
<script src="./playlist.js" type="text/javascript"></script>
<body>
<input type="text" class="inputIp" placeholder="input ip: http://xxx.xxx.xxx.xxx:port/ xxx is between 0 ~ 255"/>
<input type="text" class="inputIp" placeholder="input ip: http://xxx.xxx.xxx.xxx:port/(xxx is between 0 ~ 255)"/>
<input type="search" class="research" placeholder="research..."/>
......
......@@ -81,14 +81,12 @@
tmp.length + " music");
})
.fail(function (error) {
if (!(error instanceof RSVP.CancellationError)) {
if (ipValue) {
gadget.__element.getElementsByClassName('info')[0].innerHTML =
"network error";
}
return gadget.displayThisTitle("online playlist: " +
"0 music");
if (ipValue) {
gadget.__element.getElementsByClassName('info')[0].innerHTML =
"network error";
}
return gadget.displayThisTitle("online playlist: " +
"0 music");
});
})
.declareMethod('startService', function () {
......@@ -118,15 +116,26 @@
var info = g.__element.getElementsByClassName('info')[0],
http,
port,
portEnd,
ipValue = ip.value;
http = ipValue.indexOf("http");
g.__element.getElementsByTagName('ul')[0].innerHTML = " ";
if (ipValue.indexOf("/", ipValue.length - 1) === -1) {
info.innerHTML = " not end with /";
return;
}
http = ipValue.indexOf("http://");
ipValue = ipValue.substring(ipValue.indexOf("//") + 2);
port = ipValue.indexOf(":");
portEnd = ipValue.indexOf(":/");
if (port !== -1) {
ipValue = ipValue.substring(0, port);
}
if (http === -1) {
info.innerHTML = " please start ip with http";
info.innerHTML = " please start ip with http://";
return;
}
if (port === -1 || portEnd !== -1) {
info.innerHTML = "input port number";
return;
}
if (checkIp(ipValue) === false) {
......@@ -134,10 +143,6 @@
"invalide ip: ip should like xxx.xxx.xxx.xxx(xxx is between 0 ~ 255)";
return;
}
if (port === -1) {
info.innerHTML = "input port number";
return;
}
return new RSVP.Queue()
.push(function () {
return g.plCreateHttpStorage(ip.value);
......
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