/* scriversi le cose nel local storage*/ function initStorage() { try { return 'localStorage' in window && window.localStorage !== null; } catch (e) { return false; } } /*per network info*/ function checkConnection(code, msgConnect) { var msgTitle = "Non sei connesso"; msgConnect = msgConnect || "Occore essere connessi per poter ricevere i nuovi articoli"; var networkState = navigator.connection.type; var states = {}; states[Connection.UNKNOWN] = 'Unknown connection'; states[Connection.ETHERNET] = 'Ethernet connection'; states[Connection.WIFI] = 'WiFi connection'; states[Connection.CELL_2G] = 'Cell 2G connection'; states[Connection.CELL_3G] = 'Cell 3G connection'; states[Connection.CELL_4G] = 'Cell 4G connection'; states[Connection.CELL] = 'Cell generic connection'; states[Connection.NONE] = 'No network connection'; if (states[networkState] == 'Unknown connection' || states[networkState] == 'No network connection') { toastr.warning(msgConnect, msgTitle); console.log(code); return false; } else { return true; } } var getObjKey = function(obj, val) { var key = null; for(var k in obj){ if(obj[k] == val){ key = k; break; } } return key; };