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>
//funzione carica pagina
</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>
<!-- chiude body-->
</div>

View file

@ -156,7 +156,10 @@ function overlayblock() {
$(".overlaynero").toggleClass("hide");
}
/*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 states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
@ -168,7 +171,8 @@ function checkConnection() {
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = '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
} else {
return true
@ -227,8 +231,6 @@ function postInListTag(div) {
});
};
function initTag(div) {
$.mobile.loading('show');
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() {
if (checkConnection()) {
var ret = checkConnection('ERR_CERCA');
if (ret) {
cercaMe();
return true;
} else {
toastr.error('Err: ERR_CERCA');
return false;
}
}
return ret;
};
function segnalaBug() {
if (checkConnection())
return true;
else {
toastr.error('Err: ERR_SEGNALA');
return false;
}
return checkConnection('ERR_SEGNALA');
};
function mostraEsperto() {
if (checkConnection()) {
var ret = checkConnection('ERR_ESPERTO');
if (ret) {
myJsonPage(2167, '#espertotitle', '#mostraesperto');
return true;
} else {
toastr.error('Err: ERR_ESPERTO');
return false;
}
return ret;
};
function checkAndUpdate() {
if (checkConnection()) {
var ret = checkConnection('ERR_ESPERTO');
if (ret) {
update();
return true;
} else {
toastr.error('Err: ERR_UPDATE');
return false;
}
return ret;
};
function checkAndReset() {
if (checkConnection()) {
var ret = checkConnection('ERR_ESPERTO');
if (ret) {
resetAndUpdate();
return true;
} else {
toastr.error('Err: ERR_RESET');
return false;
}
}
return ret;
};

View file

@ -1,19 +1,20 @@
// this is the complete list of currently supported params you can pass to the plugin (all optional)
var options = {
message: 'share this', // not supported on some apps (Facebook, Instagram)
subject: 'the subject', // fi. for email
files: ['', ''], // an array of filenames either locally or remotely
url: 'https://www.website.com/foo/#bar?a=b',
chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
function shareMeNow(message, subject, url) {
// this is the complete list of currently supported params you can pass to the plugin (all optional)
var options = {
message: message || 'share this', // not supported on some apps (Facebook, Instagram)
subject: subject || 'the subject', // fi. for email
//files: ['', ''], // an array of filenames either locally or remotely
url: url || 'https://www.website.com/foo/#bar?a=b',
}
var onSuccess = function(result) {
console.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
console.log("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
}
var onError = function(msg) {
console.log("Sharing failed with message: " + msg);
}
window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
}
var onSuccess = function(result) {
console.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
console.log("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
}
var onError = function(msg) {
console.log("Sharing failed with message: " + msg);
}
window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);