Compare commits

...

7 Commits

Author SHA1 Message Date
7ccd0279ab Fix Cookie default value 2020-08-30 17:18:12 +02:00
3b23d358a0 Fix cookie sameSite attribute 2020-08-30 17:03:24 +02:00
187ea6c970 Fix settings panel display 2020-08-30 16:54:27 +02:00
2799d2bb86 Add credits 2020-08-25 20:05:48 +02:00
ca72365f6d Fix Director's name 2020-08-25 18:03:12 +02:00
c7cc14effc Merge branch 'master' of ssh://git@git.lutran.fr:2244/franzz/ugc.git 2020-04-17 11:40:24 +02:00
e165581dc7 Adding default timezone 2020-04-17 11:38:50 +02:00
8 changed files with 134 additions and 131 deletions

View File

@@ -3,4 +3,5 @@
class Settings
{
const DEBUG = false;
const TIMEZONE = 'Europe/Paris';
}

View File

@@ -35,7 +35,7 @@
<h2><i class="fa inline fa-feedback"></i>Filtered films</h2>
<div id="feed_content"></div>
</div>
<footer><i class="fa inline fa-power"></i>Designed &amp; powered by Franzz, licensed under GPLv3.</footer>
<footer><i class="fa inline fa-power"></i>Designed &amp; powered by Franzz, <a href="https://git.lutran.fr/franzz/ugc" title="Git Repository" target="_blank">licensed under GPLv3</a>.</footer>
<div class="background"></div>
<div id="settings">
<h1>Theaters<span id="ok_settings" class="button no_bg square fa fa-ok"></span></h1>
@@ -44,4 +44,4 @@
<div class="switches"><i id="premiere" class="fa fa-lg inline"></i><span>Include Avant-première</span></div>
</div>
</body>
</html>
</html>

