post activities function
This commit is contained in:
@@ -7,7 +7,6 @@ function Film()
|
|||||||
this._ban = {status:false, reason:''};
|
this._ban = {status:false, reason:''};
|
||||||
this._timetable = {};
|
this._timetable = {};
|
||||||
this.$Main = $('main');
|
this.$Main = $('main');
|
||||||
this.$Footer = $('footer');
|
|
||||||
|
|
||||||
this.ban = function(bStatus, sReason)
|
this.ban = function(bStatus, sReason)
|
||||||
{
|
{
|
||||||
@@ -18,7 +17,7 @@ function Film()
|
|||||||
this._ban.status = true;
|
this._ban.status = true;
|
||||||
this._ban.reason = sReason;
|
this._ban.reason = sReason;
|
||||||
this.error('Hidding "'+this.name()+'". Ban reason: '+this.ban().reason);
|
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');
|
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);
|
else this.error('Trying to set an empty film attribute: '+sName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
this.removeSpinner = function()
|
this.removeSpinner = function()
|
||||||
{
|
{
|
||||||
this.anchor().find('.timetable').removeClass('fa fa-fw fa-spinner fa-spin');
|
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()
|
this.anchor = function()
|
||||||
{
|
{
|
||||||
if(Object.keys(this._anchor).length > 0) return this._anchor;
|
if(Object.keys(this._anchor).length > 0) return this._anchor;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Init page
|
|
||||||
this.onPageReady();
|
|
||||||
|
|
||||||
//Add film to DOM
|
//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':'bg', 'src':this.poster()}))
|
||||||
.append($('<img>', {'class':'poster', 'src':this.poster()}))
|
.append($('<img>', {'class':'poster', 'src':this.poster()}))
|
||||||
.append($('<div>', {'class':'info'})
|
.append($('<div>', {'class':'info'})
|
||||||
@@ -94,7 +101,9 @@ function Film()
|
|||||||
.append($('<a>', {'target':'_blank', 'href':this.trailer()})
|
.append($('<a>', {'target':'_blank', 'href':this.trailer()})
|
||||||
.append($('<i>', {'class':'fa fa-fw fa-icon fa-trailer'}))
|
.append($('<i>', {'class':'fa fa-fw fa-icon fa-trailer'}))
|
||||||
.append('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);
|
.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)
|
this.renderTimetable = function(iCinemaId, asLang)
|
||||||
{
|
{
|
||||||
var sCinema = asCinemas[iCinemaId];
|
var sCinema = asCinemas[iCinemaId];
|
||||||
@@ -134,6 +137,9 @@ function Film()
|
|||||||
.append($('<span>', {'class':'lang'}).text(sLang))
|
.append($('<span>', {'class':'lang'}).text(sLang))
|
||||||
.appendTo(self.anchor().find('.timetable'));
|
.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){
|
$.each(self.timetable(iCinemaId, sLang).sort(self.timeCompare), function(iKey, oTime){
|
||||||
$Timetable
|
$Timetable
|
||||||
.append($('<a>', {'class':'time', 'href':oTime.booking, 'target':'_blank'}).text(oTime.time))
|
.append($('<a>', {'class':'time', 'href':oTime.booking, 'target':'_blank'}).text(oTime.time))
|
||||||
@@ -150,7 +156,6 @@ function Film()
|
|||||||
|
|
||||||
this.error = function(sMsg)
|
this.error = function(sMsg)
|
||||||
{
|
{
|
||||||
$('#feedback').show();
|
|
||||||
$('#feed_content').append($('<p>').text(sMsg));
|
$('#feed_content').append($('<p>').text(sMsg));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -164,15 +169,48 @@ function Affiche(oDate)
|
|||||||
this.date.timestamp = this.date.today / 1;
|
this.date.timestamp = this.date.today / 1;
|
||||||
|
|
||||||
this._films = {};
|
this._films = {};
|
||||||
|
this._wip = 0;
|
||||||
this.consts = { days:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
this.consts = { days:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||||
months:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]};
|
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()
|
this.isLoaded = function()
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
return true;
|
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()
|
this.loadCinemas = function()
|
||||||
{
|
{
|
||||||
//Today timestamp
|
//Today timestamp
|
||||||
@@ -182,6 +220,7 @@ function Affiche(oDate)
|
|||||||
getUgcPage( 'filmsAjaxAction!getFilmsForPageCinema.action',
|
getUgcPage( 'filmsAjaxAction!getFilmsForPageCinema.action',
|
||||||
{cinemaId:iCinemaId, cinemaCode:'', page:'7', filmId:'', filmId_widget:'', '_':Date.now()},
|
{cinemaId:iCinemaId, cinemaCode:'', page:'7', filmId:'', filmId_widget:'', '_':Date.now()},
|
||||||
function(hDom){self.addCinema(iCinemaId, hDom)},
|
function(hDom){self.addCinema(iCinemaId, hDom)},
|
||||||
|
function(){},
|
||||||
'html');
|
'html');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -190,6 +229,7 @@ function Affiche(oDate)
|
|||||||
{
|
{
|
||||||
var $Page = $(hDom);
|
var $Page = $(hDom);
|
||||||
var $Films = $Page.find('.FilmDiv');
|
var $Films = $Page.find('.FilmDiv');
|
||||||
|
this.wip($Films.length);
|
||||||
$Films.each(function()
|
$Films.each(function()
|
||||||
{
|
{
|
||||||
var $Film = $(this);
|
var $Film = $(this);
|
||||||
@@ -235,7 +275,8 @@ function Affiche(oDate)
|
|||||||
if(!(self.date.timestamp in jData.dates))
|
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]]+')');
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -264,13 +305,23 @@ function Affiche(oDate)
|
|||||||
});
|
});
|
||||||
asLangs.push(sLang);
|
asLangs.push(sLang);
|
||||||
oFilm.renderTimetable(iCinemaId, asLangs);
|
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');
|
'html');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
function(){
|
||||||
|
self.wip(-1);
|
||||||
|
self.error('Error detected on film "'+oFilm.name()+'" @'+asCinemas[iCinemaId]+'. UGC website Temporarily Unavailable');
|
||||||
|
},
|
||||||
'json');
|
'json');
|
||||||
}
|
}
|
||||||
|
else self.wip(-1);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -292,13 +343,17 @@ function Affiche(oDate)
|
|||||||
|
|
||||||
this.error = function(sMsg)
|
this.error = function(sMsg)
|
||||||
{
|
{
|
||||||
$('#feedback').show();
|
|
||||||
$('#feed_content').append($('<p>').text(sMsg));
|
$('#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}};
|
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