mirror of
https://github.com/Doodle3D/doodle3d-connect.git
synced 2024-12-25 18:13:48 +01:00
Better filenames
This commit is contained in:
parent
7a008250c1
commit
0dcd18d491
@ -8,8 +8,13 @@
|
|||||||
|
|
||||||
var BoxPage = (function (w) {
|
var BoxPage = (function (w) {
|
||||||
var _page;
|
var _page;
|
||||||
|
var _list;
|
||||||
var _title;
|
var _title;
|
||||||
var _intro;
|
var _intro;
|
||||||
|
var _drawItem;
|
||||||
|
var _updateItem;
|
||||||
|
var _joinNetworkItem;
|
||||||
|
|
||||||
var _networkStatus;
|
var _networkStatus;
|
||||||
var _networkAPI = new NetworkAPI();
|
var _networkAPI = new NetworkAPI();
|
||||||
var _boxData = {};
|
var _boxData = {};
|
||||||
@ -22,9 +27,13 @@ var BoxPage = (function (w) {
|
|||||||
$.mobile.document.on( "pageinit", PAGE_ID, function( event, data ) {
|
$.mobile.document.on( "pageinit", PAGE_ID, function( event, data ) {
|
||||||
//console.log("Box page pageinit");
|
//console.log("Box page pageinit");
|
||||||
_page = $(this);
|
_page = $(this);
|
||||||
|
_list = _page.find("ul[data-role=listview]");
|
||||||
_title = _page.find(".ui-title");
|
_title = _page.find(".ui-title");
|
||||||
_intro = _page.find(".intro");
|
_intro = _page.find(".intro");
|
||||||
|
|
||||||
|
_drawItem = _page.find("#drawItem");
|
||||||
|
_updateItem = _page.find("#updateItem");
|
||||||
|
_joinNetworkItem = _page.find("#joinNetworkItem");
|
||||||
});
|
});
|
||||||
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
|
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
|
||||||
console.log("Box page pagebeforeshow");
|
console.log("Box page pagebeforeshow");
|
||||||
@ -47,9 +56,8 @@ var BoxPage = (function (w) {
|
|||||||
_networkAPI.status(function(data) {
|
_networkAPI.status(function(data) {
|
||||||
console.log("_networkAPI.status complete");
|
console.log("_networkAPI.status complete");
|
||||||
console.log(" data: ",data);
|
console.log(" data: ",data);
|
||||||
if(data.status !== "" && typeof data.status === 'string') {
|
|
||||||
data.status = parseInt(data.status,10);
|
data.status = parseInt(data.status,10);
|
||||||
}
|
console.log(" data.status: ",data.status);
|
||||||
//console.log(_self.id,"NetworkPanel:retrievedStatus status: ",data.status,data.statusMessage);
|
//console.log(_self.id,"NetworkPanel:retrievedStatus status: ",data.status,data.statusMessage);
|
||||||
//console.log(" networkPanel ",_element[0]," parent: ",_element.parent()[0]);
|
//console.log(" networkPanel ",_element[0]," parent: ",_element.parent()[0]);
|
||||||
// ToDo: update _currentNetwork when available
|
// ToDo: update _currentNetwork when available
|
||||||
@ -71,55 +79,40 @@ var BoxPage = (function (w) {
|
|||||||
_retryRetrieveStatusDelay = setTimeout(_self.retrieveStatus, _retryRetrieveStatusDelayTime); // retry after delay
|
_retryRetrieveStatusDelay = setTimeout(_self.retrieveStatus, _retryRetrieveStatusDelayTime); // retry after delay
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNetworkStatus(status,data) {
|
function setNetworkStatus(status,data) {
|
||||||
console.log("setNetworkStatus: ",status,data);
|
console.log("setNetworkStatus: ",status,data);
|
||||||
|
console.log(" _updateItem: ",_updateItem);
|
||||||
if(status === NetworkAPI.STATUS.CONNECTED) { // online
|
if(status === NetworkAPI.STATUS.CONNECTED) { // online
|
||||||
_page.find("#drawItem a").text("Draw");
|
console.log("online");
|
||||||
// ToDo: Link to update page (auto retrieve if available)
|
_drawItem.find("#a").text("Draw");
|
||||||
// ToDo: Link to your app here?
|
// ToDo: Link to your app here?
|
||||||
// ToDo: Status
|
// ToDo: Status
|
||||||
// ToDo: Control
|
// ToDo: Control
|
||||||
_page.find("#joinNetworkItem").toggleClass("ui-screen-hidden",true);
|
_joinNetworkItem.toggleClass("ui-screen-hidden",true);
|
||||||
|
_updateItem.toggleClass("ui-screen-hidden",false);
|
||||||
|
// ToDo: retrieve update information
|
||||||
|
|
||||||
} else { // offline
|
} else { // offline
|
||||||
|
console.log("offline");
|
||||||
_intro.text("Please connect your WiFi-Box to the internet. You can also use it offline but then you aren't able to update.");
|
_intro.text("Please connect your WiFi-Box to the internet. You can also use it offline but then you aren't able to update.");
|
||||||
|
|
||||||
var joinNetworkItem = _page.find("#joinNetworkItem");
|
_joinNetworkItem.toggleClass("ui-screen-hidden",false);
|
||||||
joinNetworkItem.toggleClass("ui-screen-hidden",false);
|
|
||||||
|
|
||||||
var joinLink = joinNetworkItem.find("a").attr("href");
|
var joinLink = _joinNetworkItem.find("a").attr("href");
|
||||||
joinLink = d3d.util.replaceURLParameters(joinLink,_boxData);
|
joinLink = d3d.util.replaceURLParameters(joinLink,_boxData);
|
||||||
joinNetworkItem.find("a").attr("href",joinLink);
|
_joinNetworkItem.find("a").attr("href",joinLink);
|
||||||
|
|
||||||
_page.find("#drawItem a").text("Draw (offline)");
|
_drawItem.find("a").text("Draw (offline)");
|
||||||
|
_updateItem.toggleClass("ui-screen-hidden",true);
|
||||||
|
|
||||||
// ToDo: Status
|
// ToDo: Status
|
||||||
// ToDo: Control
|
// ToDo: Control
|
||||||
}
|
}
|
||||||
|
|
||||||
// update info
|
// ToDo: update footer with network info
|
||||||
/*switch(status) {
|
|
||||||
case NetworkAPI.STATUS.CONNECTED:
|
_list.listview('refresh'); // jQuery mobile enhance content
|
||||||
//console.log(" data.ssid: ",data.ssid);
|
|
||||||
if(data.ssid == "") {
|
|
||||||
_currentNetwork = undefined;
|
|
||||||
//data.status = NetworkAPI.STATUS.NOT_CONNECTED;
|
|
||||||
setStatus(NetworkAPI.STATUS.NOT_CONNECTED);
|
|
||||||
} else {
|
|
||||||
_currentNetwork = data.ssid;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NetworkAPI.STATUS.CONNECTING:
|
|
||||||
if(_selectedNetwork != undefined) {
|
|
||||||
targetNetwork = _selectedNetwork;
|
|
||||||
} else if(_currentNetwork != undefined) {
|
|
||||||
targetNetwork = _currentNetwork;
|
|
||||||
}
|
|
||||||
case NetworkAPI.STATUS.CREATING:
|
|
||||||
case NetworkAPI.STATUS.CREATED:
|
|
||||||
_currentNetwork = undefined;
|
|
||||||
break;
|
|
||||||
}*/
|
|
||||||
_networkStatus = data.status;
|
_networkStatus = data.status;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
var BoxesPage = (function (w) {
|
var BoxesPage = (function (w) {
|
||||||
var connectAPI = new ConnectAPI(); // TODO add _
|
var _connectAPI = new ConnectAPI();
|
||||||
|
|
||||||
var _page;
|
var _page;
|
||||||
var _list;
|
var _list;
|
||||||
@ -20,18 +20,18 @@ var BoxesPage = (function (w) {
|
|||||||
_list = _page.find("#boxeslist");
|
_list = _page.find("#boxeslist");
|
||||||
_findItem = _list.find("#findItem");
|
_findItem = _list.find("#findItem");
|
||||||
|
|
||||||
connectAPI.refreshing = onRefreshing;
|
_connectAPI.refreshing = onRefreshing;
|
||||||
connectAPI.listUpdated = onListUpdated;
|
_connectAPI.listUpdated = onListUpdated;
|
||||||
connectAPI.boxAppeared = onBoxAppeared;
|
_connectAPI.boxAppeared = onBoxAppeared;
|
||||||
connectAPI.boxDisapeared = onBoxDisapeared;
|
_connectAPI.boxDisapeared = onBoxDisapeared;
|
||||||
});
|
});
|
||||||
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
|
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
|
||||||
//console.log("Boxes page pagebeforeshow");
|
//console.log("Boxes page pagebeforeshow");
|
||||||
connectAPI.start();
|
_connectAPI.start();
|
||||||
});
|
});
|
||||||
$.mobile.document.on( "pagehide", PAGE_ID, function( event, data ) {
|
$.mobile.document.on( "pagehide", PAGE_ID, function( event, data ) {
|
||||||
//console.log("Boxes page pagehide");
|
//console.log("Boxes page pagehide");
|
||||||
connectAPI.stop();
|
_connectAPI.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
function onRefreshing() {
|
function onRefreshing() {
|
||||||
@ -46,8 +46,10 @@ var BoxesPage = (function (w) {
|
|||||||
function onBoxAppeared(boxData) {
|
function onBoxAppeared(boxData) {
|
||||||
console.log("onBoxAppeared: ",boxData.localip);
|
console.log("onBoxAppeared: ",boxData.localip);
|
||||||
|
|
||||||
var link = "#box?localip="+boxData.localip+"&wifiboxid="+boxData.wifiboxid;
|
var linkParams = {localip: boxData.localip,wifiboxid: boxData.wifiboxid};
|
||||||
if(boxData.link) { link += "&link="+boxData.link; }
|
if(boxData.link) { linkParams.link = boxData.link; }
|
||||||
|
var link = "#box";
|
||||||
|
link = d3d.util.replaceURLParameters(link,linkParams);
|
||||||
var id = boxData.localip.replace(/\./g,"-");
|
var id = boxData.localip.replace(/\./g,"-");
|
||||||
var linkElement = $("<a href='"+link+"' class='link'>"+boxData.wifiboxid+"</a>");
|
var linkElement = $("<a href='"+link+"' class='link'>"+boxData.wifiboxid+"</a>");
|
||||||
var box = $("<li id='"+id+"' class='box'></li>");
|
var box = $("<li id='"+id+"' class='box'></li>");
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the Doodle3D project (http://doodle3d.com).
|
|
||||||
*
|
|
||||||
* Copyright (c) 2013, Doodle3D
|
|
||||||
* This software is licensed under the terms of the GNU GPL v2 or later.
|
|
||||||
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function (w) {
|
|
||||||
var _page;
|
|
||||||
var _list;
|
|
||||||
var _networks;
|
|
||||||
// var _networkStatus;
|
|
||||||
// var _networkAPI = new NetworkAPI();
|
|
||||||
// var _boxData = {};
|
|
||||||
// var _retryRetrieveStatusDelay;
|
|
||||||
// var _retryRetrieveStatusDelayTime = 3000;
|
|
||||||
var PAGE_ID = "#join_network";
|
|
||||||
|
|
||||||
var _self = this;
|
|
||||||
|
|
||||||
$.mobile.document.on( "pageinit", PAGE_ID, function( event, data ) {
|
|
||||||
console.log("Join network page pageinit");
|
|
||||||
_page = $(this);
|
|
||||||
_list = _page.find("ul[data-role=listview]");
|
|
||||||
console.log(" list: ",_list);
|
|
||||||
});
|
|
||||||
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
|
|
||||||
console.log("Join network page pagebeforeshow");
|
|
||||||
_boxData = d3d.util.getPageParams(PAGE_ID);
|
|
||||||
var boxURL = "http://"+_boxData.localip;
|
|
||||||
console.log(" _boxData: ",_boxData);
|
|
||||||
|
|
||||||
_networkAPI.init(boxURL);
|
|
||||||
refreshNetworks();
|
|
||||||
});
|
|
||||||
function refreshNetworks(completeHandler) {
|
|
||||||
console.log("JoinNetwork:refreshNetworks");
|
|
||||||
_api.scan(function(data) { // completed
|
|
||||||
console.log("JoinNetwork:refreshNetworks:scanned");
|
|
||||||
|
|
||||||
fillNetworks(data.networks)
|
|
||||||
_networks = {};
|
|
||||||
$.each(data.networks, function(index,network) {
|
|
||||||
_networks[network.ssid] = network;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(completeHandler) completeHandler();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function fillNetworks(networks) {
|
|
||||||
_list.empty();
|
|
||||||
$.each(networks, function(index,network) {
|
|
||||||
|
|
||||||
var joinLink = joinNetworkItem.find("a").attr("href");
|
|
||||||
joinLink = d3d.util.replaceURLParameters(joinLink,_boxData);
|
|
||||||
joinNetworkItem.find("a").attr("href",joinLink);
|
|
||||||
|
|
||||||
|
|
||||||
var link = "#network_connecting";
|
|
||||||
link = d3d.util.replaceURLParameters(link,_boxData);
|
|
||||||
//var item = $("<li></li>");
|
|
||||||
|
|
||||||
_list.append(
|
|
||||||
//$("<option></option>").val(network.ssid).html(network.ssid)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
_list.listview('refresh'); // jQuery mobile enhance content
|
|
||||||
}
|
|
||||||
|
|
||||||
})(window);
|
|
89
js/JoinNetworkPage.js
Normal file
89
js/JoinNetworkPage.js
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Doodle3D project (http://doodle3d.com).
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013, Doodle3D
|
||||||
|
* This software is licensed under the terms of the GNU GPL v2 or later.
|
||||||
|
* See file LICENSE.txt or visit http://www.gnu.org/licenses/gpl.html for full license details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function JoinNetworkPage(w) {
|
||||||
|
|
||||||
|
var _page;
|
||||||
|
var _list;
|
||||||
|
var _joinOtherItem;
|
||||||
|
var _networks;
|
||||||
|
var _networkAPI = new NetworkAPI();
|
||||||
|
var _boxData = {};
|
||||||
|
var _refreshDelay;
|
||||||
|
var _refreshDelayTime = 3000;
|
||||||
|
var PAGE_ID = "#join_network";
|
||||||
|
|
||||||
|
var _self = this;
|
||||||
|
|
||||||
|
$.mobile.document.on( "pageinit", PAGE_ID, function( event, data ) {
|
||||||
|
console.log("Join network page pageinit");
|
||||||
|
_page = $(this);
|
||||||
|
_list = _page.find("ul[data-role=listview]");
|
||||||
|
_joinOtherItem = _list.find("#joinOther");
|
||||||
|
console.log(" list: ",_list);
|
||||||
|
});
|
||||||
|
$.mobile.document.on( "pagebeforeshow", PAGE_ID, function( event, data ) {
|
||||||
|
console.log("Join network page pagebeforeshow");
|
||||||
|
_boxData = d3d.util.getPageParams(PAGE_ID);
|
||||||
|
var boxURL = "http://"+_boxData.localip;
|
||||||
|
console.log(" _boxData: ",_boxData);
|
||||||
|
|
||||||
|
_networkAPI.init(boxURL);
|
||||||
|
refreshNetworks();
|
||||||
|
});
|
||||||
|
$.mobile.document.on( "pagehide", PAGE_ID, function( event, data ) {
|
||||||
|
console.log("Join network page pagehide");
|
||||||
|
clearTimeout(_refreshDelay);
|
||||||
|
});
|
||||||
|
function refreshNetworks() {
|
||||||
|
console.log("JoinNetwork:refreshNetworks");
|
||||||
|
d3d.util.showLoader();
|
||||||
|
_networkAPI.scan(function(data) { // completed
|
||||||
|
console.log("JoinNetwork:refreshNetworks:scanned");
|
||||||
|
d3d.util.hideLoader();
|
||||||
|
_networks = {};
|
||||||
|
$.each(data.networks, function(index,network) {
|
||||||
|
_networks[network.ssid] = network;
|
||||||
|
});
|
||||||
|
// update list
|
||||||
|
updateList();
|
||||||
|
// keep refreshing
|
||||||
|
clearTimeout(_refreshDelay);
|
||||||
|
_refreshDelay = setTimeout(refreshNetworks, _refreshDelayTime);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function updateList() {
|
||||||
|
_list.empty();
|
||||||
|
var baseConnectingLink = _list.data("connecting-target");
|
||||||
|
var baseSecuredLink = _list.data("secured-target");
|
||||||
|
var linkParams = $.extend({}, _boxData);
|
||||||
|
console.log(" linkParams: ",linkParams);
|
||||||
|
$.each(_networks, function(index,network) {
|
||||||
|
console.log(" network: ",network);
|
||||||
|
linkParams.ssid = network.ssid;
|
||||||
|
|
||||||
|
var secured = (network.encryption !== "none" && network.encryption !== "")
|
||||||
|
var link;
|
||||||
|
var icon = "";
|
||||||
|
if(secured) {
|
||||||
|
linkParams.encryption = network.encryption;
|
||||||
|
link = d3d.util.replaceURLParameters(baseSecuredLink,linkParams);
|
||||||
|
icon = "lock";
|
||||||
|
} else {
|
||||||
|
link = d3d.util.replaceURLParameters(baseConnectingLink,linkParams);
|
||||||
|
}
|
||||||
|
console.log(" link: ",link);
|
||||||
|
_list.append(
|
||||||
|
$('<li data-icon="'+icon+'"><a href="'+link+'">'+network.ssid+'</a></li>')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
_list.append(_joinOtherItem);
|
||||||
|
_list.listview('refresh'); // jQuery mobile enhance content
|
||||||
|
}
|
||||||
|
})(window);
|
||||||
|
//new JoinNetworkPage();
|
Loading…
Reference in New Issue
Block a user