Miglior gestione dell'errore no connessione. Fix errore social network.
This commit is contained in:
parent
2cabd00de7
commit
417cb283a4
3 changed files with 46 additions and 56 deletions
|
@ -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>
|
||||||
|
|
|
@ -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');
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
cercaMe();
|
cercaMe();
|
||||||
return true;
|
}
|
||||||
} else {
|
|
||||||
toastr.error('Err: ERR_CERCA');
|
return ret;
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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 ret;
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
|
@ -1,19 +1,20 @@
|
||||||
// this is the complete list of currently supported params you can pass to the plugin (all optional)
|
function shareMeNow(message, subject, url) {
|
||||||
var options = {
|
// this is the complete list of currently supported params you can pass to the plugin (all optional)
|
||||||
message: 'share this', // not supported on some apps (Facebook, Instagram)
|
var options = {
|
||||||
subject: 'the subject', // fi. for email
|
message: message || 'share this', // not supported on some apps (Facebook, Instagram)
|
||||||
files: ['', ''], // an array of filenames either locally or remotely
|
subject: subject || 'the subject', // fi. for email
|
||||||
url: 'https://www.website.com/foo/#bar?a=b',
|
//files: ['', ''], // an array of filenames either locally or remotely
|
||||||
chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
|
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);
|
|
Loading…
Reference in a new issue