8
script/jquery.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,7 @@ function Film(oSettings)
this._ban = {status:false, reason:''};
this._timetable = {};
this.$Main = $('main');
this.ban = function(bStatus, sReason)
{
sReason = sReason || '';
@@ -22,18 +22,18 @@ function Film(oSettings)
}
else this.error('Setting ban status with no reason');
}
this.id = function(iFilmId)
{
return this.attr('id', iFilmId);
}
this.name = function(sName)
{
sName = sName?(sName + '').toLowerCase().replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function($1) {return $1.toUpperCase();}):'';
return this.attr('name', sName);
};
this.safe = function(sName)
{
var sSafeName = sName?removeDiacritics(sName):'';
@@ -52,7 +52,7 @@ function Film(oSettings)
if(sPoster) sPoster = this.getPosterUrl(sPoster, 'large', bForce);
return this.attr('poster_bg', sPoster);
};
this.getPosterUrl = function(sUrl, sSize, bForce)
{
bForce = bForce || false;
@@ -65,18 +65,18 @@ function Film(oSettings)
{
return this.attr('edito', sEdito);
};
this.trailer = function(sTrailer)
{
sTrailer = sTrailer?self.consts.ugc_url+sTrailer:'';
sTrailer = sTrailer?self.consts.ugc_url+sTrailer:'';
return this.attr('trailer', sTrailer);
};
this.director = function(sDirector)
{
return this.attr('director', sDirector);
};
this.attr = function(sName, sValue)
{
if(!sValue) return this._attr[sName];
@@ -106,12 +106,12 @@ function Film(oSettings)
else if(sEdito=='Nouveau') iRank += 10000000; //New releases
else if(sEdito.slice(-7)=='semaine')iRank += 100000 * parseInt(sEdito.substr(0, sEdito.indexOf('è'))); //Popular movies
else if(sEdito=='Dernières Séances')iRank += 100000;
//Adding movie ID (newer movies have greater IDs)
iRank += parseInt(this.id(), 10);
return iRank;
};
this.anchor = function()
{
if(Object.keys(this._anchor).length > 0) return this._anchor;
@@ -151,7 +151,7 @@ function Film(oSettings)
.appendTo(this.$Main);
}
};
this.toggleFilmDetails = function() {
var $This = $(this);
var show = function(hDom){
@@ -160,7 +160,7 @@ function Film(oSettings)
$Dom.find('.movie-infos li').add($Dom.find('.movie-infos').next('ul').find('li')).each(function(iKey, oElem){
self.anchor().find('.film-details').append($('<p>').text($(oElem).text()));
});
self.anchor().find('.film-details, .timetable').toggle();
self.anchor().find('.more-info').removeClass('fa-spinner fa-spin').addClass('fa-close');
};
@@ -168,17 +168,17 @@ function Film(oSettings)
self.anchor().find('.film-details, .timetable').toggle();
self.anchor().find('.more-info').removeClass('fa-close').addClass('fa-more');
}
if(self.anchor().find('.more-info').hasClass('fa-close')) hide();
else if(!$This.data('loaded')) self.getFilmDetails(show);
else show();
};
this.getFilmDetails = function(fCallBack) {
self.anchor().find('.more-info').removeClass('fa-more').addClass('fa-spinner fa-spin');
getUgcPage('film.html', {id: self.id()}, fCallBack, function(){}, 'html');
};
this.timetable = function(iCinemaId, sLang, oTimetable)
{
if(!iCinemaId) return this._timetable || {};
@@ -191,7 +191,7 @@ function Film(oSettings)
this._timetable[iCinemaId][sLang].push(oTimetable);
}
};
this.renderTimetable = function(iCinemaId)
{
var sCinema = self.settings.cinemas(iCinemaId);
@@ -208,7 +208,7 @@ function Film(oSettings)
.append($('<span>', {'class':'cinema_name'}).text(sCinema)))
.append($('<span>', {'class':'lang'}).text(sLang))
.appendTo($CinemaBox);
var $Timetable = $('<p>', {'class':'screening'});
$.each(asTimetable.sort(self.timeCompare), function(iKey, oTime){
$Timetable
@@ -219,12 +219,12 @@ function Film(oSettings)
}
});
};
this.timeCompare = function(sTime1, sTime2)
{
return (Date.parse('01/01/1970 '+sTime1.time+':00') > Date.parse('01/01/1970 '+sTime2.time+':00'));
};
this.feedback = function(sMsg)
{
$('#feed_content').append($('<p>').text(sMsg));
@@ -249,15 +249,15 @@ function Ugc()
this.$Main = $('main');
this.$Footer = $('footer');
this.$Feedback = $('#feedback');
this.loadCinemas = function()
{
//Display buffer while loading
buffer(true);
//Load Settings
this.settings.init();
//Set Header
$('#date')
.attr('datetime', this.settings.date('html'))
@@ -270,10 +270,10 @@ function Ugc()
{cinemaId:iCinemaId, date:self.settings.date('french'), page:'10007', sort:'ugc', searchFilmKey:''},
function(hDom){self.addCinema(iCinemaId, hDom)},
function(){},
'html');
'html');
});
};
this.wip = function(iProgress)
{
if(!iProgress) return this._wip;
@@ -283,11 +283,11 @@ function Ugc()
if(this._wip==0) this.onPostLoad();
}
};
this.onPostLoad = function()
{
var $Films = $('.film');
//Remove movies with no screening
$Films.not('.banned').each(function(iKey, hFilm){
var $Film = $(hFilm);
@@ -297,22 +297,22 @@ function Ugc()
oFilm.ban(true, 'No screening today');
}
});
//Sort films
$Films.sort(function(oFilm1, oFilm2){
return (self.film($(oFilm1).data('id')).getRank() < self.film($(oFilm2).data('id')).getRank())?1:-1;
}).detach();
//Add films (except bans)
$Films.appendTo(this.$Main);
//remove buffer
buffer(false);
//Build Search
this.initSearch();
};
this.addCineNav = function(iCinemaId)
{
var sCinema = self.settings.cinemas(iCinemaId);
@@ -326,7 +326,7 @@ function Ugc()
})
.text(sFirstLetter));
};
this.initSearch = function()
{
var $SearchInput = $("#search");
@@ -345,10 +345,10 @@ function Ugc()
{
var sTerm = removeDiacritics(oRequest.term);
var rMatcher = new RegExp($.ui.autocomplete.escapeRegex(sTerm), 'i');
//Remove all films
$('.film').not('.banned').hide();
$.each(oUgc.film(), function(iFilmId, oFilm)
{
if(!oFilm.ban().status)
@@ -362,7 +362,7 @@ function Ugc()
});
}
});
var asHash = self.hash();
var sDefaultSearch = asHash.items[0] || '';
if(asHash.page=='search' && sDefaultSearch!='')
@@ -370,7 +370,7 @@ function Ugc()
$SearchInput.focus().val(sDefaultSearch).putCursorAtEnd().autocomplete("search", sDefaultSearch);
}
};
this.hash = function(sPage, asItems)
{
sPage = sPage || '';
@@ -390,7 +390,7 @@ function Ugc()
window.location.hash = '#'+encodeURIComponent(sPage+sItems);
}
};
this.addCinema = function(iCinemaId, hDom)
{
var $Films = $('<div>'+hDom+'</div>').find('.cinema-time-item');
@@ -401,54 +401,54 @@ function Ugc()
var $Film = $(this);
var iFilmId = $Film.find('.movie-link').attr('href').split('id=').pop();
var oFilm = self.film(iFilmId);
if(!oFilm)
{
oFilm = new Film(self.settings);
//ID
oFilm.id(iFilmId);
//Edito
var sProg = $.trim($Film.find('.programming').text());
var sProg = $.trim($Film.find('.programming').text());
var sLabel = $.trim($Film.find('.label-ugc').text());
var sEdito = sProg?sProg:sLabel;
oFilm.edito(sEdito);
//Name
oFilm.safe(oFilm.name($Film.find('.title > a').text()));
//Poster
var sPosterUrl = $Film.find('.movie-img').attr('source').replace('palegrey.jpg', 'white.jpg');
oFilm.poster(sPosterUrl);
oFilm.backgroundPoster(sPosterUrl.replace('/small/', '/large/'));
//Trailer
oFilm.trailer('');
//Director
oFilm.director($.trim($Film.find('.movie-realisator').text().substring(4))); //omg
oFilm.director($.trim($Film.find('.movie-realisator').text().trim().substring(3))); //omg
//Minimum info acquired: book place on DOM
oFilm.anchor();
//Ban if wrong edito
if((sEdito=='Avant-Première' && !self.settings.premiere()) || sEdito=='UGC Culte' || sEdito=='Soirée Club') oFilm.ban(true, sEdito);
//Append film to Ugc
self.film(iFilmId, oFilm);
}
//Timetable
//Timetable
if(!oFilm.ban().status)
{
var sLang = '';
var $Timetables = $Film.find('ul.timetable');
var oTimes = [];
//Loop on languages
$Timetables.each(function(iKey, oTimeTable){
//Loop on sessions
$(oTimeTable).find('li').each(function(iKey, oLi){
$Li = $(oLi);
@@ -470,19 +470,19 @@ function Ugc()
else self.wip(-1);
});
};
this.film = function(iFilmId, oFilm)
{
if(!iFilmId) return this._films;
else if(!oFilm) return (iFilmId in this._films)?this._films[iFilmId]:false;
else this._films[iFilmId] = oFilm;
};
this.feedback = function(sMsg)
{
$('#feed_content').append($('<p>').text(sMsg));
};
this.error = function(sMsg)
{
console.log('Ugc Error: '+sMsg);
@@ -496,14 +496,14 @@ function Settings()
this._cinemas = {};
//this._ugcDates = [];
this._date = null;
this.$Settings = $('#settings');
this.$Header = $('header');
this.$Main = $('main');
this.consts = { days:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
months:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]};
this.init = function()
{
//Default date
@@ -516,16 +516,17 @@ function Settings()
}
else oDate = new Date(iCookieTimestamp);
this.date(oDate);
//UGC dates
this.addUgcDatesToDom();
//Default cinemas
var asCookieCinemas = Cookies.getJSON('cinemas');
this.cinemas(asCookieCinemas?asCookieCinemas:{'10':'Les Halles', '12':'Bercy', '20':'La Défense'});
asCookieCinemas = $.isEmptyObject(asCookieCinemas)?{'10':'Les Halles', '12':'Bercy', '20':'La Défense'}:asCookieCinemas;
this.cinemas(asCookieCinemas);
//UGC cinemas
getUgcPage( 'resaExpressAction!getCinemaList.action',
getUgcPage( 'resaExpressAction!getCinemaList.action',
{region:'', cinema:'', film:'', date:'', seance:'', '_':this.date('timestamp')},
function(jData){
self.ugcCinemas(jData.cinemas);
@@ -533,39 +534,39 @@ function Settings()
},
function(){self.error('Error: Could not load cinema list');},
'json');
//Avant-Première switch
var bCookiePremiere = Cookies.getJSON('premiere');
this.premiere(bCookiePremiere==null?false:bCookiePremiere);
$('.switches').click(function(){self.premiere(!self.premiere());});
};
this.premiere = function(bActive)
{
var $Premiere = $('#premiere');
if(bActive==null) return $Premiere.hasClass('fa-on');
else $Premiere.removeClass('fa-on fa-off').addClass(bActive?'fa-on':'fa-off');
};
this.ugcCinemas = function(asCinemas)
{
if(!asCinemas) return this._ugcCinemas;
else if($.isNumeric(asCinemas)) return this._ugcCinemas[asCinemas]; //Get Cinema name
else
{
$.each(asCinemas, function(iCinemaId, sCinema){
self._ugcCinemas[iCinemaId] = $.trim(sCinema.replace(/UGC( Ciné Cité|)/i, ''));
$.each(asCinemas, function(iKey, sCinema){
self._ugcCinemas[sCinema.cinemaId] = $.trim(sCinema.cinemaName.replace(/UGC( Ciné Cité|)/i, ''));
});
}
};
this.cinemas = function(asCinemas)
{
if(!asCinemas) return this._cinemas;
else if($.isNumeric(asCinemas)) return this._cinemas[asCinemas]; //Get Cinema name
else this._cinemas = asCinemas;
};
this.date = function(oDate)
{
if(!oDate) return this._date;
@@ -601,14 +602,14 @@ function Settings()
}
else this._date = oDate;
};
this.addUgcDatesToDom = function()
{
//Build today at midnight
var oNextDay = new Date();
var bTuesdayNight = (oNextDay.getDay()==2 && oNextDay.getHours()==23);
oNextDay = new Date(oNextDay.getFullYear(), oNextDay.getMonth(), oNextDay.getDate());
//Build available dates
var $Select = $('#ugc_dates').find('select');
var $List = $('#ugc_days');
@@ -625,35 +626,35 @@ function Settings()
}
$Select.append($('<option>', {'value':iTimestamp}).text(sDay));
$List.append($('<a>', {'class':'button no_bg inline day', 'id':'day_'+iTimestamp}).data('timestamp', iTimestamp).text(sDay));
//Manual break for extra day in case of Tuesday night after 23h
if(oNextDay.getDay()==3 && bTuesdayNight) break;
//Building next day
oNextDay = new Date(this.timestamp(oNextDay) + 24*60*60*1000);
iCount++;
}
//Selecting right value
$Select.val(this.date('midnight_timestamp'));
$List.find('#day_'+this.date('midnight_timestamp')).addClass('clicked');
//event
$Select.change(function(){
Cookies.set('date', $(this).val(), {expires:6});
Cookies.set('date', $(this).val(), {expires:6, sameSite: 'lax'});
reload();
});
$List.find('.day').click(function(){
Cookies.set('date', $(this).data('timestamp'), {expires:6});
Cookies.set('date', $(this).data('timestamp'), {expires:6, sameSite: 'lax'});
reload();
});
});
};
this.addUgcCinemasToDom = function()
{
//Hide buffer
self.$Settings.find('#buffer_settings').hide();
//Add cinemas
var $Cinemas = self.$Settings.find('.cinemas');
$.each(self.ugcCinemas(), function(iKey, sCinemaName){
@@ -665,7 +666,7 @@ function Settings()
.click(function(){$(this).toggleClass('include');})
.text(sCinemaName));
});
//Event: Show / Hide panel
$('#btn_settings').click(function(){self.toggleSettings(true);});
$('.background').click(function(){self.toggleSettings(false);});
@@ -678,23 +679,23 @@ function Settings()
var $Cine = $(oCinema);
asCines[$Cine.data('id')] = $Cine.text();
});
Cookies.set('cinemas', asCines);
Cookies.set('premiere', self.premiere()?'true':'false');
Cookies.set('cinemas', asCines, {sameSite: 'lax'});
Cookies.set('premiere', self.premiere()?'true':'false', {sameSite: 'lax'});
reload();
});
};
this.toggleSettings = function(bShow)
{
self.$Settings.add('.background').toggle((typeof bShow == 'undefined')?null:bShow);
};
this.timestamp = function(oDate)
{
oDate = oDate || new Date();
return oDate.getTime();
}
this.error = function(sMsg)
{
console.log('Settings Error: '+sMsg);
@@ -847,6 +848,6 @@ function removeDiacritics(str)
{
return str.replace(/[^\u0000-\u007E]/g, function(a)
{
return diacriticsMap[a] || a;
return diacriticsMap[a] || a;
});
}
}

