|
@@ -5,11 +5,10 @@ function myJsonCategory(Qcategory, div, addTagCategory) {
|
|
|
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 date = val.date;
|
|
|
var title = val.title.rendered;
|
|
|
var url = val.guid.rendered;
|
|
|
- var splitTime = time.split("T");
|
|
|
- var cleanTime = splitTime[0];
|
|
|
+ var cleanTime = EVENTS.formatDate(date, EVENTS.dateFormat.display.date);
|
|
|
var tag = '';
|
|
|
var cattag = '';
|
|
|
/* if (addTagCategory) {
|
|
@@ -25,17 +24,43 @@ function myJsonCategory(Qcategory, div, addTagCategory) {
|
|
|
items.push("<li class='"+ cattag +"'><a href='#singleQpost' data-post='" + id + "'>" + title + "</a><br/><small>" + cleanTime + "</small><span>" + tag + "</span>|</li>");
|
|
|
}
|
|
|
else {*/
|
|
|
- items.push("<li><a href='#singleQpost' data-post='" + id + "'>" + title + "</a><br/><small>" + cleanTime + "</small></li>");
|
|
|
-
|
|
|
+ items.push(getLiPost(id, title, cleanTime));
|
|
|
}
|
|
|
$("<ul/>", {
|
|
|
"class": "my-new-list",
|
|
|
html: items.join("")
|
|
|
}).prependTo(div);
|
|
|
+ $.mobile.loading('hide');
|
|
|
});
|
|
|
- $.mobile.loading('hide');
|
|
|
}
|
|
|
|
|
|
+var getLiPostNotPresent = function(id, title, cleanTime, url, style){
|
|
|
+ //TODO:var onclick = " onclick='"+getWpPost()+ "' ";
|
|
|
+ var li = "<li>"+
|
|
|
+ "<a style='"+ style +"' href='" + url + "' rel='external'>" +
|
|
|
+ title +
|
|
|
+ "</a>"+
|
|
|
+ "<br/>"+
|
|
|
+ "<small>" + cleanTime + "</small>"+
|
|
|
+ "<hr class='post-divider'>"+
|
|
|
+ "</li>";
|
|
|
+
|
|
|
+ return li;
|
|
|
+};
|
|
|
+
|
|
|
+var getLiPost = function(id, title, cleanTime){
|
|
|
+ var li = "<li>"+
|
|
|
+ "<a href='#singleQpost' data-post='" + id + "'>" +
|
|
|
+ title +
|
|
|
+ "</a>"+
|
|
|
+ "<br/>"+
|
|
|
+ "<small>" + cleanTime + "</small>"+
|
|
|
+ "<hr class='post-divider'>"+
|
|
|
+ "</li>";
|
|
|
+
|
|
|
+ return li;
|
|
|
+};
|
|
|
+
|
|
|
var drawListPost = function(div, resultSet, position) {
|
|
|
var items = [];
|
|
|
for (var i = 0; i < resultSet.rows.length; i++) {
|
|
@@ -46,16 +71,7 @@ var drawListPost = function(div, resultSet, position) {
|
|
|
var url = val.guid.rendered;
|
|
|
var cleanTime = EVENTS.formatDate(date, EVENTS.dateFormat.display.date);
|
|
|
|
|
|
- var li = "<li>"+
|
|
|
- "<a href='#singleQpost' data-post='" + id + "'>" +
|
|
|
- title +
|
|
|
- "</a>"+
|
|
|
- "<br/>"+
|
|
|
- "<small>" + cleanTime + "</small>"+
|
|
|
- "<hr class='post-divider'>"+
|
|
|
- "</li>";
|
|
|
-
|
|
|
- items.push(li);
|
|
|
+ items.push(getLiPost(id, title, cleanTime));
|
|
|
}
|
|
|
|
|
|
var ul = $("<ul/>", {
|
|
@@ -102,6 +118,7 @@ function drawNoPostsFound(div) {
|
|
|
}
|
|
|
|
|
|
function sqlErrHandler(error){
|
|
|
+ $.mobile.loading('hide');
|
|
|
console.log(error.message);
|
|
|
}
|
|
|
|
|
@@ -128,6 +145,8 @@ POST.sql = {
|
|
|
end : "ORDER BY date COLLATE NOCASE DESC LIMIT ?"
|
|
|
};
|
|
|
|
|
|
+POST.table = "xm24_posts";
|
|
|
+
|
|
|
var selectLastNews = function(div, categories) {
|
|
|
var catsWhere = getCategoryWhere(categories);
|
|
|
|
|
@@ -235,6 +254,21 @@ function myJsonCategoryPaginated(Qcategory, div, pageNumber) {
|
|
|
$.mobile.loading('hide');
|
|
|
}
|
|
|
|
|
|
+var renderShareButton = function(div_content, title, url, content){
|
|
|
+ $('.share-btn').remove();
|
|
|
+
|
|
|
+ content = content || '';
|
|
|
+
|
|
|
+ var shareButton = $('<button>', {
|
|
|
+ class : "share-btn ui-btn ui-shadow ui-corner-all",
|
|
|
+ text: "Condividi"
|
|
|
+ }).click(function(){
|
|
|
+ shareMeNow(title, content, url);
|
|
|
+ });
|
|
|
+
|
|
|
+ $(div_content).after(shareButton);
|
|
|
+};
|
|
|
+
|
|
|
function drawPost(div_title, div_content, resultSet){
|
|
|
for (var i = 0; i < resultSet.rows.length; i++) {
|
|
|
var val = JSON.parse(resultSet.rows.item(i).post);
|
|
@@ -247,17 +281,8 @@ function drawPost(div_title, div_content, resultSet){
|
|
|
content = findImg(content);
|
|
|
|
|
|
$(div_title).html(title);
|
|
|
-
|
|
|
- var shareButton = $('<button>', {
|
|
|
- class : "share-btn ui-btn ui-shadow ui-corner-all",
|
|
|
- text: "Condividi"
|
|
|
- }).click(function(){
|
|
|
- shareMeNow(title, '',url);
|
|
|
- });
|
|
|
-
|
|
|
- $('.share-btn').remove();
|
|
|
$(div_content).html("<p>" + content + "</p>");
|
|
|
- $(div_content).after(shareButton);
|
|
|
+ renderShareButton(div_content, title, url, '');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -274,22 +299,13 @@ function drawEvent(div_title, div_content, resultSet){
|
|
|
var geo = val.geo;
|
|
|
|
|
|
$(div_title).html(title);
|
|
|
-
|
|
|
- var shareButton = $('<button>', {
|
|
|
- class : "share-btn ui-btn ui-shadow ui-corner-all",
|
|
|
- text: "Condividi"
|
|
|
- }).click(function(){
|
|
|
- shareMeNow(title, evInitDate + " "+ evEndDate, url);
|
|
|
- });
|
|
|
-
|
|
|
- $('.share-btn').remove();
|
|
|
$(div_content).html("<small>" + evInitDate +"-" + evEndDate +"</small><p>" + content + "</p>");
|
|
|
- $(div_content).after(shareButton);
|
|
|
+ renderShareButton(div_content, title, url, evInitDate + " "+ evEndDate);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function myJsonPost(Qid, div_title, div_content, _class) {
|
|
|
- var table = "xm24_posts";
|
|
|
+ var table = POST.table;
|
|
|
if(_class){
|
|
|
table = EVENTS.table.single;
|
|
|
}
|
|
@@ -300,9 +316,7 @@ function myJsonPost(Qid, div_title, div_content, _class) {
|
|
|
} else {
|
|
|
drawEvent(div_title, div_content, resultSet);
|
|
|
}
|
|
|
- }, function (error) {
|
|
|
- console.log(error);
|
|
|
- });
|
|
|
+ }, sqlErrHandler);
|
|
|
}
|
|
|
|
|
|
function myJsonPage(Qid, div_title, div_content) {
|
|
@@ -317,7 +331,6 @@ function myJsonPage(Qid, div_title, div_content) {
|
|
|
var content = data.page;
|
|
|
content = findImg(content);
|
|
|
$(div_title).html(title);
|
|
|
- //key mi dice l'indice'
|
|
|
$(div_content).html("<p>" + content + "</p>");
|
|
|
}
|
|
|
});
|