Fix Loader senza rete #36
This commit is contained in:
parent
6c5e85cef1
commit
2bd4ed9e17
3 changed files with 17 additions and 14 deletions
|
@ -1,6 +1,5 @@
|
||||||
function myJsonCategory(Qcategory, div, addTagCategory) {
|
function myJsonCategory(Qcategory, div, addTagCategory) {
|
||||||
$.mobile.loading('show');
|
FONTE.dbHandler.executeSql("SELECT DISTINCT * FROM xm24_posts WHERE category = ? ORDER BY date COLLATE NOCASE DESC;", [Qcategory], function (resultSet) {
|
||||||
FONTE.dbHandler.executeSql("SELECT * FROM xm24_posts WHERE category = ? ORDER BY date COLLATE NOCASE DESC;", [Qcategory], function (resultSet) {
|
|
||||||
var items = [];
|
var items = [];
|
||||||
for (var i = 0; i < resultSet.rows.length; i++) {
|
for (var i = 0; i < resultSet.rows.length; i++) {
|
||||||
var val = JSON.parse(resultSet.rows.item(i).post);
|
var val = JSON.parse(resultSet.rows.item(i).post);
|
||||||
|
@ -83,7 +82,10 @@ var drawListPost = function(div, resultSet, position) {
|
||||||
} else if(position == 'prepend'){
|
} else if(position == 'prepend'){
|
||||||
ul.prependTo(div);
|
ul.prependTo(div);
|
||||||
}
|
}
|
||||||
$.mobile.loading('hide');
|
|
||||||
|
setTimeout(function () {
|
||||||
|
$.mobile.loading('hide');
|
||||||
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
var appendPostList = function(div, resultSet, categories, fallback) {
|
var appendPostList = function(div, resultSet, categories, fallback) {
|
||||||
|
@ -144,7 +146,7 @@ var getCategoryWhere = function(categories) {
|
||||||
|
|
||||||
var POST = POST || {};
|
var POST = POST || {};
|
||||||
POST.sql = {
|
POST.sql = {
|
||||||
init: "SELECT * FROM xm24_posts JOIN xm24_cats_to_posts USING(id) WHERE ",
|
init: "SELECT DISTINCT * FROM xm24_posts JOIN xm24_cats_to_posts USING(id) WHERE ",
|
||||||
end : "ORDER BY date COLLATE NOCASE DESC LIMIT ?"
|
end : "ORDER BY date COLLATE NOCASE DESC LIMIT ?"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,7 +197,7 @@ function myJsonLastPage(div) {
|
||||||
var firstTime = storage.getItem('db_lastnews_firsttime');
|
var firstTime = storage.getItem('db_lastnews_firsttime');
|
||||||
if (firstTime != 'yes') {
|
if (firstTime != 'yes') {
|
||||||
if (lastnewsDate) {
|
if (lastnewsDate) {
|
||||||
FONTE.dbHandler.executeSql("SELECT * FROM xm24_posts WHERE date > ? ORDER BY date COLLATE NOCASE DESC LIMIT 40;", [lastnewsDate], function (resultSet) {
|
FONTE.dbHandler.executeSql("SELECT DISTINCT * FROM xm24_posts WHERE date > ? ORDER BY date COLLATE NOCASE DESC LIMIT 40;", [lastnewsDate], function (resultSet) {
|
||||||
var items = [];
|
var items = [];
|
||||||
$(div).empty();
|
$(div).empty();
|
||||||
if (resultSet.rows.length > 0) {
|
if (resultSet.rows.length > 0) {
|
||||||
|
@ -232,7 +234,7 @@ function myJsonLastPage(div) {
|
||||||
|
|
||||||
function myJsonCategoryPaginated(Qcategory, div, pageNumber) {
|
function myJsonCategoryPaginated(Qcategory, div, pageNumber) {
|
||||||
$.mobile.loading('show');
|
$.mobile.loading('show');
|
||||||
FONTE.dbHandler.executeSql("SELECT * FROM xm24_posts WHERE category = ? ORDER BY date COLLATE NOCASE DESC;", [Qcategory], function (resultSet) {
|
FONTE.dbHandler.executeSql("SELECT DISTINCT * FROM xm24_posts WHERE category = ? ORDER BY date COLLATE NOCASE DESC;", [Qcategory], function (resultSet) {
|
||||||
var items = [];
|
var items = [];
|
||||||
$(div).empty();
|
$(div).empty();
|
||||||
for (var i = 0; i < resultSet.rows.length; i++) {
|
for (var i = 0; i < resultSet.rows.length; i++) {
|
||||||
|
@ -313,7 +315,7 @@ function myJsonPost(Qid, div_title, div_content, _class) {
|
||||||
table = EVENTS.table.single;
|
table = EVENTS.table.single;
|
||||||
}
|
}
|
||||||
|
|
||||||
FONTE.dbHandler.executeSql("SELECT * FROM " + table + " WHERE id = ?;", [Qid], function(resultSet) {
|
FONTE.dbHandler.executeSql("SELECT DISTINCT * FROM " + table + " WHERE id = ?;", [Qid], function(resultSet) {
|
||||||
if(!_class){
|
if(!_class){
|
||||||
drawPost(div_title, div_content, resultSet);
|
drawPost(div_title, div_content, resultSet);
|
||||||
} else {
|
} else {
|
||||||
|
@ -325,7 +327,7 @@ function myJsonPost(Qid, div_title, div_content, _class) {
|
||||||
function myJsonPage(Qid, div_title, div_content) {
|
function myJsonPage(Qid, div_title, div_content) {
|
||||||
$.mobile.loading('show');
|
$.mobile.loading('show');
|
||||||
var pageId = parseInt(Qid);
|
var pageId = parseInt(Qid);
|
||||||
FONTE.dbHandler.executeSql("SELECT * FROM xm24_pages WHERE id = ?;", [pageId], function (resultSet) {
|
FONTE.dbHandler.executeSql("SELECT DISTINCT * FROM xm24_pages WHERE id = ?;", [pageId], function (resultSet) {
|
||||||
for (var i = 0; i < resultSet.rows.length; i++) {
|
for (var i = 0; i < resultSet.rows.length; i++) {
|
||||||
var data = resultSet.rows.item(i);
|
var data = resultSet.rows.item(i);
|
||||||
var id = data.id;
|
var id = data.id;
|
||||||
|
@ -342,7 +344,7 @@ function myJsonPage(Qid, div_title, div_content) {
|
||||||
|
|
||||||
function myJsonRandomPost(div_title, div_content) {
|
function myJsonRandomPost(div_title, div_content) {
|
||||||
$.mobile.loading('show');
|
$.mobile.loading('show');
|
||||||
FONTE.dbHandler.executeSql("SELECT * FROM xm24_posts ORDER BY RANDOM() LIMIT 1;", [], function (resultSet) {
|
FONTE.dbHandler.executeSql("SELECT DISTINCT * FROM xm24_posts ORDER BY RANDOM() LIMIT 1;", [], function (resultSet) {
|
||||||
for (var i = 0; i < resultSet.rows.length; i++) {
|
for (var i = 0; i < resultSet.rows.length; i++) {
|
||||||
var val = JSON.parse(resultSet.rows.item(i).post);
|
var val = JSON.parse(resultSet.rows.item(i).post);
|
||||||
var id = val.id;
|
var id = val.id;
|
||||||
|
|
|
@ -245,9 +245,9 @@ function getLastSinglePageRecur(url, pagenum, categories) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.length == 0) {
|
// if (data.length === 0) {
|
||||||
renderLastNews(FONTE.contentListClass, categories);
|
// renderLastNews(FONTE.contentListClass, categories);
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
error: JSONErrorHandler
|
error: JSONErrorHandler
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ function initStorage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*per network info*/
|
/*per network info*/
|
||||||
function checkConnection(code, msgConnect) {
|
function checkConnection(code, msgConnect, print) {
|
||||||
var msgTitle = "Non sei connesso";
|
var msgTitle = "Non sei connesso";
|
||||||
msgConnect = msgConnect || "Occore essere connessi per poter ricevere i nuovi articoli";
|
msgConnect = msgConnect || "Occore essere connessi per poter ricevere i nuovi articoli";
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@ function checkConnection(code, msgConnect) {
|
||||||
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') {
|
||||||
toastr.warning(msgConnect, msgTitle);
|
if(! print)
|
||||||
|
toastr.warning(msgConnect, msgTitle);
|
||||||
console.log(code);
|
console.log(code);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue