72 lines
3.3 KiB
JavaScript
72 lines
3.3 KiB
JavaScript
var EVENTS = EVENTS || {};
|
|
|
|
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) {
|
|
console.log('resultSet.insertId: ' + resultSet.insertId);
|
|
console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected);
|
|
|
|
$.mobile.loading('hide');
|
|
}, function (error) {
|
|
console.error("EVENTS.query() : ", error);
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
EVENTS.queryRepeat = 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_repeat', [], function() {
|
|
FONTE.dbHandler.executeSql('INSERT INTO xm24_events_repeat VALUES (?,?,?,?,?,?,?)', [evId, evTitle, evDesc, evInitDate, evEndDate, evUrl, evGeo], function (resultSet) {
|
|
console.log('resultSet.insertId: ' + resultSet.insertId);
|
|
console.log('resultSet.rowsAffected: ' + resultSet.rowsAffected);
|
|
|
|
$.mobile.loading('hide');
|
|
}, function (error) {
|
|
console.error("EVENTS.query() : ", error);
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
EVENTS.loadFromDb = function (containerId) {
|
|
$.mobile.loading('show');
|
|
FONTE.dbHandler.executeSql("SELECT * FROM xm24_events_single 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>");
|
|
}
|
|
$(containerId).empty();
|
|
$("<ul/>", {
|
|
"class": "my-new-list"
|
|
, html: items.join("")
|
|
}).prependTo(containerId);
|
|
$.mobile.loading('hide');
|
|
}, function (error) {
|
|
console.log(error);
|
|
});
|
|
};
|