22. Changing the href listeners
Every time we change the page
// -- Set android params -- //
function setAndroidParams(href)
{
" if (href) {
" " var n = href.indexOf('?');
" " window.localStorage.setItem("android-href", href);
" " href = href.substring(0, n != -1 ? n : href.length);
" " return href;
" }
}
// -- Android anchor listener -- //
function refresh_android_listener(page_div, event){
" " $(page_div).on(event, 'a', function() {
" " " var href = $(this).attr('href');
" " " if (href && href != "#" && href.search("tel") == -1){
" " " " change_page(href);
" " " " return false;
" " " }
" " });
}
23. Accessing URL parameters
statuses_show.html?status_id=104381
function getParamValue(param,url) {
// Android only
url = window.localStorage.getItem("android-href");
" // Common to iOS and Android
" var u = (url == undefined || (url != undefined && url.indexOf("?") == -1)) ?
document.location.href : url;
var reg = new RegExp('(?|&|^)'+param+'=(.*?)(&|$)');
" matches = u.match(reg);
return (matches != undefined && matches.length > 1) ?
decodeURIComponent(matches[2]).replace(/+/g,' ') : null;
}
24. Same function names
on iOS and Android
function triggerActionSheet(param,url) {
// Android only
}
function triggerActionSheet(param,url) {
// iOS Only
}