reduce http request : screening time

This commit is contained in:
2015-08-30 18:41:04 +02:00
parent 50ab7c3cf4
commit edd1c37560

View File

@@ -120,9 +120,9 @@ function Film(oSettings)
this.timetable = function(iCinemaId, sLang, oTimetable) this.timetable = function(iCinemaId, sLang, oTimetable)
{ {
if(!iCinemaId) return this._timetable; if(!iCinemaId) return this._timetable || {};
else if(!sLang) return this._timetable[iCinemaId]; else if(!sLang) return this._timetable[iCinemaId] || {};
else if(!oTimetable) return this._timetable[iCinemaId][sLang]; else if(!oTimetable) return this._timetable[iCinemaId][sLang] || [];
else else
{ {
if(!(iCinemaId in this._timetable)) this._timetable[iCinemaId] = {}; if(!(iCinemaId in this._timetable)) this._timetable[iCinemaId] = {};
@@ -289,48 +289,35 @@ function Ugc()
//Timetable //Timetable
if(!oFilm.ban().status) if(!oFilm.ban().status)
{ {
getUgcPage( 'filmsAfficheAction!loadDatesList.action', getUgcPage( 'filmsAfficheAction!reloadSeancesList.action',
{filmId:oFilm.id(), cinemaId:iCinemaId, cinemaCode:'', day:''}, {filmId:oFilm.id(), cinemaId:iCinemaId, cinemaCode:'', day:self.settings.date('midnight_timestamp')},
function(jData){ function(hData){
if(!(self.settings.date('midnight_timestamp') in jData.dates)) self.wip(-1); var sLang = '';
else var $Timetable = $(hData);
{ var oTimes = [];
getUgcPage( 'filmsAfficheAction!reloadSeancesList.action', $Timetable.children().each(function(iKey, oDiv){
{filmId:oFilm.id(), cinemaId:iCinemaId, cinemaCode:'', day:self.settings.date('midnight_timestamp')}, $Div = $(oDiv);
function(hData){ if($Div.attr('class')=='Line') //New Lang
var sLang = ''; {
var $Timetable = $(hData); sLang = $.trim($Div.find('.FilmTitle').text());
var oTimes = []; }
$Timetable.children().each(function(iKey, oDiv){ else if($Div.find('a').length > 0)
$Div = $(oDiv); {
if($Div.attr('class')=='Line') //New Lang $Div.find('a').each(function(iKey, oLink){
{ var $Time = $(oLink);
sLang = $.trim($Div.find('.FilmTitle').text()); oTime = {'time':$.trim($Time.find('span').text()), 'booking':oFilm.consts.ugc_url+$Time.attr('href')};
} oFilm.timetable(iCinemaId, sLang, oTime);
else });
{ }
$Div.find('a').each(function(iKey, oLink){ });
var $Time = $(oLink); oFilm.renderTimetable(iCinemaId);
oTime = {'time':$.trim($Time.find('span').text()), 'booking':oFilm.consts.ugc_url+$Time.attr('href')}; self.wip(-1);
oFilm.timetable(iCinemaId, sLang, oTime);
});
}
});
oFilm.renderTimetable(iCinemaId);
self.wip(-1);
},
function(){
self.wip(-1);
self.error('Ajax Error detected on movie "'+oFilm.name()+'" @'+self.settings.cinemas(iCinemaId)+'.');
},
'html');
}
}, },
function(){ function(){
self.wip(-1); self.wip(-1);
self.error('Ajax Error detected on movie "'+oFilm.name()+'" @'+self.settings.cinemas(iCinemaId)+'.'); self.error('Ajax Error detected on movie "'+oFilm.name()+'" @'+self.settings.cinemas(iCinemaId)+'.');
}, },
'json'); 'html');
} }
else self.wip(-1); else self.wip(-1);
}); });
@@ -404,7 +391,13 @@ function Settings()
{ {
if(!asCinemas) return this._ugcCinemas; if(!asCinemas) return this._ugcCinemas;
else if($.isNumeric(asCinemas)) return this._ugcCinemas[asCinemas]; //Get Cinema name else if($.isNumeric(asCinemas)) return this._ugcCinemas[asCinemas]; //Get Cinema name
else this._ugcCinemas = asCinemas; else
{
$.each(asCinemas, function(iCinemaId, sCinema){
self._ugcCinemas[iCinemaId] = $.trim(sCinema.replace(/UGC (Ciné Cité|)/i, ''));
});
}
}; };
this.cinemas = function(asCinemas) this.cinemas = function(asCinemas)