Fix visualizzazione eventi single
This commit is contained in:
parent
8a17f75182
commit
5fe0b14d40
3 changed files with 79 additions and 28 deletions
|
@ -35,15 +35,16 @@
|
|||
<script type="text/javascript" src="js/vendor/jquery-1.10.2.min.js"></script>
|
||||
|
||||
<!--script src="js/swipe-page.js"></script-->
|
||||
<script src="js/main.js"></script>
|
||||
<script src="js/update.js"></script>
|
||||
<script src="js/query.js"></script>
|
||||
<script src="js/eventsCRUD.js"></script>
|
||||
<script type="text/javascript" src="js/main.js"></script>
|
||||
<script type="text/javascript" src="js/update.js"></script>
|
||||
<script type="text/javascript" src="js/query.js"></script>
|
||||
<script type="text/javascript" src="js/eventsCRUD.js"></script>
|
||||
|
||||
<script src="js/vendor/jquery.mobile-1.4.5.min.js"></script>
|
||||
<script src="js/vendor/xml2json.js"></script>
|
||||
<script src="js/vendor/toastr.js"></script>
|
||||
<script src="js/events.js"></script>
|
||||
<script type="text/javascript" src="js/vendor/jquery.mobile-1.4.5.min.js"></script>
|
||||
<script type="text/javascript" src="js/vendor/xml2json.js"></script>
|
||||
<script type="text/javascript" src="js/vendor/toastr.js"></script>
|
||||
<script type="text/javascript" src="js/vendor/moment-with-locales.min.js"></script>
|
||||
<script type="text/javascript" src="js/events.js"></script>
|
||||
|
||||
<script type="text/javascript" src="cordova.js"></script>
|
||||
<script type="text/javascript" src="js/push.js"></script>
|
||||
|
@ -180,7 +181,7 @@
|
|||
<div class="ui-body">
|
||||
<p class="introlettera">EVENTI</p>
|
||||
<p id="mostralista" class="listatovirgole listevoci">
|
||||
<img class="gifloader" src="./image/ajax_loader_red_512.gif" />
|
||||
|
||||
</p>
|
||||
</div>
|
||||
<!-- chiude body-->
|
||||
|
|
|
@ -1,27 +1,61 @@
|
|||
var EVENTS = EVENTS || {};
|
||||
//var date = moment();
|
||||
|
||||
EVENTS.render = function() {
|
||||
var ret = checkConnection('ERR_EVENT');
|
||||
if (ret) {
|
||||
EVENTS.querySingle();
|
||||
} else {
|
||||
EVENTS.loadFromDb('#mostralista', ai1ec.cats.single);
|
||||
}
|
||||
}
|
||||
|
||||
EVENTS.querySingle = function () {
|
||||
$.mobile.loading('show');
|
||||
ai1ec.remote.getLastEvents(ai1ec.cats.single, function(events) {
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var event = events[i];
|
||||
var evId = ai1ec.event.getId(event);
|
||||
var evTitle = ai1ec.event.getTitle(event);
|
||||
var evDesc = ai1ec.event.getDescription(event);
|
||||
var evInitDate = ai1ec.event.getInitDate(event);
|
||||
var evEndDate = ai1ec.event.getEndDate(event);
|
||||
var evUrl = ai1ec.event.getUrl(event);
|
||||
var evGeo = ai1ec.event.getGeo(event);
|
||||
FONTE.dbHandler.executeSql('TRUNCATE TABLE xm24_events_single', [], function() {
|
||||
FONTE.dbHandler.executeSql('INSERT INTO xm24_events_single VALUES (?,?,?,?,?,?,?)', [evId, evTitle, evDesc, evInitDate, evEndDate, evUrl, evGeo], function (resultSet) {
|
||||
var n_evs = events.length,
|
||||
n_evs_ins = 0,
|
||||
n_evs_err = 0;
|
||||
|
||||
if(n_evs > 0) {
|
||||
FONTE.dbHandler.executeSql('DELETE FROM xm24_events_single', [], function() {
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
var event = events[i];
|
||||
var evId = ai1ec.event.getId(event);
|
||||
var evTitle = ai1ec.event.getTitle(event);
|
||||
var evDesc = ai1ec.event.getDescription(event);
|
||||
var evInitDate = ai1ec.event.getInitDate(event);
|
||||
var evEndDate = ai1ec.event.getEndDate(event);
|
||||
var evUrl = ai1ec.event.getUrl(event);
|
||||
var evGeo = ai1ec.event.getGeo(event);
|
||||
|
||||
FONTE.dbHandler.executeSql('INSERT INTO xm24_events_single VALUES (?,?,?,?,?,?,?)', [evId, evTitle, evDesc, evInitDate, evEndDate, evUrl, evGeo], function (resultSet) {
|
||||
n_evs_ins++;
|
||||
console.log('resultSet.insertId: ' + resultSet.insertId);
|
||||
console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected);
|
||||
|
||||
$.mobile.loading('hide');
|
||||
if(n_evs_ins + n_evs_err == n_evs - 1) {
|
||||
if(n_evs_ins > 0) {
|
||||
EVENTS.loadFromDb('#mostralista', ai1ec.cats.single);
|
||||
}
|
||||
}
|
||||
}, function (error) {
|
||||
n_evs_err++;
|
||||
if(n_evs_ins + n_evs_err == n_evs - 1) {
|
||||
if(n_evs_ins > 0) {
|
||||
EVENTS.loadFromDb('#mostralista', ai1ec.cats.single);
|
||||
} else {
|
||||
toastr.info("Non ci sono nuovi eventi.");
|
||||
$.mobile.loading('hide');
|
||||
}
|
||||
}
|
||||
console.error("EVENTS.query() : ", error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}, function(error){
|
||||
toastr.error("Err: errore nel TRUNCATE della tabella degli eventi single");
|
||||
});
|
||||
} else {
|
||||
toastr.info("Non ci sono nuovi eventi.");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -52,13 +86,27 @@ EVENTS.queryRepeat = function () {
|
|||
});
|
||||
};
|
||||
|
||||
EVENTS.loadFromDb = function (containerId) {
|
||||
$.mobile.loading('show');
|
||||
FONTE.dbHandler.executeSql("SELECT * FROM xm24_events_single ORDER BY initDate COLLATE NOCASE ASC;", [], function (resultSet) {
|
||||
EVENTS.loadFromDb = function (containerId, type) {
|
||||
var table = type == ai1ec.cats.single ? 'xm24_events_single' : 'xm24_events_repeat';
|
||||
FONTE.dbHandler.executeSql("SELECT * FROM " + table + " ORDER BY initDate COLLATE NOCASE ASC;", [], function (resultSet) {
|
||||
var items = [];
|
||||
for (var i = 0; i < resultSet.rows.length; i++) {
|
||||
var item = resultSet.rows.item(i);
|
||||
items.push("<li><img src='./image/virgolette_1.png' class='epuntato'/><a href='#event' data-post='" + item.id + "' >" + item.title + "</a><br/></li>");
|
||||
|
||||
var period = "Da: " + item.initDate;
|
||||
if(item.endDate) {
|
||||
period += " A: " + item.endDate;
|
||||
}
|
||||
|
||||
var li = "<li>" +
|
||||
//"<img src='./image/virgolette_1.png' class='epuntato'/>" +
|
||||
"<a href='#event' data-post='" + item.id + "' >"
|
||||
+ item.title +
|
||||
"</a>" +
|
||||
"<br/>" +
|
||||
period +
|
||||
"</li>";
|
||||
items.push(li);
|
||||
}
|
||||
$(containerId).empty();
|
||||
$("<ul/>", {
|
||||
|
@ -67,6 +115,8 @@ EVENTS.loadFromDb = function (containerId) {
|
|||
}).prependTo(containerId);
|
||||
$.mobile.loading('hide');
|
||||
}, function (error) {
|
||||
$.mobile.loading('hide');
|
||||
toastr.error("Err: nel caricamento dei dati dal db");
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -71,7 +71,7 @@ function alterContent(url) {
|
|||
case '#events':
|
||||
$("#navheader").removeClass("hide");
|
||||
$("#navfooter").removeClass("hide");
|
||||
EVENTS.loadFromDb('#mostralista');
|
||||
EVENTS.render();
|
||||
// ai1ec.remote.getAllEvents(ai1ec.cats.single);
|
||||
// ai1ec.remote.getLastEvents(ai1ec.cats.single);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue