diff --git a/www/index.html b/www/index.html index 2b09e84..27471b2 100644 --- a/www/index.html +++ b/www/index.html @@ -72,11 +72,8 @@ @@ -93,80 +90,16 @@ - - -
-

News

- + + Non è stato attalmente caricato alcun contenuto +

+
@@ -178,9 +111,24 @@

EVENTI

-

+

+
+ +
+
+

-

+

+
+
+

+ +

+
+
@@ -233,45 +181,7 @@
- -
@@ -363,7 +273,6 @@

-
diff --git a/www/js/events.js b/www/js/events.js index cc723cf..86a5c87 100644 --- a/www/js/events.js +++ b/www/js/events.js @@ -1,10 +1,10 @@ var ai1ec = (function(){ - var API = {}, json = null, events = []; + var API = {}, json = [], events = []; //Categorie di eventi API.cats = { single: 34, - repeat: 25 + repeat: 87 }; var getCleanId = function(uid){ @@ -57,20 +57,20 @@ var ai1ec = (function(){ }, }; - var getXmlData = function(url, callback) { + var getXmlData = function(url, catId, callback) { $.ajax({ url: url, dataType: 'xml', method: 'GET', success: function(res) { - json = $.xml2json(res); - events = json["#document"].vcalendar.vevent; - console.log(events); - return callback(events); + json[catId] = $.xml2json(res); + events[catId] = json[catId]["#document"].vcalendar.vevent; + console.log(events[catId]); + return callback(events[catId]); }, error: function(err){ console.log("Err: status ", err.status); - return callback(events); + return callback(events[catId]); } }); }; @@ -94,13 +94,13 @@ var ai1ec = (function(){ //Torna un array con tutti gli eventi organizzati da xm24, un array vuoto se errore. getAllEvents : function(catId, callback) { var url = getDefaultUrl(catId); - getXmlData(url, callback); + getXmlData(url, catId, callback); }, //Torna un array con gli eventi tra -30 e +30 giorni da oggi, un array vuoto se errore. getLastEvents : function(catId, callback) { var url = getDefaultUrl(catId) + '&' + API.remote.win; - getXmlData(url, callback); + getXmlData(url, catId, callback); }, } diff --git a/www/js/eventsCRUD.js b/www/js/eventsCRUD.js index 1606890..91697c4 100644 --- a/www/js/eventsCRUD.js +++ b/www/js/eventsCRUD.js @@ -29,8 +29,10 @@ EVENTS.render = function() { var ret = checkConnection('ERR_EVENT'); if (ret) { EVENTS.getDataAndLoad(ai1ec.cats.single); + EVENTS.getDataAndLoad(ai1ec.cats.repeat); } else { - EVENTS.loadFromDb('#mostralista', ai1ec.cats.single); + EVENTS.loadFromDb('#mostralista-'+ ai1ec.cats.single, ai1ec.cats.single); + EVENTS.loadFromDb('#mostralista-'+ ai1ec.cats.repeat, ai1ec.cats.repeat); } } @@ -65,7 +67,7 @@ EVENTS.getDataAndLoad = function (type) { console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected); if(n_evs_ins + n_evs_err == n_evs - 1) { if(n_evs_ins > 0) { - EVENTS.loadFromDb('#mostralista', type); + EVENTS.loadFromDb('#mostralista-'+ type, type); } } }, @@ -74,7 +76,7 @@ EVENTS.getDataAndLoad = function (type) { n_evs_err++; if(n_evs_ins + n_evs_err == n_evs - 1) { if(n_evs_ins > 0) { - EVENTS.loadFromDb('#mostralista', type); + EVENTS.loadFromDb('#mostralista-'+ type, type); } else { toastr.info("Non ci sono nuovi eventi."); $.mobile.loading('hide'); diff --git a/www/js/main.js b/www/js/main.js index bf02386..c01ea11 100644 --- a/www/js/main.js +++ b/www/js/main.js @@ -22,16 +22,20 @@ FONTE.dbName = "xm24"; FONTE.dbHandler; FONTE.tagsPageInitiated = false; FONTE.categoriesList = [8, 497]; +FONTE.categoriesILove = [497,647,590]; //ilove, 4mar, solid +FONTE.categoriesInfo = [8,42,68,3]; FONTE.updatedCategoriesCount; FONTE.updatedPostsCount; FONTE.neededPostsCount; FONTE.hrefseguente = ""; +FONTE.info_page_loaded = 0; +FONTE.ilove_page_loaded = 0; FONTE.ajaxError = false; /* * data ultimo aggiornamento */ -function ultimoAggiornamento() { +function displayLastUpdateDate() { var lastUpdate = window.localStorage.getItem('db_update_date'); if (lastUpdate) { var data = lastUpdate.split('T'); @@ -123,17 +127,13 @@ function benvenuta() { // $("#aggiornaora").popup("open"); //}; -function setFirstRun() { +function run() { initStorage(); overlayblock(); - if (window.localStorage.getItem('has_run') != 'true') { - //do some stuff if has not loaded before - overlayblock(); - benvenuta(); - if (checkConnection()) { - partialUpdate(); - //window.localStorage.setItem('has_run', 'true'); - } + if (checkConnection()) { + partialUpdate(); + } else { + } }; @@ -214,7 +214,7 @@ $(function () { function onDeviceReady() { // console.log('deviceready'); createDB(); - setFirstRun(); + run(); $("a.nav").on("click", function (event) { // Prevent the usual navigation behavior event.preventDefault(); @@ -354,16 +354,17 @@ function cercaMe() { } } -function checkloader() { - myJsonLastPage('#mostralistaultime'); - var mieultime = $("#mostralistaultime").html(); - // console.log("ultime" + mieultime); - if (mieultime == "Non ci sono nuovi contenuti.") { - //feedback +function checkloader(categories) { + var div = '#mostralistainfo'; + + displayLastUpdateDate(categories); + renderLastNews(div, categories); + + if ($(div).html() == "Non ci sono nuovi contenuti.") { $("#aggiorna").attr("src", "./image/aggiorna.png"); - ultimoAggiornamento(); + return true - //console.log("ultime2"); + //console.log("ultime2"); } // console.log("ultime3"); return false diff --git a/www/js/query.js b/www/js/query.js index f3a787b..30886aa 100644 --- a/www/js/query.js +++ b/www/js/query.js @@ -36,6 +36,96 @@ function myJsonCategory(Qcategory, div, addTagCategory) { $.mobile.loading('hide'); }; +function drawPostsList(div, resultSet, categories, fallback) { + var items = []; + $(div).empty(); + if (resultSet.rows.length > 0) { + for (var i = 0; i < resultSet.rows.length; i++) { + var val = JSON.parse(resultSet.rows.item(i).post); + var id = val.id; + var time = val.modified; + var title = val.title.rendered; + var url = val.guid.rendered; + // console.log(Url); + var splitTime = time.split("T"); + var cleanTime = splitTime[0]; + //key mi dice l'indice' + items.push("
  • " + title + "
    " + cleanTime + ""); + } + $("