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;
}
/*.introlettera OLD {
display:inline-block;
padding:0 2em;
margin-top:0px;
text-align:left;
font-family: 'bebas_neuebold';
} */
#today li .e_title,
#mydate li .e_title {
font-size: 0.7em;
line-height: 2.8;
}
#today .title,
#mydate .title {
text-transform: initial;
font-size: 1.2em;
color: #000;
}
.introlettera {
display: inline-block;
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/xml2json.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 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 role="main" class="ui-content">
<div class="ui-body">
<p class="introlettera">EVENTI</p>
<div data-role="tabs">
<div data-role="navbar">
<ul>
<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>
<p class="introlettera">Eventi</p>
<p id="mostralista-34" class="listatovirgole listevoci">
<i>Non sono stati attualmente caricati eventi.</i>
</p>
</div>
</div>
</div><!--chiude content -->

View file

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

View file

@ -6,8 +6,8 @@ PROJECT.labs = [
dlong: "...",
when : [
{day: "Mar", hour: ["19:00", "22:00"], title: "Assemblea Ciclofficina" },
{day: "Mer", hour: ["18:00", "22:00"], title: "Riparazioni collettive biciclette" },
{day: "Dom", 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 biciclette" }
],
old_event: "", //un vecchio evento
site: "http://ampioraggio.noblogs.org", //sito personale
@ -83,7 +83,7 @@ PROJECT.labs = [
"opposta alle logiche della produzione industriale massiva e omologante.",
when : [
{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: "Lun", 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"+
" una alternativa al sistema economico dominante.",
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
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) {
if(!url)
return "";
_class = _class || "";
@ -215,25 +250,32 @@ PROJECT.getHtmlA = function(label, url, _class) {
"</a>";
};
PROJECT.getHtmlDate = function(evt) {
return "<ol>"+
"<span class='e_day'>" + evt.day + "</span>" +
"<span class='e_from'>" + evt.hour[0] + "</span>" + " - " +
"<span class='e_to'>" + evt.hour[1] + "</span>" +
"</ol>";
PROJECT.getHtmlDate = function(evt, noDay) {
if(evt) {
var day = ! noDay ? "<span class='e_day'>" + evt.day + "</span>" + " " : "";
return "<small>" + day +
"<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){
var events = "<ul>";
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>";
var li = "<li>"+
"<span class='title'>" + lab.title + "</span>"+
"<span class='title'>" + lab.collettivo + "</span>"+
"<br>"+
"<span class='dshort'>" + lab.dshort + "</span>"+
"<br>"+
PROJECT.getHtmlA("Sito:", lab.site)+
PROJECT.getHtmlA("Social Network", lab.sn)+
events+
@ -244,33 +286,90 @@ PROJECT.labOrder = function(lab){
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="";
};
var init = true;
PROJECT.render = function() {
var a = moment().format("MMM");
//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]);
todayEvents.sort(sortHours);
for(var i = 0, len = todayEvents.length; i < len; i++) {
var hr = i == len - 1 ? "" : PROJECT.hr;
events += "<li>" +
PROJECT.getHtmlDate(todayEvents[i], true) +
hr +
"</li>";
}
// $('#today p').empty();
// $('#today p').html("<ul>" + lab + "</ul>");
//
// $('#mydate p').empty();
// $('#mydate p').html("<ul>" + lab + "</ul>");
if(todayEvents.length === 0) {
events = "<i>Oggi non sono previsti laboratori o assemblee.</i>";
} else {
events = "<p class='title'>OGGI: " + moment().format('DD/MM/YYYY') + "</p><ul>" + events + "</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').html("<ul>" + lab + "</ul>");