post activities function
This commit is contained in:
@@ -7,7 +7,6 @@ function Film()
|
||||
this._ban = {status:false, reason:''};
|
||||
this._timetable = {};
|
||||
this.$Main = $('main');
|
||||
this.$Footer = $('footer');
|
||||
|
||||
this.ban = function(bStatus, sReason)
|
||||
{
|
||||
@@ -18,7 +17,7 @@ function Film()
|
||||
this._ban.status = true;
|
||||
this._ban.reason = sReason;
|
||||
this.error('Hidding "'+this.name()+'". Ban reason: '+this.ban().reason);
|
||||
this.anchor().hide();
|
||||
this.anchor().addClass('banned');
|
||||
}
|
||||
else this.error('setting ban status with no reason');
|
||||
}
|
||||
@@ -66,22 +65,30 @@ function Film()
|
||||
else this.error('Trying to set an empty film attribute: '+sName);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
this.removeSpinner = function()
|
||||
{
|
||||
this.anchor().find('.timetable').removeClass('fa fa-fw fa-spinner fa-spin');
|
||||
}
|
||||
*/
|
||||
this.getRank = function()
|
||||
{
|
||||
var sEdito = this.edito() || '';
|
||||
var iRank = 0;
|
||||
if(sEdito=='Nouveau') iRank += 10000000;
|
||||
else if(sEdito.slice(-7)=='semaine') iRank += 100000*parseInt(sEdito.substr(0, sEdito.indexOf('è')));
|
||||
iRank += parseInt(this.id(), 10);
|
||||
return iRank;
|
||||
};
|
||||
|
||||
this.anchor = function()
|
||||
{
|
||||
if(Object.keys(this._anchor).length > 0) return this._anchor;
|
||||
else
|
||||
{
|
||||
//Init page
|
||||
this.onPageReady();
|
||||
|
||||
//Add film to DOM
|
||||
this._anchor = $('<div>', {'class':'film', 'id':'film_'+this.id()})
|
||||
this._anchor = $('<div>', {'class':'film', 'id':'film_'+this.getRank()})
|
||||
.data('rank', this.getRank())
|
||||
//.append($('<img>', {'class':'bg', 'src':this.poster()}))
|
||||
.append($('<img>', {'class':'poster', 'src':this.poster()}))
|
||||
.append($('<div>', {'class':'info'})
|
||||
@@ -94,7 +101,9 @@ function Film()
|
||||
.append($('<a>', {'target':'_blank', 'href':this.trailer()})
|
||||
.append($('<i>', {'class':'fa fa-fw fa-icon fa-trailer'}))
|
||||
.append('Trailer')))
|
||||
.append($('<div>', {'class':'timetable fa fa-fw fa-spinner fa-spin'})))
|
||||
.append($('<div>', {'class':'timetable'})))
|
||||
//.append($('<div>', {'class':'timetable fa fa-fw fa-spinner fa-spin'})))
|
||||
.hide()
|
||||
.appendTo(this.$Main);
|
||||
}
|
||||
};
|
||||
@@ -112,12 +121,6 @@ function Film()
|
||||
}
|
||||
};
|
||||
|
||||
this.onPageReady = function()
|
||||
{
|
||||
this.$Main.find('#buffer').hide();
|
||||
this.$Footer.show();
|
||||
};
|
||||
|
||||
this.renderTimetable = function(iCinemaId, asLang)
|
||||
{
|
||||
var sCinema = asCinemas[iCinemaId];
|
||||
@@ -134,6 +137,9 @@ function Film()
|
||||
.append($('<span>', {'class':'lang'}).text(sLang))
|
||||
.appendTo(self.anchor().find('.timetable'));
|
||||
|
||||
|
||||
var test = self.timetable(iCinemaId, sLang);
|
||||
if(!test) console.log('cinema '+iCinemaId+' lang '+sLang+' film '+self.id());
|
||||
$.each(self.timetable(iCinemaId, sLang).sort(self.timeCompare), function(iKey, oTime){
|
||||
$Timetable
|
||||
.append($('<a>', {'class':'time', 'href':oTime.booking, 'target':'_blank'}).text(oTime.time))
|
||||
@@ -150,7 +156,6 @@ function Film()
|
||||
|
||||
this.error = function(sMsg)
|
||||
{
|
||||
$('#feedback').show();
|
||||
$('#feed_content').append($('<p>').text(sMsg));
|
||||
};
|
||||
}
|
||||
@@ -164,15 +169,48 @@ function Affiche(oDate)
|
||||
this.date.timestamp = this.date.today / 1;
|
||||
|
||||
this._films = {};
|
||||
this._wip = 0;
|
||||
this.consts = { days:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||
months:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]};
|
||||
|
||||
this.$Main = $('main');
|
||||
this.$Footer = $('footer');
|
||||
this.$Feedback = $('#feedback');
|
||||
|
||||
this.isLoaded = function()
|
||||
{
|
||||
//TODO
|
||||
return true;
|
||||
};
|
||||
|
||||
this.wip = function(iProgress)
|
||||
{
|
||||
if(!iProgress) return this._wip;
|
||||
else
|
||||
{
|
||||
this._wip += iProgress;
|
||||
if(this._wip==0) this.onPostLoad();
|
||||
}
|
||||
};
|
||||
|
||||
this.onPostLoad = function()
|
||||
{
|
||||
//Sort films
|
||||
$Films = $('.film');
|
||||
$Films.sort(function(oFilm1, oFilm2)
|
||||
{
|
||||
return ($(oFilm1).data('rank') < $(oFilm2).data('rank'))?1:-1;
|
||||
});
|
||||
|
||||
this.$Main.find('#buffer').hide();
|
||||
$Films
|
||||
.detach()
|
||||
.appendTo(this.$Main)
|
||||
.not('.banned')
|
||||
.show();
|
||||
this.$Footer.add(this.$Feedback).show();
|
||||
};
|
||||
|
||||
this.loadCinemas = function()
|
||||
{
|
||||
//Today timestamp
|
||||
@@ -182,6 +220,7 @@ function Affiche(oDate)
|
||||
getUgcPage( 'filmsAjaxAction!getFilmsForPageCinema.action',
|
||||
{cinemaId:iCinemaId, cinemaCode:'', page:'7', filmId:'', filmId_widget:'', '_':Date.now()},
|
||||
function(hDom){self.addCinema(iCinemaId, hDom)},
|
||||
function(){},
|
||||
'html');
|
||||
});
|
||||
};
|
||||
@@ -190,6 +229,7 @@ function Affiche(oDate)
|
||||
{
|
||||
var $Page = $(hDom);
|
||||
var $Films = $Page.find('.FilmDiv');
|
||||
this.wip($Films.length);
|
||||
$Films.each(function()
|
||||
{
|
||||
var $Film = $(this);
|
||||
@@ -235,7 +275,8 @@ function Affiche(oDate)
|
||||
if(!(self.date.timestamp in jData.dates))
|
||||
{
|
||||
self.error('No times today for "'+oFilm.name()+'" @'+asCinemas[iCinemaId]+' (first date available: '+jData.dates[Object.keys(jData.dates)[0]]+')');
|
||||
if(self.isLoaded()) oFilm.removeSpinner();
|
||||
//if(self.isLoaded()) oFilm.removeSpinner();
|
||||
self.wip(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -264,13 +305,23 @@ function Affiche(oDate)
|
||||
});
|
||||
asLangs.push(sLang);
|
||||
oFilm.renderTimetable(iCinemaId, asLangs);
|
||||
if(self.isLoaded()) oFilm.removeSpinner();
|
||||
//if(self.isLoaded()) oFilm.removeSpinner();
|
||||
self.wip(-1);
|
||||
},
|
||||
function(){
|
||||
self.wip(-1);
|
||||
self.error('Error detected on film "'+oFilm.name()+'" @'+asCinemas[iCinemaId]+'. UGC website Temporarily Unavailable');
|
||||
},
|
||||
'html');
|
||||
}
|
||||
},
|
||||
function(){
|
||||
self.wip(-1);
|
||||
self.error('Error detected on film "'+oFilm.name()+'" @'+asCinemas[iCinemaId]+'. UGC website Temporarily Unavailable');
|
||||
},
|
||||
'json');
|
||||
}
|
||||
else self.wip(-1);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -292,13 +343,17 @@ function Affiche(oDate)
|
||||
|
||||
this.error = function(sMsg)
|
||||
{
|
||||
$('#feedback').show();
|
||||
$('#feed_content').append($('<p>').text(sMsg));
|
||||
};
|
||||
}
|
||||
|
||||
function getUgcPage(sPath, asData, fOnSuccess, sType)
|
||||
function getUgcPage(sPath, asData, fOnSuccess, fOnFail, sType)
|
||||
{
|
||||
var asParams = {'a':'get_page', 'type':sType, 'data':{'path':sPath, 'vars':asData}};
|
||||
$.get((new Film()).consts.process_url, asParams, fOnSuccess, sType);
|
||||
$.ajax({
|
||||
url: (new Film()).consts.process_url,
|
||||
data: asParams,
|
||||
dataType: sType
|
||||
}).done(fOnSuccess)
|
||||
.fail(fOnFail);
|
||||
}
|
||||
Reference in New Issue
Block a user