mirror of
https://github.com/Doodle3D/doodle3d-connect.git
synced 2024-12-25 18:13:48 +01:00
Prevent parameters removal from url's
This commit is contained in:
parent
e5483988b5
commit
7329682626
@ -52,12 +52,12 @@ var BoxPage = (function (w) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function retrieveNetworkStatus() {
|
function retrieveNetworkStatus() {
|
||||||
console.log("retrieveNetworkStatus");
|
//console.log("retrieveNetworkStatus");
|
||||||
_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);
|
||||||
data.status = parseInt(data.status,10);
|
data.status = parseInt(data.status,10);
|
||||||
console.log(" data.status: ",data.status);
|
//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
|
||||||
@ -81,11 +81,10 @@ var BoxPage = (function (w) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setNetworkStatus(status) {
|
function setNetworkStatus(status) {
|
||||||
console.log("setNetworkStatus: ",status);
|
//console.log("setNetworkStatus: ",status);
|
||||||
console.log(" _updateItem: ",_updateItem);
|
|
||||||
var introText = "";
|
var introText = "";
|
||||||
if(status === NetworkAPI.STATUS.CONNECTED) { // online
|
if(status === NetworkAPI.STATUS.CONNECTED) { // online
|
||||||
console.log("online");
|
//console.log("online");
|
||||||
_drawItem.find("a").text("Draw");
|
_drawItem.find("a").text("Draw");
|
||||||
// ToDo: Link to your app here?
|
// ToDo: Link to your app here?
|
||||||
// ToDo: Status
|
// ToDo: Status
|
||||||
@ -97,7 +96,7 @@ var BoxPage = (function (w) {
|
|||||||
_joinNetworkItem.toggleClass("ui-screen-hidden",true);
|
_joinNetworkItem.toggleClass("ui-screen-hidden",true);
|
||||||
|
|
||||||
} else { // offline
|
} else { // offline
|
||||||
console.log("offline");
|
//console.log("offline");
|
||||||
introText = "Please connect your WiFi-Box to the internet. You can also use it offline, but then you won't be able to update.";
|
introText = "Please connect your WiFi-Box to the internet. You can also use it offline, but then you won't be able to update.";
|
||||||
|
|
||||||
_joinNetworkItem.toggleClass("ui-screen-hidden",false);
|
_joinNetworkItem.toggleClass("ui-screen-hidden",false);
|
||||||
|
41
js/main.js
41
js/main.js
@ -12,9 +12,10 @@ d3d.util = {
|
|||||||
parseURL:function(url) {
|
parseURL:function(url) {
|
||||||
var parsed = $.mobile.path.parseUrl( url );
|
var parsed = $.mobile.path.parseUrl( url );
|
||||||
var hashParts = parsed.hash.split( "?" );
|
var hashParts = parsed.hash.split( "?" );
|
||||||
var parameters = {};
|
var parameters;
|
||||||
// Assemble query parameters object from the query string
|
// Assemble query parameters object from the query string
|
||||||
if (hashParts.length > 1) {
|
if (hashParts.length > 1) {
|
||||||
|
parameters = {};
|
||||||
$.each(hashParts[1].split( "&" ), function( index, value ) {
|
$.each(hashParts[1].split( "&" ), function( index, value ) {
|
||||||
var pair = value.split( "=" );
|
var pair = value.split( "=" );
|
||||||
if ( pair.length > 0 && pair[ 0 ] ) {
|
if ( pair.length > 0 && pair[ 0 ] ) {
|
||||||
@ -60,30 +61,30 @@ d3d.util = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
(function (w) {
|
(function (w) {
|
||||||
|
//$(function () {
|
||||||
/*$.mobile.document.on( "pagebeforechange", function( event, data ) {
|
|
||||||
console.log("pagebeforechange");
|
|
||||||
//console.log(" event: ",event);
|
|
||||||
//console.log(" data: ",data);
|
|
||||||
d3d.pageParams[pageID]
|
|
||||||
|
|
||||||
if ($.type(data.toPage) === "string") {
|
|
||||||
console.log(" data.toPage: ",data.toPage);
|
|
||||||
//var url = d3d.util.processURL(data.toPage);
|
|
||||||
//data.url = url;
|
|
||||||
// add to data attribute of target page ?
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
//to get to url parameters we need the url
|
//to get to url parameters we need the url
|
||||||
// only pagecontainer events contain url's
|
// only pagecontainer events contain url's
|
||||||
// we parse the parameters and store them in a global object
|
// we parse the parameters and store them in a global object
|
||||||
$.mobile.document.on( "pagecontainerbeforetransition", function( event, data ) {
|
$.mobile.document.on( "pagebeforechange", function( event, data ) {
|
||||||
//console.log("pagecontainerbeforetransition");
|
//console.log("pagebeforechange");
|
||||||
var url = d3d.util.parseURL(data.absUrl);
|
//console.log(" event: ",event);
|
||||||
|
//console.log(" data: ",data);
|
||||||
|
//d3d.pageParams[pageID]
|
||||||
|
//console.log(" data.toPage: ",data.toPage);
|
||||||
|
if (typeof data.toPage !== "string") { return; }
|
||||||
|
|
||||||
|
var url = d3d.util.parseURL(data.toPage);
|
||||||
//console.log(" url: ",url);
|
//console.log(" url: ",url);
|
||||||
|
//console.log(" url.hash: ",url.hash);
|
||||||
|
if(url.parameters === undefined) { return; }
|
||||||
if(!d3d.pageParams) { d3d.pageParams = {}; }
|
if(!d3d.pageParams) { d3d.pageParams = {}; }
|
||||||
d3d.pageParams[url.hash] = url.parameters;
|
d3d.pageParams[url.hash] = url.parameters;
|
||||||
});
|
|
||||||
|
|
||||||
|
// let jQuery mobile navigate to page (providing only the page id so it understands)
|
||||||
|
$.mobile.changePage(url.hash, data.options);
|
||||||
|
// replace the history item with a url including parameters
|
||||||
|
window.history.replaceState(null, null, url.parsed.href);
|
||||||
|
// make sure that the parameters are not removed from the visible url
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
})(window);
|
})(window);
|
Loading…
Reference in New Issue
Block a user