View File

@@ -1 +1 @@
sass --unix-newline -l --style=compressed --watch ugc.scss:ugc.css
sass --style=compressed --watch ugc.scss:ugc.css

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -97,7 +97,7 @@ select {
.fa-spinner {
color: $ugc_color;
font-size:2em;
&:before {
content: "\f110";
}
@@ -118,7 +118,7 @@ select {
content: "\f0e7";
}
.fa-feedback:before {
content: "\f0b0";
content: "\f0b0";
}
.fa-settings:before {
content: "\f013";
@@ -186,11 +186,11 @@ header .title time {
nav a {
color: $ugc_color;
&:hover, &.hidden {
color: $comp_color;
}
&.hidden:hover {
color: $ugc_color;
}
@@ -226,11 +226,11 @@ main {
-webkit-box-shadow: 1px 1px 2px 1px rgba(0,0,0,0.5);
-moz-box-shadow: 1px 1px 2px 1px rgba(0,0,0,0.5);
box-shadow: 1px 1px 2px 1px rgba(0,0,0,0.5);
* {
transform: translate(0px, 0px);
}
img.bg {
position:absolute;
top:50%;
@@ -241,10 +241,10 @@ main {
opacity:0.2;
width:calc(100% - #{$poster_size});
}
.poster-container {
display: inline-block;
img.poster {
width: $poster_size;
z-index: 2;
@@ -255,41 +255,41 @@ main {
p {
margin: 0.5em 0;
}
.info {
z-index:2;
display: inline-block;
vertical-align:top;
padding:1em;
width: calc(100% - 2em - #{$poster_size});
.title {
margin: 0;
a.name {
font-weight: bold;
text-transform: uppercase;
}
}
.edito {
font-style: italic;
color:#777;
}
.film-info {
padding-left: calc((1.28571429em + 0.5em)/0.9);
font-size: 0.9em;
color: #555;
.director {
font-style: italic;
.more-info {
font-size: calc(1em/0.9);
margin-left: 0.5em;
vertical-align: -0.05em;
&:not(.fa-spin) {
cursor: pointer;
&:hover {
@@ -298,36 +298,36 @@ main {
}
}
}
.film-details {
border-left: 2px solid #CCC;
padding-left: 0.5em;
p {
font-size: 0.8em;
color: #555;
}
}
}
.timetable {
margin-top:1em;
font-size: 0.8em;
p {
line-height: 2.0;
margin: 0;
}
.cinema {
margin-right:0.5em;
.fa {
font-size: 1.25em;
line-height: 0.7656249414em;
vertical-align: -14.06250352%;
}
}
}
.lang {
margin-right:0.5em;
}
@@ -358,6 +358,14 @@ footer {
font-size: 0.8em;
margin: 1em 0 0 0;
color: $ugc_color;
a {
color: $ugc_color;
&:hover {
color: $comp_color;
}
}
}
/* Section - Settings */
@@ -390,7 +398,7 @@ footer {
h1 {
position:relative;
.button {
position:absolute;
right:0;
@@ -412,7 +420,7 @@ footer {
li {
cursor: pointer;
&:hover, &.include {
font-weight: bold;
}