Miglior gestione dell'errore no connessione. Fix errore social network.

This commit is contained in:
gine 2017-03-18 13:48:23 +01:00
parent 2cabd00de7
commit 417cb283a4
3 changed files with 46 additions and 56 deletions

View file

@ -335,7 +335,7 @@
<script> <script>
//funzione carica pagina //funzione carica pagina
</script> </script>
<button onclick="window.plugins.socialsharing.share('Message only')">message only</button> <button onclick="shareMeNow('ciao', 'testo', 'http://www.enc.org/xm24')">Text Share</button>
</div> </div>
<!-- chiude body--> <!-- chiude body-->
</div> </div>

View file

@ -156,7 +156,10 @@ function overlayblock() {
$(".overlaynero").toggleClass("hide"); $(".overlaynero").toggleClass("hide");
} }
/*per network info*/ /*per network info*/
function checkConnection() { 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 networkState = navigator.connection.type;
var states = {}; var states = {};
states[Connection.UNKNOWN] = 'Unknown connection'; states[Connection.UNKNOWN] = 'Unknown connection';
@ -168,7 +171,8 @@ function checkConnection() {
states[Connection.CELL] = 'Cell generic connection'; states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection'; states[Connection.NONE] = 'No network connection';
if (states[networkState] == 'Unknown connection' || states[networkState] == 'No network connection') { if (states[networkState] == 'Unknown connection' || states[networkState] == 'No network connection') {
//alert('Non sei connesso ad internet, connettiti ad una rete per procedere.'); toastr.warning(msgConnect, msgTitle);
console.log(code);
return false return false
} else { } else {
return true return true
@ -227,8 +231,6 @@ function postInListTag(div) {
}); });
}; };
function initTag(div) { function initTag(div) {
$.mobile.loading('show'); $.mobile.loading('show');
FONTE.dbHandler.executeSql("SELECT * FROM xm24_tags ORDER BY date COLLATE NOCASE DESC;", [], function (resultSet) { FONTE.dbHandler.executeSql("SELECT * FROM xm24_tags ORDER BY date COLLATE NOCASE DESC;", [], function (resultSet) {
@ -792,55 +794,42 @@ function JSONErrorHandler(jqXHR, textStatus, errorThrown) {
}; };
function cerca() { function cerca() {
if (checkConnection()) { var ret = checkConnection('ERR_CERCA');
cercaMe();
return true;
} else {
toastr.error('Err: ERR_CERCA');
return false; if (ret) {
cercaMe();
} }
return ret;
}; };
function segnalaBug() { function segnalaBug() {
if (checkConnection()) return checkConnection('ERR_SEGNALA');
return true;
else {
toastr.error('Err: ERR_SEGNALA');
return false;
}
}; };
function mostraEsperto() { function mostraEsperto() {
if (checkConnection()) { var ret = checkConnection('ERR_ESPERTO');
if (ret) {
myJsonPage(2167, '#espertotitle', '#mostraesperto'); myJsonPage(2167, '#espertotitle', '#mostraesperto');
return true;
} else {
toastr.error('Err: ERR_ESPERTO');
return false;
} }
return ret;
}; };
function checkAndUpdate() { function checkAndUpdate() {
if (checkConnection()) { var ret = checkConnection('ERR_ESPERTO');
if (ret) {
update(); update();
return true;
} else {
toastr.error('Err: ERR_UPDATE');
return false;
} }
return ret;
}; };
function checkAndReset() { function checkAndReset() {
if (checkConnection()) { var ret = checkConnection('ERR_ESPERTO');
if (ret) {
resetAndUpdate(); resetAndUpdate();
return true;
} else {
toastr.error('Err: ERR_RESET');
return false;
} }
return ret;
}; };

View file

@ -1,10 +1,10 @@
function shareMeNow(message, subject, url) {
// this is the complete list of currently supported params you can pass to the plugin (all optional) // this is the complete list of currently supported params you can pass to the plugin (all optional)
var options = { var options = {
message: 'share this', // not supported on some apps (Facebook, Instagram) message: message || 'share this', // not supported on some apps (Facebook, Instagram)
subject: 'the subject', // fi. for email subject: subject || 'the subject', // fi. for email
files: ['', ''], // an array of filenames either locally or remotely //files: ['', ''], // an array of filenames either locally or remotely
url: 'https://www.website.com/foo/#bar?a=b', url: url || 'https://www.website.com/foo/#bar?a=b',
chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
} }
var onSuccess = function(result) { var onSuccess = function(result) {
@ -17,3 +17,4 @@ var onError = function(msg) {
} }
window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError); window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
}