Completata pagina eventi ripetitivi tab oggi e data

This commit is contained in:
gine 2017-04-09 03:36:57 +02:00
parent c597a21d24
commit 135c796e7d
4 changed files with 154 additions and 63 deletions

View file

@ -702,13 +702,19 @@ img.minilogo {
float: right; float: right;
} }
/*.introlettera OLD {
display:inline-block; #today li .e_title,
padding:0 2em; #mydate li .e_title {
margin-top:0px; font-size: 0.7em;
text-align:left; line-height: 2.8;
font-family: 'bebas_neuebold'; }
} */ #today .title,
#mydate .title {
text-transform: initial;
font-size: 1.2em;
color: #000;
}
.introlettera { .introlettera {
display: inline-block; display: inline-block;
margin-top: 0px; margin-top: 0px;

View file

@ -36,7 +36,7 @@
<script type="text/javascript" src="js/vendor/jquery.mobile-1.4.5.min.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/xml2json.js"></script>
<script type="text/javascript" src="js/vendor/toastr.js"></script> <script type="text/javascript" src="js/vendor/toastr.js"></script>
<script type="text/javascript" src="js/vendor/moment.min.js"></script> <script type="text/javascript" src="js/vendor/moment-with-locales.min.js"></script>
<!--script src="js/swipe-page.js"></script--> <!--script src="js/swipe-page.js"></script-->
<script type="text/javascript" src="js/main.js"></script> <script type="text/javascript" src="js/main.js"></script>
@ -132,25 +132,10 @@
<div data-role="page" id="events" data-prev="index" data-next="" data-dom-cache="true" data-theme="a" class="ui-page"> <div data-role="page" id="events" data-prev="index" data-next="" data-dom-cache="true" data-theme="a" class="ui-page">
<div role="main" class="ui-content"> <div role="main" class="ui-content">
<div class="ui-body"> <div class="ui-body">
<p class="introlettera">EVENTI</p> <p class="introlettera">Eventi</p>
<div data-role="tabs"> <p id="mostralista-34" class="listatovirgole listevoci">
<div data-role="navbar"> <i>Non sono stati attualmente caricati eventi.</i>
<ul> </p>
<li><a href="#single" data-theme="a">Iniziative</a></li>
<li><a href="#repeat" data-theme="a">Fissi</a></li>
</ul>
</div>
<div id="single" >
<p id="mostralista-34" class="listatovirgole listevoci">
<i>Non sono stati attualmente caricati eventi.</i>
</p>
</div>
<div id="repeat" >
<p id="mostralista-87" class="listatovirgole listevoci">
<i>Non sono stati attualmente caricati eventi.</i>
</p>
</div>
</div>
</div> </div>
</div> </div>
</div><!--chiude content --> </div><!--chiude content -->

View file

@ -153,7 +153,6 @@ $(function () {
}); });
function initMainPage() { function initMainPage() {
$.mobile.loading('show');
if (checkConnection()) { if (checkConnection()) {
postsUpdate(FONTE.categories.info); postsUpdate(FONTE.categories.info);
} else { } else {
@ -241,7 +240,9 @@ Site.prototype.init = function () {
}; };
function onDeviceReady() { function onDeviceReady() {
// console.log('deviceready'); //Setto il locale delle plugin delle date
moment.locale('it');
createDB(); createDB();
initStorage(); initStorage();

View file

@ -6,8 +6,8 @@ PROJECT.labs = [
dlong: "...", dlong: "...",
when : [ when : [
{day: "Mar", hour: ["19:00", "22:00"], title: "Assemblea Ciclofficina" }, {day: "Mar", hour: ["19:00", "22:00"], title: "Assemblea Ciclofficina" },
{day: "Mer", hour: ["18:00", "22:00"], title: "Riparazioni collettive biciclette" }, {day: "Mer", hour: ["18:00", "22:00"], title: "Riparazioni biciclette" },
{day: "Dom", hour: ["18:00", "22:00"], title: "Riparazioni collettive biciclette" } {day: "Dom", hour: ["18:00", "22:00"], title: "Riparazioni biciclette" }
], ],
old_event: "", //un vecchio evento old_event: "", //un vecchio evento
site: "http://ampioraggio.noblogs.org", //sito personale site: "http://ampioraggio.noblogs.org", //sito personale
@ -83,7 +83,7 @@ PROJECT.labs = [
"opposta alle logiche della produzione industriale massiva e omologante.", "opposta alle logiche della produzione industriale massiva e omologante.",
when : [ when : [
{day: "Mar", hour: ["18:30", "20:30"], title:"Hata Yoga"}, {day: "Mar", hour: ["18:30", "20:30"], title:"Hata Yoga"},
{day: "Mer", hour: ["20:30", "22:30"], title:"Hata Yoga (ver. sperimentale/meditativa)"}, {day: "Mer", hour: ["20:30", "22:30"], title:"Hata Yoga meditativa)"},
{day: "Gio", hour: ["18:30", "21:00"], title:"Hata Yoga"}, {day: "Gio", hour: ["18:30", "21:00"], title:"Hata Yoga"},
{day: "Lun", hour: ["19:00", "21:00"], title:"Tessuti aerei"}, {day: "Lun", hour: ["19:00", "21:00"], title:"Tessuti aerei"},
{day: "Mer", hour: ["19:00", "21:00"], title:"Tessuti aerei"}, {day: "Mer", hour: ["19:00", "21:00"], title:"Tessuti aerei"},
@ -137,7 +137,7 @@ PROJECT.labs = [
"Questo progetto per noi è il punto di partenza per la costruzione di"+ "Questo progetto per noi è il punto di partenza per la costruzione di"+
" una alternativa al sistema economico dominante.", " una alternativa al sistema economico dominante.",
when : [ when : [
{day: "Giov", hour: ["16.30", "21:00"], title:"Mercatino Biologico"}, {day: "Gio", hour: ["16.30", "21:00"], title:"Mercatino Biologico"},
], ],
old_event: "", //un vecchio evento old_event: "", //un vecchio evento
site: "http://www.campiaperti.org/", //sito personale site: "http://www.campiaperti.org/", //sito personale
@ -201,10 +201,45 @@ PROJECT.labs = [
} }
]; ];
var sortHours = function(a, b){
return a.hour[0] < b.hour[0] || (a.hour[0] == b.hour[0] && a.hour[1] < b.hour[1]) ? -1 : 1;
};
var sortDay = function(arr){
var sorted = [];
if(arr.lun)
sorted.push(arr.lun);
if(arr.mar)
sorted.push(arr.mar);
if(arr.mer)
sorted.push(arr.mer);
if(arr.gio)
sorted.push(arr.gio);
if(arr.ven)
sorted.push(arr.ven);
if(arr.sab)
sorted.push(arr.sab);
if(arr.dom)
sorted.push(arr.dom);
return sorted;
};
var init = true;
PROJECT.hr = "<hr class='post-divider'>";
PROJECT.getHtmlA = function(label, url, _class) { PROJECT.getHtmlA = function(label, url, _class) {
if(!url) if(!url)
return ""; return "";
_class = _class || ""; _class = _class || "";
@ -215,25 +250,32 @@ PROJECT.getHtmlA = function(label, url, _class) {
"</a>"; "</a>";
}; };
PROJECT.getHtmlDate = function(evt) { PROJECT.getHtmlDate = function(evt, noDay) {
return "<ol>"+ if(evt) {
"<span class='e_day'>" + evt.day + "</span>" + var day = ! noDay ? "<span class='e_day'>" + evt.day + "</span>" + " " : "";
"<span class='e_from'>" + evt.hour[0] + "</span>" + " - " +
"<span class='e_to'>" + evt.hour[1] + "</span>" + return "<small>" + day +
"</ol>"; "<span class='e_from'>" + evt.hour[0] + "</span>" + " - " +
"<span class='e_to'>" + evt.hour[1] + "</span></small> " +
"<span class='e_title'>" + " : " + evt.title + "</span> ";
} else {
return "";
}
}; };
PROJECT.labOrder = function(lab){ PROJECT.labOrder = function(lab){
var events = "<ul>"; var events = "<ul>";
for(var e = 0; e < lab.when.length; e++) { for(var e = 0; e < lab.when.length; e++) {
events += PROJECT.getHtmlDate(lab.when[e]); events += "<ol>" + PROJECT.getHtmlDate(lab.when[e]) + "</ol>";
} }
events += "</ul>"; events += "</ul>";
var li = "<li>"+ var li = "<li>"+
"<span class='title'>" + lab.title + "</span>"+ "<span class='title'>" + lab.collettivo + "</span>"+
"<br>"+
"<span class='dshort'>" + lab.dshort + "</span>"+ "<span class='dshort'>" + lab.dshort + "</span>"+
"<br>"+
PROJECT.getHtmlA("Sito:", lab.site)+ PROJECT.getHtmlA("Sito:", lab.site)+
PROJECT.getHtmlA("Social Network", lab.sn)+ PROJECT.getHtmlA("Social Network", lab.sn)+
events+ events+
@ -244,33 +286,90 @@ PROJECT.labOrder = function(lab){
return li; return li;
}; };
PROJECT.dateOrder = function(lab){ PROJECT.todayOrder = function(todayEvents, lab, day){
for(var e = 0; e < lab.when.length; e++) {
//Comparo in minuscolo così son sicuro di matchare in ogni modo in cui è scritto nel json
if(lab.when[e].day.toLowerCase() == day) {
todayEvents.push(lab.when[e]);
}
}
}; };
PROJECT.todayOrder = function(lab){ PROJECT.todayRender = function(todayEvents){
var events="";
}; todayEvents.sort(sortHours);
for(var i = 0, len = todayEvents.length; i < len; i++) {
var init = true; var hr = i == len - 1 ? "" : PROJECT.hr;
events += "<li>" +
PROJECT.render = function() { PROJECT.getHtmlDate(todayEvents[i], true) +
var a = moment().format("MMM"); hr +
"</li>";
//if(ini)
var lab = "", date = "", today = "";
for(var l = 0, labLen = PROJECT.labs.length; l < labLen; l++) {
//today += PROJECT.todayOrder(PROJECT.labs[l]);
lab += PROJECT.labOrder(PROJECT.labs[l]);
//date += PROJECT.dateOrder(PROJECT.labs[l]);
} }
// $('#today p').empty(); if(todayEvents.length === 0) {
// $('#today p').html("<ul>" + lab + "</ul>"); events = "<i>Oggi non sono previsti laboratori o assemblee.</i>";
// } else {
// $('#mydate p').empty(); events = "<p class='title'>OGGI: " + moment().format('DD/MM/YYYY') + "</p><ul>" + events + "</ul>";
// $('#mydate p').html("<ul>" + lab + "</ul>"); }
return events;
};
PROJECT.dateRender = function(date) {
date.sort(sortHours);
var dates = "<p class='title'>" + date[0].day.toUpperCase() + "</p>";
dates += "<ul>";
for(var i = 0, len = date.length; i < len; i++) {
var hr = i == len - 1 ? "" : PROJECT.hr;
dates += "<li>" +
PROJECT.getHtmlDate(date[i], true) +
hr +
"</li>";
}
dates += "</ul>";
return dates;
};
PROJECT.dateOrder = function(dayEvents, lab) {
for(var e = 0; e < lab.when.length; e++) {
var day = lab.when[e].day.toLowerCase();
if(! dayEvents[day])
dayEvents[day] = [];
dayEvents[day].push(lab.when[e]);
}
};
PROJECT.render = function() {
var day = moment().format("ddd").toLowerCase();
//var day = "mar"; //DEBUG
var lab = "", date = "", today = "";
var todayEvents = [], dayEvents = [];
for(var l = 0, labLen = PROJECT.labs.length; l < labLen; l++) {
PROJECT.todayOrder(todayEvents, PROJECT.labs[l], day);
lab += PROJECT.labOrder(PROJECT.labs[l]);
PROJECT.dateOrder(dayEvents, PROJECT.labs[l]);
}
//------ TODAY ORDER
today += PROJECT.todayRender(todayEvents);
$('#today p').empty();
$('#today p').html(today);
//------ DAY ORDER
dayEvents = sortDay(dayEvents);
for(var k in dayEvents) {
date += PROJECT.dateRender(dayEvents[k]);
}
$('#mydate p').empty();
$('#mydate p').html(date);
//------ LAB ORDER
$('#project p').empty(); $('#project p').empty();
$('#project p').html("<ul>" + lab + "</ul>"); $('#project p').html("<ul>" + lab + "</ul>");