Better network connectivity status reporting and handling of orientation change events.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1194948 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
11adbc1719
commit
d114612218
17 changed files with 328 additions and 102 deletions
|
|
@ -22,7 +22,7 @@
|
|||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td><h2><span id="h1"></span><span id="userNameHeader"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
@ -102,11 +102,16 @@ var savedaccountentryxml = '';
|
|||
* Get and display the user's account.
|
||||
*/
|
||||
function getaccount(name) {
|
||||
showStatus('Loading');
|
||||
|
||||
return accounts.get(name, function(doc) {
|
||||
|
||||
// Stop now if we didn't get an account
|
||||
if (doc == null)
|
||||
if (doc == null) {
|
||||
showStatus('No data');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
accountentry = doc != null? car(elementsToValues(atom.readATOMEntry(mklist(doc)))) : mklist("'entry", mklist("'title", ''), mklist("'id", name));
|
||||
username = cadr(assoc("'id", cdr(accountentry)));
|
||||
|
|
@ -149,11 +154,16 @@ function getaccount(name) {
|
|||
function save(entryxml) {
|
||||
if (isNil(username))
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Saving';
|
||||
showStatus('Saving');
|
||||
savedaccountentryxml = entryxml;
|
||||
accounts.put(username, savedaccountentryxml, function(e) {
|
||||
if (!e)
|
||||
$('saveStatus').innerHTML = 'Saved';
|
||||
if (e) {
|
||||
showStatus('Local copy');
|
||||
return false;
|
||||
}
|
||||
|
||||
showStatus('Saved');
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
|
@ -181,7 +191,7 @@ function onaccountchange() {
|
|||
if (savedaccountentryxml == entryxml)
|
||||
return false;
|
||||
|
||||
$('saveStatus').innerHTML = 'Modified';
|
||||
showStatus('Modified');
|
||||
return save(entryxml);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html manifest="/cache-manifest.cmf">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<link rel="apple-touch-icon" href="/public/touchicon.png"/>
|
||||
|
|
@ -47,16 +47,16 @@ appcache.get = function(uri) {
|
|||
http.send(null);
|
||||
if (http.status == 200) {
|
||||
if (http.getResponseHeader("X-Login") != null) {
|
||||
if (log) log('http err', u, 'X-Login');
|
||||
if (log) log('http error', u, 'X-Login');
|
||||
return null;
|
||||
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
|
||||
if (log) log('http err', u, 'No-Content');
|
||||
if (log) log('http error', u, 'No-Content');
|
||||
return null;
|
||||
}
|
||||
localStorage.setItem(u, http.responseText);
|
||||
return http.responseText;
|
||||
}
|
||||
if (log) log('http err', u, http.status, http.statusText);
|
||||
if (log) log('http error', u, http.status, http.statusText);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
|
@ -561,7 +561,7 @@ function getpagedata() {
|
|||
// Get the component app data
|
||||
startcomp.get(location.search, function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(start, ' + location.search + ')', e);
|
||||
log('error on get(start, ' + location.search + ')', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ function getpagedata() {
|
|||
// Get and eval the optional timer, animation and location watch setup scripts
|
||||
timercomp.get('setup', function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(timer, setup)', e);
|
||||
log('error on get(timer, setup)', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +581,7 @@ function getpagedata() {
|
|||
});
|
||||
animationcomp.get('setup', function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(animation, setup)', e);
|
||||
log('error on get(animation, setup)', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -590,7 +590,7 @@ function getpagedata() {
|
|||
});
|
||||
locationcomp.get('setup', function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(location, setup)', e);
|
||||
log('error on get(location, setup)', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -601,7 +601,7 @@ function getpagedata() {
|
|||
return true;
|
||||
|
||||
} catch(e) {
|
||||
log('exception in getpagedata()', e);
|
||||
log('error in getpagedata()', e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -639,7 +639,7 @@ function buttonClickHandler(id) {
|
|||
var uri = compquery();
|
||||
return sca.component(id).get(uri, function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(button, ' + uri + ')', e);
|
||||
log('error on get(button, ' + uri + ')', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -647,7 +647,7 @@ function buttonClickHandler(id) {
|
|||
updatepage(docdata(doc));
|
||||
});
|
||||
} catch(e) {
|
||||
log('exception in buttonClickHandler()', e);
|
||||
log('error in buttonClickHandler()', e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ function intervalHandler() {
|
|||
var uri = compquery();
|
||||
return timercomp.get(uri, function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(timer, ' + uri + ')', e);
|
||||
log('error on get(timer, ' + uri + ')', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -668,7 +668,7 @@ function intervalHandler() {
|
|||
updatepage(docdata(doc));
|
||||
});
|
||||
} catch(e) {
|
||||
log('exception in intervalHandler()', e);
|
||||
log('error in intervalHandler()', e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -681,7 +681,7 @@ function setupIntervalHandler(msec) {
|
|||
try {
|
||||
return setInterval(intervalHandler, msec);
|
||||
} catch(e) {
|
||||
log('exception in setupIntervalHandler()', e);
|
||||
log('error in setupIntervalHandler()', e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -734,7 +734,7 @@ function animationHandler() {
|
|||
var uri = compquery();
|
||||
return animationcomp.get(uri, function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(animation, ' + uri + ')', e);
|
||||
log('error on get(animation, ' + uri + ')', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -750,7 +750,7 @@ function animationHandler() {
|
|||
return applyAnimation();
|
||||
|
||||
} catch(e) {
|
||||
log('exception in animationHandler()', e);
|
||||
log('error in animationHandler()', e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -764,7 +764,7 @@ function setupAnimationHandler(msec, loop) {
|
|||
try {
|
||||
return setInterval(animationHandler, msec);
|
||||
} catch(e) {
|
||||
log('exception in setupAnimationHandler()', e);
|
||||
log('error in setupAnimationHandler()', e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -781,7 +781,7 @@ function locationHandler(pos) {
|
|||
var uri = compquery();
|
||||
return locationcomp.get(uri, function(doc, e) {
|
||||
if (isNil(doc)) {
|
||||
log('exception on get(location, ' + uri + ')', e);
|
||||
log('error on get(location, ' + uri + ')', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +814,7 @@ function setupLocationHandler() {
|
|||
try {
|
||||
locationWatch = navigator.geolocation.watchPosition(locationHandler, locationErrorHandler);
|
||||
} catch(e) {
|
||||
log('exception in installLocationHandler()', e);
|
||||
log('error in installLocationHandler()', e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -826,9 +826,9 @@ function setupLocationHandler() {
|
|||
|
||||
// Load the app page
|
||||
pagecomp.get('app.html', function(doc, e) {
|
||||
log('page get');
|
||||
//log('page get');
|
||||
if (isNil(doc)) {
|
||||
log('exception getting app page', e);
|
||||
log('error getting app page', e);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -839,6 +839,18 @@ pagecomp.get('app.html', function(doc, e) {
|
|||
getpagedata();
|
||||
});
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document load post processing.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td><h2><span id="h1"></span><span id="appNameHeader"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
@ -99,11 +100,16 @@ var savedappentryxml = '';
|
|||
function getapp(name) {
|
||||
if (isNil(name))
|
||||
return false;
|
||||
showStatus('Loading');
|
||||
|
||||
return apps.get(name, function(doc) {
|
||||
|
||||
// Stop now if we didn't get the app
|
||||
if (doc == null)
|
||||
if (doc == null) {
|
||||
showStatus('No data');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
appentry = doc != null? car(elementsToValues(atom.readATOMEntry(mklist(doc)))) : mklist("'entry", mklist("'title", ''), mklist("'id", name));
|
||||
var title = cadr(assoc("'title", cdr(appentry)));
|
||||
|
|
@ -121,14 +127,18 @@ $('cloneAppForm').onsubmit = function() {
|
|||
var name = $('appName').value;
|
||||
if (name == '')
|
||||
return false;
|
||||
showStatus('Saving');
|
||||
|
||||
// Clone the app
|
||||
var title = $('appTitle').value;
|
||||
var app = mklist(mklist("'entry", mklist("'title", title != ''? title : name), mklist("'id", appname)));
|
||||
var entry = atom.writeATOMEntry(valuesToElements(app));
|
||||
dashboards.put(name, car(entry), function(e) {
|
||||
if (e)
|
||||
if (e) {
|
||||
showStatus('Local copy');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
// Open it in the page editor
|
||||
ui.navigate('/#view=page&app=' + name, '_view');
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
<div id="bodydiv" class="bodydiv">
|
||||
|
||||
<table style="width: 100%;">
|
||||
<tr><td><h2><span id="h1"></span></h2></td></tr>
|
||||
<tr>
|
||||
<td><h2><span id="h1"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table style="width: 100%;">
|
||||
|
|
@ -72,14 +75,18 @@ $('createAppForm').onsubmit = function() {
|
|||
var name = $('appName').value;
|
||||
if (name == '')
|
||||
return false;
|
||||
showStatus('Saving');
|
||||
|
||||
// Clone the '.new' app template
|
||||
var title = $('appTitle').value;
|
||||
var app = mklist(mklist("'entry", mklist("'title", title != ''? title : name), mklist("'id", 'new')));
|
||||
var entry = atom.writeATOMEntry(valuesToElements(app));
|
||||
dashboards.put(name, car(entry), function(e) {
|
||||
if (e)
|
||||
if (e) {
|
||||
showStatus('Local copy');
|
||||
return false;
|
||||
}
|
||||
showStatus('Saved');
|
||||
|
||||
// Open it in the page editor
|
||||
ui.navigate('/#view=page&app=' + name, '_view');
|
||||
|
|
@ -95,6 +102,8 @@ $('createAppCancelButton').onclick = function() {
|
|||
history.back();
|
||||
};
|
||||
|
||||
showStatus(defaultStatus());
|
||||
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td><h2><span id="appNameHeader"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right; padding-right: 8px;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
|
||||
<td style="vertical-align: middle; text-align: right; padding-right: 8px;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
@ -1924,11 +1924,16 @@ function atomcomposite(doc) {
|
|||
function getapp(name, g) {
|
||||
if (isNil(name))
|
||||
return false;
|
||||
showStatus('Loading');
|
||||
|
||||
return composites.get(name, function(doc) {
|
||||
|
||||
// Stop now if we didn't get a composite
|
||||
if (doc == null)
|
||||
if (doc == null) {
|
||||
showStatus('No data');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
composite = atomcomposite(doc);
|
||||
if (isNil(composite)) {
|
||||
|
|
@ -2003,15 +2008,17 @@ function installpalette(name, pos, g, bg, palette, gpalettes) {
|
|||
* Save the current composite.
|
||||
*/
|
||||
function save(savexml) {
|
||||
$('saveStatus').innerHTML = 'Saving';
|
||||
showStatus('Saving');
|
||||
savedcomposxml = savexml;
|
||||
var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
|
||||
'<title type="text">' + appname + '</title><id>' + appname + '</id><content type="application/xml">' +
|
||||
savedcomposxml + '</content></entry>';
|
||||
composites.put(appname, entry, function(e) {
|
||||
if (e)
|
||||
if (e) {
|
||||
showStatus('Local copy');
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Saved';
|
||||
}
|
||||
showStatus('Saved');
|
||||
return false;
|
||||
});
|
||||
return true;
|
||||
|
|
@ -2024,17 +2031,17 @@ function oncomposchange(prop) {
|
|||
var newxml = car(writeXML(composite, false));
|
||||
if (savedcomposxml == newxml)
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Modified';
|
||||
showStatus('Modified');
|
||||
|
||||
// Save property changes right away
|
||||
if (prop)
|
||||
return save(newxml);
|
||||
|
||||
// Autosave other changes after 1 second
|
||||
$('saveStatus').innerHTML = 'Modified';
|
||||
showStatus('Modified');
|
||||
setTimeout(function() {
|
||||
if (savedcomposxml == newxml) {
|
||||
$('saveStatus').innerHTML = 'Saved';
|
||||
showStatus('Saved');
|
||||
return false;
|
||||
}
|
||||
return save(newxml);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
<div id="bodydiv" class="bodydiv">
|
||||
|
||||
<table style="width: 100%;">
|
||||
<tr><td><h2><span id="h1"></span></h2></td></tr>
|
||||
<tr>
|
||||
<td><h2><span id="h1"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div style="margin-left: auto; margin-right: auto; text-align: center;">
|
||||
|
|
@ -58,6 +61,8 @@ setInterval(function() {
|
|||
diagram.style.backgroundPosition = '0px ' + ui.pixpos(bgpos);
|
||||
}, 2000);
|
||||
|
||||
showStatus(defaultStatus());
|
||||
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html manifest="/cache-manifest.cmf">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<link rel="apple-touch-icon" href="/public/touchicon.png"/>
|
||||
|
|
@ -47,16 +47,16 @@ appcache.get = function(uri) {
|
|||
http.send(null);
|
||||
if (http.status == 200) {
|
||||
if (http.getResponseHeader("X-Login") != null) {
|
||||
if (log) log('http err', u, 'X-Login');
|
||||
if (log) log('http error', u, 'X-Login');
|
||||
return null;
|
||||
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
|
||||
if (log) log('http err', u, 'No-Content');
|
||||
if (log) log('http error', u, 'No-Content');
|
||||
return null;
|
||||
}
|
||||
localStorage.setItem(u, http.responseText);
|
||||
return http.responseText;
|
||||
}
|
||||
if (log) log('http err', u, http.status, http.statusText);
|
||||
if (log) log('http error', u, http.status, http.statusText);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
|
@ -137,39 +137,49 @@ var appresources = [
|
|||
*/
|
||||
applicationCache.addEventListener('checking', function(e) {
|
||||
//log('appcache checking', e);
|
||||
showStatus('Checking');
|
||||
}, false);
|
||||
applicationCache.addEventListener('error', function(e) {
|
||||
//log('appcache error', e);
|
||||
showStatus(defaultStatus());
|
||||
}, false);
|
||||
applicationCache.addEventListener('noupdate', function(e) {
|
||||
//log('appcache noupdate', e);
|
||||
showStatus(defaultStatus());
|
||||
}, false);
|
||||
applicationCache.addEventListener('downloading', function(e) {
|
||||
//log('appcache downloading', e);
|
||||
showStatus('Updating');
|
||||
}, false);
|
||||
applicationCache.addEventListener('progress', function(e) {
|
||||
//log('appcache progress', e);
|
||||
showStatus('Updating');
|
||||
}, false);
|
||||
applicationCache.addEventListener('updateready', function(e) {
|
||||
//log('appcache updateready', e);
|
||||
applicationCache.swapCache();
|
||||
showStatus(defaultStatus());
|
||||
//log('appcache swapped', e);
|
||||
}, false);
|
||||
applicationCache.addEventListener('cached', function(e) {
|
||||
//log('appcache cached', e);
|
||||
map(function(res) {
|
||||
showStatus('Updating');
|
||||
appcache.get(res[0]);
|
||||
}, appresources);
|
||||
showStatus(defaultStatus());
|
||||
}, false);
|
||||
|
||||
/**
|
||||
* Handle network offline/online events.
|
||||
*/
|
||||
window.addEventListener('offline', function(e) {
|
||||
//log('going offline');
|
||||
//log('going offline');
|
||||
showStatus('Offline');
|
||||
}, false);
|
||||
window.addEventListener('online', function(e) {
|
||||
//log('going online');
|
||||
//log('going online');
|
||||
showStatus('Online');
|
||||
}, false);
|
||||
|
||||
//log(navigator.onLine? 'online' : 'offline');
|
||||
|
|
@ -224,10 +234,7 @@ function mkviewdiv(cname) {
|
|||
* Return the last visited location.
|
||||
*/
|
||||
function lastvisited() {
|
||||
var loc = localStorage.getItem('ui.lastvisited')
|
||||
if (!isNil(loc))
|
||||
return loc;
|
||||
return '' + location;
|
||||
return localStorage.getItem('ui.lastvisited')
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -245,6 +252,24 @@ function showmenu(mdiv, view, appname) {
|
|||
mklist(ui.menu('Account', '/#view=account', '_view', view == 'account'), ui.menu('Sign out', '/logout/', '_self', false)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a status message.
|
||||
*/
|
||||
function showStatus(s) {
|
||||
var sdiv = $('status');
|
||||
if (isNil(sdiv))
|
||||
return s;
|
||||
sdiv.innerHTML = s;
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default status message.
|
||||
*/
|
||||
function defaultStatus() {
|
||||
return navigator.onLine? 'Online' : 'Offline';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a view.
|
||||
*/
|
||||
|
|
@ -352,21 +377,33 @@ function showview(url) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Handle navigations.
|
||||
* Update the browser window location.
|
||||
*/
|
||||
window.onnavigate = function(url) {
|
||||
//log('onnavigate', url);
|
||||
function updatelocation(url) {
|
||||
//log('updatelocation', url);
|
||||
|
||||
// Add url to the history
|
||||
// Add url to the history if necessary
|
||||
if (url != ui.pathandparams(location)) {
|
||||
history.pushState(null, null, url);
|
||||
//log('pushstate', history.length);
|
||||
|
||||
// Update the location hash if necessary
|
||||
var f = ui.fragment(url);
|
||||
if (f != '' && f != location.hash) {
|
||||
location.hash = f;
|
||||
//log('hash', f);
|
||||
}
|
||||
//log('pushstate', history.length);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle navigations.
|
||||
*/
|
||||
window.onnavigate = function(url) {
|
||||
//log('onnavigate', url);
|
||||
|
||||
updatelocation(url);
|
||||
|
||||
// Show the specified view
|
||||
if (url == viewurl)
|
||||
|
|
@ -378,7 +415,7 @@ window.onnavigate = function(url) {
|
|||
* Handle history.
|
||||
*/
|
||||
window.addEventListener('popstate', function(e) {
|
||||
//log('popstate', history.length);
|
||||
//log('onpopstate', history.length);
|
||||
var furl = ui.fragment(location);
|
||||
var url = location.pathname + (furl == ''? '' : '#' + furl);
|
||||
|
||||
|
|
@ -401,27 +438,51 @@ window.addEventListener('hashchange', function(e) {
|
|||
|
||||
}, false);
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload', history.length);
|
||||
var furl = ui.fragment(location);
|
||||
url = location.pathname + (furl == ''? '' : '#' + furl);
|
||||
|
||||
// Show the current view
|
||||
// Show the view specified in the given url fragment
|
||||
if (furl != '') {
|
||||
var url = location.pathname + '#' + furl;
|
||||
if (url == viewurl)
|
||||
return true;
|
||||
return showview(url);
|
||||
}
|
||||
|
||||
// Show the last visited view
|
||||
if (ui.isMobile() && (document.referrer == null || document.referrer == '')) {
|
||||
//log('show lastvisited');
|
||||
var lv = lastvisited();
|
||||
var url = isNil(lv)? location.pathname : lv;
|
||||
updatelocation(url);
|
||||
if (url == viewurl)
|
||||
return true;
|
||||
return showview(url);
|
||||
}
|
||||
|
||||
// Show the main home view
|
||||
var url = location.pathname;
|
||||
if (url == viewurl)
|
||||
return true;
|
||||
return showview(url);
|
||||
}
|
||||
|
||||
// Show the last visited view
|
||||
//if (ui.isMobile() && (document.referrer == null || document.referrer == '')) {
|
||||
//log('show lastvisited');
|
||||
//showview(lastvisited());
|
||||
//} else
|
||||
//showview('/');
|
||||
|
||||
</script>
|
||||
|
||||
<div id="footdiv" class="fsection">
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Sign in</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<base href="/login/"/>
|
||||
|
|
@ -75,12 +75,28 @@ function submitSignin() {
|
|||
document.formSignin.submit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload');
|
||||
|
||||
// Show the page
|
||||
document.body.style.visibility = 'visible';
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 1);
|
||||
window.scrollTo(0, 0);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Sign out</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<base href="/logout/"/>
|
||||
|
|
@ -46,12 +46,28 @@ function submitSignout() {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Document load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload');
|
||||
|
||||
// Show the page
|
||||
document.body.style.visibility = 'visible';
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 1);
|
||||
window.scrollTo(0, 0);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Sorry</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, target-densitydpi=devicedpi"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<base href="/notauth/"/>
|
||||
|
|
@ -46,16 +46,16 @@ appcache.get = function(uri) {
|
|||
http.send(null);
|
||||
if (http.status == 200) {
|
||||
if (http.getResponseHeader("X-Login") != null) {
|
||||
if (log) log('http err', u, 'X-Login');
|
||||
if (log) log('http error', u, 'X-Login');
|
||||
return null;
|
||||
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
|
||||
if (log) log('http err', u, 'No-Content');
|
||||
if (log) log('http error', u, 'No-Content');
|
||||
return null;
|
||||
}
|
||||
localStorage.setItem(u, http.responseText);
|
||||
return http.responseText;
|
||||
}
|
||||
if (log) log('http err', u, http.status, http.statusText);
|
||||
if (log) log('http error', u, http.status, http.statusText);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
|
@ -116,10 +116,24 @@ function showmenu(mdiv) {
|
|||
showmenu($('menu'));
|
||||
cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload');
|
||||
|
||||
// Show the page
|
||||
document.body.style.visibility = 'visible';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Page not found</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, target-densitydpi=devicedpi"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<base href="/notfound/"/>
|
||||
|
|
@ -46,16 +46,16 @@ appcache.get = function(uri) {
|
|||
http.send(null);
|
||||
if (http.status == 200) {
|
||||
if (http.getResponseHeader("X-Login") != null) {
|
||||
if (log) log('http err', u, 'X-Login');
|
||||
if (log) log('http error', u, 'X-Login');
|
||||
return null;
|
||||
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
|
||||
if (log) log('http err', u, 'No-Content');
|
||||
if (log) log('http error', u, 'No-Content');
|
||||
return null;
|
||||
}
|
||||
localStorage.setItem(u, http.responseText);
|
||||
return http.responseText;
|
||||
}
|
||||
if (log) log('http err', u, http.status, http.statusText);
|
||||
if (log) log('http error', u, http.status, http.statusText);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
|
@ -117,10 +117,24 @@ function showmenu(mdiv) {
|
|||
showmenu(mdiv);
|
||||
div.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload');
|
||||
|
||||
// Show the page
|
||||
document.body.style.visibility = 'visible';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Page not found</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, target-densitydpi=devicedpi"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<base href="/notyet/"/>
|
||||
|
|
@ -46,16 +46,16 @@ appcache.get = function(uri) {
|
|||
http.send(null);
|
||||
if (http.status == 200) {
|
||||
if (http.getResponseHeader("X-Login") != null) {
|
||||
if (log) log('http err', u, 'X-Login');
|
||||
if (log) log('http error', u, 'X-Login');
|
||||
return null;
|
||||
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
|
||||
if (log) log('http err', u, 'No-Content');
|
||||
if (log) log('http error', u, 'No-Content');
|
||||
return null;
|
||||
}
|
||||
localStorage.setItem(u, http.responseText);
|
||||
return http.responseText;
|
||||
}
|
||||
if (log) log('http err', u, http.status, http.statusText);
|
||||
if (log) log('http error', u, http.status, http.statusText);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
|
@ -117,10 +117,24 @@ function showmenu(mdiv) {
|
|||
showmenu($('menu'));
|
||||
cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload');
|
||||
|
||||
// Show the page
|
||||
document.body.style.visibility = 'visible';
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Oops</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, target-densitydpi=devicedpi"/>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0/>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<base href="/oops/"/>
|
||||
|
|
@ -46,16 +46,16 @@ appcache.get = function(uri) {
|
|||
http.send(null);
|
||||
if (http.status == 200) {
|
||||
if (http.getResponseHeader("X-Login") != null) {
|
||||
if (log) log('http err', u, 'X-Login');
|
||||
if (log) log('http error', u, 'X-Login');
|
||||
return null;
|
||||
} else if (http.responseText == '' || http.getResponseHeader("Content-Type") == null) {
|
||||
if (log) log('http err', u, 'No-Content');
|
||||
if (log) log('http error', u, 'No-Content');
|
||||
return null;
|
||||
}
|
||||
localStorage.setItem(u, http.responseText);
|
||||
return http.responseText;
|
||||
}
|
||||
if (log) log('http err', u, http.status, http.statusText);
|
||||
if (log) log('http error', u, http.status, http.statusText);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
|
@ -116,10 +116,24 @@ function showmenu(mdiv) {
|
|||
showmenu($('menu'));
|
||||
cdiv.style.top = ui.pixpos(mdiv.offsetTop + mdiv.offsetHeight);
|
||||
|
||||
/**
|
||||
* Handle orientation change.
|
||||
*/
|
||||
document.body.onorientationchange = function(e) {
|
||||
//log('onorientationchange');
|
||||
|
||||
// Scroll to the top and hide the address bar
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load post processing.
|
||||
*/
|
||||
function onload() {
|
||||
//log('onload');
|
||||
|
||||
// Show the page
|
||||
document.body.style.visibility = 'visible';
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td><h2><span id="appNameHeader"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right; padding-right: 8px;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
|
||||
<td style="vertical-align: middle; text-align: right; padding-right: 8px;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
@ -744,11 +744,16 @@ var widget = null;
|
|||
function getpage(name, ediv) {
|
||||
if (isNil(name))
|
||||
return false;
|
||||
showStatus('Loading');
|
||||
|
||||
return pages.get(name, function(doc) {
|
||||
|
||||
// Stop now if we didn't get a page
|
||||
if (doc == null)
|
||||
if (doc == null) {
|
||||
showStatus('No data');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
// Convert the page to XHTML and place it in a hidden buffer
|
||||
var buffer = $('buffer');
|
||||
|
|
@ -861,7 +866,7 @@ function pagexhtml(ediv) {
|
|||
* Save the current page.
|
||||
*/
|
||||
function save(newxml) {
|
||||
$('saveStatus').innerHTML = 'Saving';
|
||||
showStatus('Saving');
|
||||
|
||||
// Get the current page XHTML content
|
||||
savedpagexhtml = newxml;
|
||||
|
|
@ -872,9 +877,11 @@ function save(newxml) {
|
|||
newxml + '</content></entry>';
|
||||
|
||||
pages.put(appname, entry, function(e) {
|
||||
if (e)
|
||||
if (e) {
|
||||
showStatus('Local copy');
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Saved';
|
||||
}
|
||||
showStatus('Saved');
|
||||
return false;
|
||||
});
|
||||
return true;
|
||||
|
|
@ -887,7 +894,7 @@ function onpagechange(prop) {
|
|||
var newxml = pagexhtml(ediv);
|
||||
if (savedpagexhtml == newxml)
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Modified';
|
||||
showStatus('Modified');
|
||||
|
||||
// Save property changes right away
|
||||
if (prop)
|
||||
|
|
@ -896,7 +903,7 @@ function onpagechange(prop) {
|
|||
// Autosave other changes after 1 second
|
||||
setTimeout(function() {
|
||||
if (savedpagexhtml == newxml) {
|
||||
$('saveStatus').innerHTML = 'Saved';
|
||||
showStatus('Saved');
|
||||
return false;
|
||||
}
|
||||
return save(newxml);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td><h2><span id="h1"></span><span id="appNameHeader"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="saveStatus" style="font-weight: bold; color: #808080;">Saved</span></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
|
@ -96,11 +96,16 @@ var savedappentryxml = '';
|
|||
function getapp(name) {
|
||||
if (isNil(name))
|
||||
return false;
|
||||
showStatus('Loading');
|
||||
|
||||
return apps.get(name, function(doc) {
|
||||
|
||||
// Stop now if we didn't get the app
|
||||
if (doc == null)
|
||||
if (doc == null) {
|
||||
showStatus('No data');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
appentry = doc != null? car(elementsToValues(atom.readATOMEntry(mklist(doc)))) : mklist("'entry", mklist("'title", ''), mklist("'id", name));
|
||||
var title = cadr(assoc("'title", cdr(appentry)));
|
||||
|
|
@ -116,12 +121,15 @@ function getapp(name) {
|
|||
* Save the current app.
|
||||
*/
|
||||
function save(entryxml) {
|
||||
$('saveStatus').innerHTML = 'Saving';
|
||||
showStatus('Saving');
|
||||
savedappentryxml = entryxml;
|
||||
dashboards.put(appname, savedappentryxml, function(e) {
|
||||
if (e)
|
||||
if (e) {
|
||||
showStatus('Local copy');
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Saved';
|
||||
}
|
||||
|
||||
showStatus('Saved');
|
||||
return false;
|
||||
});
|
||||
return true;
|
||||
|
|
@ -136,7 +144,7 @@ function onappchange() {
|
|||
var entryxml = car(atom.writeATOMEntry(valuesToElements(mklist(appentry))));
|
||||
if (savedappentryxml == entryxml)
|
||||
return false;
|
||||
$('saveStatus').innerHTML = 'Modified';
|
||||
showStatus('Modified');
|
||||
return save(entryxml);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
<div id="bodydiv" class="bodydiv">
|
||||
|
||||
<table style="width: 100%;">
|
||||
<tr><td><h2><span id="h1"></span></h2></td></tr>
|
||||
<tr>
|
||||
<td><h2><span id="h1"></span></h2></td>
|
||||
<td style="vertical-align: middle; text-align: right;"><span id="status" style="font-weight: bold; color: #808080;"></span></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="catmenu"></div>
|
||||
|
|
@ -115,11 +118,16 @@ if (category == 'myapps') {
|
|||
*/
|
||||
function getapps(category) {
|
||||
//log('category', category);
|
||||
showStatus('Loading');
|
||||
|
||||
function display(doc) {
|
||||
|
||||
// Stop now if we didn't get the apps
|
||||
if (doc == null)
|
||||
if (doc == null) {
|
||||
showStatus('No data');
|
||||
return false;
|
||||
}
|
||||
showStatus(defaultStatus());
|
||||
|
||||
var apps = '<div>';
|
||||
var feed = car(elementsToValues(atom.readATOMFeed(mklist(doc))));
|
||||
|
|
|
|||
|
|
@ -180,13 +180,14 @@ overflow: hidden;
|
|||
}
|
||||
|
||||
.hsection {
|
||||
width: 100%; height: 50px;
|
||||
width: 100%; height: 0px; visibility: hidden;
|
||||
border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; border-style: solid; border-bottom-color: #000000; background-color: #ffffff;
|
||||
padding: 0px; margin-bottom: 0px; margin-left: auto; margin-right: auto; text-align: center;
|
||||
}
|
||||
|
||||
.fsection{
|
||||
width: 100%; height: 50px; border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; border-style: solid; border-top-color: #a2bae7;
|
||||
width: 100%; height: 0px; visibility: hidden;
|
||||
border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; border-style: solid; border-top-color: #a2bae7;
|
||||
padding: 0px; margin-top: 0px; margin-left: auto; margin-right: auto; text-align: center;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue