123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119 |
- var map;
- var isOnline = false;
- var docDir;
- var doc;
- var file;
- var fileRecorded = false;
- function setLat(lat) {
- if (document.getElementById("lat").value != lat) {
- document.getElementById("lat").value = lat;
- }
- }
- function setLon(lon) {
- if (document.getElementById("lon").value != lon) {
- document.getElementById("lon").value = lon;
- }
- }
- function getLink(provider) {
- var lat = $("#lat").val();
- var lon = $("#lon").val();
- var url;
- switch(provider)
- {
- case 'OSM' :
- url =
- "http://www.openstreetmap.org/?&zoom=10&layers=mapnik&lat=${lat}&lon=${lon}";
- break;
- case 'GM' :
- url = "http://maps.google.com/maps?&z=10&ll=${lat},${lon}";
- break;
- case 'NOKIA' :
- url = "http://maps.nokia.com/${lat},${lon},16,0,0,normal.day";
- break;
- default :
- url = "http://www.openstreetmap.org/?&zoom=10&layers=mapnik&lat=${lat}&lon=${lon}";
- break;
- }
- url = url.replace("${lon}", lon);
- url = url.replace("${lat}", lat);
- return url;
- }
- function goToURL(provider) {
- if (isOnline) {
- var appControl = new tizen.ApplicationControl(
- "http://tizen.org/appcontrol/operation/view",
- getLink(provider), null);
- var appControlReplyCallback = {
- onsuccess : function(data) {
- for ( var i = 0; i < data.length; i++) {
- console.log("#" + i + " key:" + data[i].key);
- for ( var j = 0; j < data[i].value.length; j++) {
- console.log(" value#" + j + ":" + data[i].value[j]);
- }
- }
- },
- onfailure : function() {
- console.log('The launch application control failed');
- }
- }
- tizen.application.launchAppControl(appControl, null, function() {
- console.log("launch internet application control succeed");
- }, function(e) {
- console.log("launch internet application control failed. reason: "
- + e.message);
- }, appControlReplyCallback);
- } else {
- alert("Please connect your application online in the settings"
- + " if you want to open a browser")
- }
- }
- function getMapSize() {
- var viewHeight = $(window).height();
- var viewWidth = $(window).width();
- var header = $("div[data-role='header']:visible:visible");
- var footer = $("div[data-role='footer']:visible:visible");
- var navbar = $("div[data-role='navbar']:visible:visible");
- var content = $("div[data-role='content']:visible:visible");
- var contentHeight = viewHeight - header.outerHeight()
- - navbar.outerHeight() - footer.outerHeight();
- var contentWidth = viewWidth - 30;
- return [ contentWidth, contentHeight ];
- }
- function setMapSize() {
- var mapSize = getMapSize();
- $('#myMap').css("width", mapSize[0]);
- $('#myMap').css("height", mapSize[1]);
- }
- function initIcon(){
- var size = new OpenLayers.Size(21,25);
- var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
-
- return new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);
- }
- function chargeCourse(data){
- log("chargeCourse data : "+data['dates'][0]);
- var icon = initIcon();
-
- log("tab lons = "+data['lons']);
- log("tab lats = "+data['lats']);
- log("tab dates = "+data['dates']);
-
- for(var i= 0; i<data['dates'].length; i++){
- var lon = parseFloat(data['lons'][i]);
- var lat = parseFloat(data['lats'][i]);
- var date = data['dates'][i];
- log("data['dates']["+i+"] = "+date);
- log("data['lons']["+i+"] = "+lon);
- log("data['lat']["+i+"] = "+lat);
- log("lat before : "+lat);
- log("lon before : "+lon);
- var lonlat = new OpenLayers.LonLat(lon,lat).transform('EPSG:4326', 'EPSG:3857');
- var mark = new OpenLayers.Marker(lonlat,icon);
- course.addMarker(mark);
- }
- map.addLayer(course);
- log("finito");
- }
- function chargeMap() {
- var latCenter = $("#lat").val();
- var lonCenter = $("#lon").val();
- map = new OpenLayers.Map('myMap', {
- projection : 'EPSG:3857',
- layers : [ new OpenLayers.Layer.OSM("OpenStreetMap"),
- new OpenLayers.Layer.Google("Google Streets",
- {numZoomLevels:20}),
- new OpenLayers.Layer.Google("Google Physical",
- {type : google.maps.MapTypeId.TERRAIN}),
- new OpenLayers.Layer.Google("Google Hybrid",
- {type : google.maps.MapTypeId.HYBRID,numZoomLevels : 20}),
- new OpenLayers.Layer.Google("Google Satellite",
- {type : google.maps.MapTypeId.SATELLITE,numZoomLevels : 22})
- ],
- center : new OpenLayers.LonLat(lonCenter, latCenter).transform('EPSG:4326', 'EPSG:3857'),
- zoom : 7
- });
- map.addControl(new OpenLayers.Control.LayerSwitcher());
-
- if(fileRecorded){
-
-
-
-
- var markers = map.getLayersByName("Last recorded course");
- if(markers.length!=0){
- var previousCourse = markers[0];
- log("course = "+previousCourse.name);
- previousCourse.destroy();
- }
-
- course = new OpenLayers.Layer.Markers("Last recorded course");
-
- readFile();
- }
- }
- function fromLatLonToDMS(lat, lon) {
- var latitude = lat;
- var longitude = lon;
- var dms="";
- var NS="";
- if (latitude >= 0) {
- NS += "N";
- } else {
- latitude = -latitude;
- NS += "S";
- }
- var dLat = parseInt(latitude, 10);
- var mLat = parseInt((latitude - dLat) * 60, 10);
- var sLat = parseInt((latitude-dLat)*60*60 - 60*mLat, 10);
- dms += NS+" "+dLat+"° "+mLat+"' "+sLat+"\" ";
- var EW="";
- if (longitude >= 0) {
- EW += "E";
- } else {
- EW += "W";
- longitude = -longitude;
- }
- var dLon = parseInt(longitude, 10);
- var mLon = parseInt((longitude - dLon) * 60, 10);
- var sLon = parseInt((longitude-dLon)*60*60 - 60*mLon, 10);
- dms += EW+" "+dLon+"° "+mLon+"' "+sLon+"\"";
-
- return dms;
- }
- function fromDMSToLatLon(dms){
- var re =
- /^([NS])\s*([0-9.\-]+)\s*°\s*([0-9.\-]+)\s*\'\s*([0-9.\-]+)\s*\"\s*([EW])\s*([0-9.\-]+)\s*°\s*([0-9.\-]+)\s*\'\s*([0-9.\-]+)\s*\"\s*$/;
- if(re.test(dms)){
- var lat = (parseFloat(RegExp.$2)+parseFloat(RegExp.$3)/60+parseFloat(RegExp.$4)/(60*60)).toFixed(6);
- if(RegExp.$1=='S'){
- lat=-lat;
- }
- lat = lat.toString();
- setLat(lat);
- var lon = (parseFloat(RegExp.$6)+parseFloat(RegExp.$7)/60+parseFloat(RegExp.$8)/(60*60)).toFixed(6);
- if(RegExp.$5=='W'){
- lon=-lon;
- }
- lon = lon.toString();
- setLon(lon);
- }
- }
- function setDMS() {
- $('#dms').val(fromLatLonToDMS($("#lat").val(), $("#lon").val()));
- }
- function setLatLon(){
- var coordinates = fromDMSToLatLon($('#dms').val());
- }
- function validateDMS(dms){
- var re =
- /^([NS])\s*([0-9.\-]+)\s*°\s*([0-9.\-]+)\s*\'\s*([0-9.\-]+)\s*\"\s*([EW])\s*([0-9.\-]+)\s*°\s*([0-9.\-]+)\s*\'\s*([0-9.\-]+)\s*\"\s*$/;
- if (re.test(dms)) {
- return true;
- } else {
- return false;
- }
- }
- function validateLatOrLon(latOrLon){
- if(/^[0-9.\-]+$/.test(latOrLon)){
- return true;
- } else {
- return false;
- }
- }
- function changeLat(){
- var lat = $('#lat').val();
- if(validateLatOrLon(lat)){
- $('#lat').val(parseFloat($('#lat').val()).toFixed(6).toString());
- setDMS();
- storeData();
- } else {
- alert("Latitude coordinate invalid : "+lat);
- initData();
- }
- }
- function changeLon(){
- var lon = $('#lon').val();
- if(validateLatOrLon(lon)){
- $('#lon').val(parseFloat($('#lon').val()).toFixed(6).toString());
- setDMS();
- storeData();
- } else {
- alert("Lontitude coordinate invalid : "+lon);
- initData();
- }
- }
- function changeDMS(){
- var dms = $('#dms').val();
- if(validateDMS(dms)){
- setLatLon();
- storeData();
- } else {
- alert("DMS coordinate invalid : "+dms);
- initData();
- }
- }
- function handleShowLocation(position) {
- var lat = position.coords.latitude.toFixed(6).toString();
- var lon = position.coords.longitude.toFixed(6).toString();
- setLat(lat);
- setLon(lon);
- refresh();
- }
- function handleErrorLocation(error) {
- var errorInfo = document.getElementById("locationInfo");
- switch (error.code) {
- case error.PERMISSION_DENIED:
- errorInfo.innerHTML = "User denied the request for Geolocation.";
- break;
- case error.POSITION_UNAVAILABLE:
- errorInfo.innerHTML = "Location information is unavailable.";
- break;
- case error.TIMEOUT:
- errorInfo.innerHTML = "The request to get user location timed out.";
- break;
- case error.UNKNOWN_ERROR:
- errorInfo.innerHTML = "An unknown error occurred.";
- break;
- }
- }
- function getLocation() {
- if (navigator.geolocation ) {
- navigator.geolocation.getCurrentPosition(handleShowLocation, handleErrorLocation,
- {enableHighAccuracy : $('#switchEnergy').val() == 'off'});
- } else {
- document.getElementById("locationInfo").innerHTML =
- "Geolocation is not supported by this browser.";
- }
- }
- function handleResolveSuccess(dir) {
- docDir = dir;
- var date = new Date();
- var dateFile = date.getDate().toString()+"."+date.getMonth().toString()+"."+date.getFullYear().toString()
- +"-"+date.getHours().toString()+":"+date.getMinutes().toString()+":"+date.getSeconds().toString();
-
- doc = 'MAPO_' + dateFile + ".txt";
- docDir.createFile(doc);
- $('#locationInfo').html("Course recording in the file:<br/>" + doc);
- }
- function handleResolveError(e) {
- console.log('message: ' + e.message);
- }
- function resolveFile() {
- try {
- file = docDir.resolve(doc);
- } catch (exc) {
- console.log('Could not resolve file: '+exc.message);
-
- return;
- }
- }
- function handleRecordError(e) {
- var msg = '';
- switch (e.code) {
- case FileError.QUOTA_EXCEEDED_ERR:
- msg = 'QUOTA_EXCEEDED_ERR';
- break;
- case FileError.NOT_FOUND_ERR:
- msg = 'NOT_FOUND_ERR';
- break;
- case FileError.SECURITY_ERR:
- msg = 'SECURITY_ERR';
- break;
- case FileError.INVALID_MODIFICATION_ERR:
- msg = 'INVALID_MODIFICATION_ERR';
- break;
- case FileError.INVALID_STATE_ERR:
- msg = 'INVALID_STATE_ERR';
- break;
- default:
- msg = 'Unknown Error';
- break;
- }
- console.log('Error: ' + msg);
- }
- function writeToStream(fileStream) {
- try {
- var date = new Date();
-
- var dateRecord = date.getDate().toString()+"."+date.getMonth().toString()+"."+date.getFullYear().toString()
- +"-"+date.getHours().toString()+":"+date.getMinutes().toString()+":"+date.getSeconds().toString();
-
- var lat = $("#lat").val();
- var lon = $("#lon").val();
-
-
- fileStream.write("\r"+dateRecord+";"+lat+";"+lon);
- fileStream.close();
- } catch (exc) {
- console.log('Could not write to file: ' + exc.message);
- }
- }
- function writeRecord() {
- try {
- file.openStream(
-
- 'a',
-
- writeToStream,
-
- handleRecordError);
- } catch (exc) {
- console.log('Could not write to file: ' + exc.message);
- }
- }
- function readFromStream(fileStream) {
- try {
- console.log('File size: ' + file.fileSize);
- var contents = fileStream.read(fileStream.bytesAvailable);
- fileStream.close();
- console.log('file contents: ' + contents);
- } catch (exc) {
- console.log('Could not read from file: ' + exc.message);
- }
- }
- function readRecord() {
- try {
- file.openStream(
-
- 'r',
-
- readFromStream,
-
- handleRecordError);
- } catch (exc) {
- console.log('Could not write to file: ' + exc.message);
- }
- }
- function handleRecordPosition(position) {
- if ($('#switchRecord').val() == "start") {
- handleShowLocation(position);
- resolveFile();
- writeRecord();
- readRecord();
- }
- }
- function handleErrorPosition(error) {
- $('#switchRecord').val('stop').slider('refresh');
- var errorInfo = document.getElementById("locationInfo");
- switch (error.code) {
- case error.PERMISSION_DENIED:
- errorInfo.innerHTML = "User denied the request for Geolocation.";
- break;
- case error.POSITION_UNAVAILABLE:
- errorInfo.innerHTML = "Location information is unavailable.";
- break;
- case error.TIMEOUT:
- errorInfo.innerHTML = "The request to get user location timed out.";
- break;
- case error.UNKNOWN_ERROR:
- errorInfo.innerHTML = "An unknown error occurred.";
- break;
- }
- }
- function getPosition() {
- navigator.geolocation.getCurrentPosition(handleRecordPosition, handleErrorPosition,
- {enableHighAccuracy : $('#switchEnergy').val() == 'off'});
- }
- function record() {
- if (navigator.geolocation) {
- var intervalID;
- if ($('#switchRecord').val() == "start") {
-
- tizen.filesystem.resolve('documents', handleResolveSuccess,
- handleResolveError, 'rw');
- getPosition();
- intervalID = setInterval(getPosition, $('#selectorTimeout').val() * 1000);
- } else {
- clearInterval(intervalID);
- $('#locationInfo').html("Course recorded in the file:<br/>" + doc);
- fileRecorded=true;
- }
- } else {
- document.getElementById("locationInfo").innerHTML =
- "Geolocation is not supported.";
- }
- }
- function readFile() {
-
- try {
- file = docDir.resolve(doc);
- console.log('File size: ' + file.fileSize);
- } catch (exceptionResolve) {
- console.log('Could not resolve file: ' + exceptionResolve.message);
-
- return;
- }
- try {
- file.readAsText(
-
- function(contents) {
-
-
- var lines = contents.split("\r");
- var re = /^([0-9.:\-]+);([0-9.\-]+);([0-9.\-]+)$/;
-
- var data = [];
-
- var dates = [];
- var lats = [];
- var lons = [];
- var iData = 0;
-
- for(var iLines=0; iLines<lines.length; iLines++){
-
- if(re.test(lines[iLines])) {
- log("line "+iLines+": "+lines[iLines]);
- var parts = lines[iLines].split(";");
- for(var iParts=0; iParts<parts.length; iParts++){
- log(" part "+iParts+": "+parts[iParts]);
- if((iParts%3)==0){
- dates[iData]=parts[iParts];
- log(" date "+iData+": "+dates[iData]);
- } else if((iParts%3)==1) {
- lats[iData]=parts[iParts];
- log(" lat "+iData+": "+lats[iData]);
- } else {
- lons[iData]=parts[iParts];
- log(" lon "+iData+": "+lons[iData]);
- }
- }
- iData++;
- }
- }
- data['dates'] = dates;
- data['lats'] = lats;
- data['lons'] = lons;
-
- log("readfile data"+data['dates'][0]);
- chargeCourse(data);
- },
-
- handleRecordError
- );
- } catch (exceptionRead) {
- console.log("readAsText() exception:" + exceptionRead.message);
- }
-
-
- }
- function sendEmail() {
- if (isOnline) {
- var message =
- "This is the position I want to show you from Mapo:" +
- "\nLatitute="+$("#lat").val()+
- "\nLongitude = "+$("#lon").val()+
- "\nIf you prefer in DMS, here it is: "+$('#dms').val()+
- "\nYou can see this position on OpenStreetMap: "+getLink('OSM')+
- "\nConnect you on Mapo for more details!";
- var appControl = new tizen.ApplicationControl(
- "http://tizen.org/appcontrol/operation/send",
- "mailto:", null, null,
- [
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/subject", [ "Mapo" ]),
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/text", [ message ]),
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/to",
- [ "mapo.tizen@gmail.com" ])
-
- ]);
- tizen.application.launchAppControl(appControl, null,
- function() {console.log("launch service succeeded");},
- function(e) {
- console.log("launch service failed. Reason: " + e.name);});
- } else {
- alert("Please connect your application online in the settings"
- + " if you want to send an email");
- }
- }
-
- function sendMessage(){
- var message =
- "This is the position I want to show you from Mapo:" +
- "\nLatitute="+$("#lat").val()+
- "\nLongitude = "+$("#lon").val()+
- "\nIf you prefer in DMS, here it is: "+$('#dms').val()+
- "\nYou can see this position on OpenStreetMap: "+getLink('OSM')+
- "\nConnect you on Mapo for more details!";
- var appControl = new tizen.ApplicationControl(
- "http://tizen.org/appcontrol/operation/compose",
- "tel:9988776655",
- null,
- null,
- [
- new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/messagetype",["sms"]),
- new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/text",[message]),
- new tizen.ApplicationControlData("http://tizen.org/appcontrol/data/to", ["2345678900"]),
- ]
- );
- tizen.application.launchAppControl(appControl, null,
- function() {console.log("launch service succeeded");},
- function(e) {console.log("launch service failed. Reason: "+e);});
- }
- function call(){
- var appControl = new tizen.ApplicationControl("http://tizen.org/appcontrol/operation/dial","tel:9988776655", null);
- tizen.application.launchAppControl(appControl,null,
- function(){console.log("launch appControl succeeded");},
- function(e){console.log("launch appControl failed. Reason: " + e.name);},
- null);
- }
- function createContact() {
- var appControl = new tizen.ApplicationControl(
- "http://tizen.org/appcontrol/operation/social/add",
- null,
- null,
-
-
-
- "vnd.tizen.item.type/vnd.tizen.contact",
- [
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/social/item_type",
- [ "contact" ]),
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/social/email",
- [ "mapo.tizen+"+
- fromLatLonToDMS($('#lat').val(), $('#lon').val()) + "@gmail.com" ]),
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/social/url",
- [ getLink('OSM') ])
- ]);
- tizen.application.launchAppControl(appControl, null,
- function() {console.log("launch service succeeded");},
- function(e) {console.log(
- "launch service failed. Reason: " +e.name+e);});
- }
- function createCalendarEvent(){
- var appControl = new tizen.ApplicationControl(
- "http://tizen.org/appcontrol/operation/social/edit",
- null,
- null,
- "tizen.calendar",
- [
- new tizen.ApplicationControlData(
- "http://tizen.org/appcontrol/data/social/item_type",
- [ "event" ])
- ]);
- tizen.application.launchAppControl(appControl, null,
- function() {console.log("launch service succeeded");},
- function(e) {console.log(
- "launch service failed. Reason: " +e.name+e);});
- }
- function storeData(){
- localStorage.setItem('lat', $('#lat').val());
- localStorage.setItem('lon', $('#lon').val());
- localStorage.setItem('dms', $('#dms').val());
- }
- function storeSettings() {
- localStorage.setItem('connection', $('#switchOnline').val());
- localStorage.setItem('energySaving', $('#switchEnergy').val());
- localStorage.setItem('timeout', $('#selectorTimeout').val());
- }
- function store() {
- var r = $.Deferred();
- storeData();
- storeSettings();
- for ( var i = 0; i < localStorage.length; i++) {
- log(i+" -- "+localStorage.key(i)+" : "+localStorage.getItem(localStorage.key(i)));
- }
- r.resolve();
- return r;
- }
- function switchOnline() {
- if (!isOnline) {
- if (navigator.onLine) {
- isOnline = true;
- } else {
- $('#switchOnline').val('offline');
- $('#switchOnline').slider('refresh');
- alert("Can not connect");
- }
- } else {
- isOnline = false;
- }
- refresh();
- }
- function refresh() {
- log("{refresh");
- if (isOnline && !navigator.onLine) {
- $('#switchOnline').val('offline').slider('refresh');
- isOnline = false;
- alert("Connection lost");
- }
-
- $('#myMap').empty();
- log("isOnline = "+isOnline);
- if (isOnline) {
- setMapSize();
- chargeMap();
- } else {
- $('#myMap').html(
- "<p align='center'>" +
- "Please connect your application online in the settings" +
- " if you want to charge the map</p>");
- }
- log("refresh}");
- }
- function exit() {
- tizen.application.getCurrentApplication().exit();
- }
- function quit() {
- log("{exit")
- store().done(exit);
- log("exit}");
- }
- function initData(){
- if (localStorage.getItem('lat') != null) {
- $('#lat').val(localStorage.getItem('lat'));
- }
- if (localStorage.getItem('lon') != null) {
- $('#lon').val(localStorage.getItem('lon'));
- }
- if (localStorage.getItem('dms') != null) {
- $('#dms').val(localStorage.getItem('dms'));
- }
- storeData();
- }
- function initSettings() {
- if (localStorage.getItem('connection') == 'online') {
- $('#switchOnline').val(localStorage.getItem('connection'));
- isOnline = true;
- }
- if (localStorage.getItem('energySaving') != null) {
- $('#switchEnergy').val(localStorage.getItem('energySaving'));
- }
- if (localStorage.getItem('timeout') != null) {
- $('#selectorTimeout').attr('value', localStorage.getItem('timeout'));
- }
- storeSettings();
- }
- function init(){
- initData();
- initSettings();
- refresh();
- }
- function log(message) {
- if (!false) console.log("# "+message);
- }
- function swipePage() {
- $('div.ui-page').live("swipeleft",
- function() {
- var nextpage = $(this).next('div[data-role="page"]');
-
- if (nextpage.length > 0) {
- $.mobile.changePage(nextpage,
- {transition : "slide", reverse : false});
- }});
- $('div.ui-page').live("swiperight",
- function() {
- var prevpage = $(this).prev('div[data-role="page"]');
-
- if (prevpage.length > 0) {
- $.mobile.changePage(prevpage,
- {transition : "slide", reverse : true});
- }});
- }
|