Skip to content
Snippets Groups Projects
Commit d5aba44e authored by Niklas Schrötler's avatar Niklas Schrötler
Browse files

Removed outdated files

parent 4e5dffe4
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 681 deletions
importScripts('../../js/helper/AJAX.js');
importScripts('../../js/helper/check.js');
importScripts('../../js/helper/AbstractWorker.js');
class DepartureWorker extends AbstractWorker {
constructor() {
super();
this.setSpeed(360000);
}
processConfig(config) {
if (isObject(config) && isArrayNotEmpty(config['stops'])) {
config['stops_converted'] = [];
for (var i = 0; i < config['stops'].length; ++i) {
config['stops_converted'].push({url:'https://vrrf.finalrewind.org/'+config['stops'][i].split(':').join('/')+'.json',method:'GET',params:{frontend:'json'}});
}
}
return config;
}
tick(callback) {
var config = this.config;
if (isObject(config) && isArrayNotEmpty(config['stops_converted'])) {
AJAX.request(config['stops_converted']).then(function(results) {
if (results.length == 0) return;
var
reftime = new Date(),
result = {
vrrf_version: {
actual: '0.0.0.0',
expected: '0.0.0.0'
},
errors: {},
info: {},
lines: {},
raw: {}
},
rawLines = {};
reftime = calcDateValue(reftime.getFullYear(), reftime.getMonth()+1, reftime.getDate(), reftime.getHours(), reftime.getMinutes());
for (var i = 0; i < results.length; ++i) {
if (!results[i].success) continue;
var data = results[i].response;
if (!isObject(data)) data = JSON.parse(data);
var stopName = config['stops'][i].split('/').join(' - ');
result['vrrf_version']['actual'] = data['version'];
result['vrrf_version']['expected'] = '0.0.0.0';
result['errors'][stopName] = data['error'];
result['info'][stopName] = '';
result['raw'][stopName] = data['raw'];
for (var j = 0; j < data['raw'].length; ++j) {
var entry = data['raw'][j];
// filter
if (isObjectNotEmpty(config['filter']) && !passFilter(config['filter'], entry)) continue;
// interprete
var
schedDate = entry['sched_date'].split('.'),
schedTime = entry['sched_time'].split(':'),
deptime = calcDateValue(schedDate[2], schedDate[1], schedDate[0], schedTime[0], schedTime[1]);
var delay = parseInt(entry['delay']);
if (isNaN(delay)) delay = 0;
if (((deptime + delay) - reftime) > 0) {
var ident = /*entry['lineref']['operator']+'|'+entry['lineref']['type']+'|'+*/entry['line']+'|'+entry['lineref']['identifier']+'|'+entry['key'];
if (!isObjectNotEmpty(result['lines'][ident])) {
result['lines'][ident] = {
timeValue: deptime,
line: entry['line'],
destination: entry['destination'],
type: entry['type'],
stops: [{
timeValue: deptime,
time: entry['sched_time'],
delay: entry['delay'],
cancel: entry['is_cancelled'],
name: stopName,
info: entry['info']
}]
};
} else {
result['lines'][ident]['stops'].push({
timeValue: deptime,
time: entry['sched_time'],
delay: entry['delay'],
cancel: entry['is_cancelled'],
name: stopName,
info: entry['info']
});
}
}
}
}
result['lines'] = sortData(Object.values(result['lines']));
if (isNumber(config.max)) {
result['lines'] = result['lines'].slice(0, config.max);
}
callback(result);
});
}
}
}
function passFilter(filter, entry) {
if (isObjectNotEmpty(filter['bl'])) {
if (isArrayNotEmpty(filter['bl']['line'])
&& arrayContains(filter['bl']['line'], entry['line'])) {
return false;
}
if (isArrayNotEmpty(filter['bl']['type'])
&& arrayContains(filter['bl']['type'], entry['type'])) {
return false;
}
if (isArrayNotEmpty(filter['bl']['platform'])
&& arrayContains(filter['bl']['platform'], entry['platform'])) {
return false;
}
if (isArrayNotEmpty(filter['bl']['destination'])
&& arrayContains(filter['bl']['destination'], entry['destination'])) {
return false;
}
}
if (isObjectNotEmpty(filter['wl'])) {
if (isArrayNotEmpty(filter['wl']['line'])
&& !arrayContains(filter['wl']['line'], entry['line'])) {
return false;
}
if (isArrayNotEmpty(filter['wl']['type'])
&& !arrayContains(filter['wl']['type'], entry['type'])) {
return false;
}
if (isArrayNotEmpty(filter['wl']['platform'])
&& !arrayContains(filter['wl']['platform'], entry['platform'])) {
return false;
}
if (isArrayNotEmpty(filter['wl']['destination'])
&& !arrayContains(filter['wl']['destination'], entry['destination'])) {
return false;
}
}
return true;
}
function sortData(data) {
for (var i = 0; i < data.length; ++i) {
data[i]['stops'] = data[i]['stops'].sort(sortFn);
data[i]['timeValue'] = data[i]['stops'][0]['timeValue'];
}
return data.sort(sortFn);
}
function sortFn(a,b) {
return a['timeValue'] - b['timeValue'];
}
function calcDateValue(year, month, day, hour, minute) {
year = parseInt(year) * 12 * 31 * 24 * 60;
month = parseInt(month) * 31 * 24 * 60;
day = parseInt(day) * 24 * 60;
hour = parseInt(hour) * 60;
minute = parseInt(minute);
return year+month+day+hour+minute;
}
new DepartureWorker;
var myPanel = null;
this.loaded = function(panel, config) {
myPanel = panel;
$(panel).find("span").text(config);
}
this.resize = function() {
$(myPanel).textfill({
maxFontPixels:-1
});
}
this.checkShowCondition = function() {
return 1;
}
this.show = function() {
$(myPanel).css("backgroundColor","red");
}
this.hide = function() {
}
span {
color: white;
font-size: 200pt;
}
span {
color:white;
font-size: 200pt;
}
\ No newline at end of file
<span>It works!</span>
\ No newline at end of file
this.resize=function() {
this.panel.find("#zwei").textfill({
maxFontPixels:-1
});
}
\ No newline at end of file
#eins {
color: #C11010;
text-align: center;
background: linear-gradient(135deg, #fff200 0%, #ffff00 34%, #ffff00 34%, #070000 35%, #000000 47%, #070000 79%, #070000 79%, #ffff00 79%, #ffff00 100%);
background-size: 100% 100%;
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
width: 100%;
height: 100%;
}
#zwei {
width: 100%;
word-break: break-all;
font-family: vrr;
font-size: 142px;
height: 100%;
white-space: nowrap;
overflow: hidden;
padding: 5px;
}
#zwei span {
height: 100%;
}
#eins {
color: #C11010;
text-align: center;
background: linear-gradient(135deg, #fff200 0%,#ffff00 34%,#ffff00 34%,#070000 35%,#000000 47%,#070000 79%,#070000 79%,#ffff00 79%,#ffff00 100%);
background-size: 100% 100%;
text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
width:100%;
height:100%;
}
#zwei{
width: 100%;
height: 100%;
word-break: break-all;
font-family: vrr;
font-size: 142px;
height:100%;
white-space: nowrap;
overflow:hidden;
padding:5px;
}
#zwei span {
height:100%;
}
\ No newline at end of file
<div id="eins">
<div id="zwei">
<span>MATEKALYPSE!</span>
</div>
</div>
\ No newline at end of file
config.php
this.tabtime=20;
this.checkShowCondition = function() {
return 3*this.tabtime;
}
this.show = function() {
// switch tabs
this.interval=setInterval(function() {
var currentTab = $("#tabs").tabs('option', 'active');
switch (currentTab) {
case 0:
currentTab = 1;
break;
case 1:
currentTab = 2;
break;
case 2:
currentTab = 0;
break;
default:
currentTab = 0;
}
$("#tabs").tabs({
active : currentTab
});
}, this.tabtime*1000);
}
this.hide = function() {
clearInterval(this.interval);
}
function padTwo(num) {
if (num < 10) {
return "0" + num
} else {
return num
}
}
function isNextDay() {
if (new Date().getHours() >= 15) {
console.log("NEXT")
return true;
}
console.log("CURRENT")
return false;
}
function calcDateAPI() {
if (isNextDay()) {
return new Date().getFullYear() + "-" + padTwo(new Date().getMonth()+1) + "-" + (padTwo(new Date().getDate() + 1));
} else {
return new Date().getFullYear() + "-" + padTwo(new Date().getMonth()+1) + "-" + padTwo(new Date().getDate());
}
}
function calcTextDisplay() {
if (isNextDay()) {
return "Mensaplan von MORGEN, dem " + (padTwo(new Date().getDate() + 1)) +"."+ padTwo(new Date().getMonth()+1) +"."+ new Date().getFullYear();
} else {
return "Mensaplan von HEUTE, dem " + padTwo(new Date().getDate()) +"."+ padTwo(new Date().getMonth()+1) +"."+ new Date().getFullYear();
}
}
function handleGericht(text) {
text = text.replace(/\([^\)]*\)/g, ""); // remove zusatzstoffe
text = text.replace(/\s+/g, " "); // fix double Whitespace
text = text.replace(/(\s,|,\s)/g, ","); // fix Komma
text = text.replace(/,/g, ", "); // fix Komma
text = text.replace(/,\sdazu\s\d\sBeilagen\snach\sWahl/g, " "); // remove Beilagen
text = text.replace(/\sund\s\d\sBeilagen\snach\sWahl/g, " "); // remove Beilagen
text = text.replace(/,\sdazu\s/g, " + "); // replace dazu
text = text.replace(/\sund\s/g, " & "); // replace und
return text
}
this.loaded = function(panel, config) {
// reload data
setInterval(function() {
getMensaPlan();
}, 30*60*1000);
function getMensaPlan() {
$.getJSON("https://infoscreen.oh14.de/canteen-menu/v3/canteens/341/"+calcDateAPI()).done(function(json) {
fillTable(json);
}).fail(function(jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
console.error("MensaPlan: Request Failed: " + err);
});
}
function fillTable(json) {
document.getElementById("mensaPlanTitleBar").innerHTML = calcTextDisplay();
var tableBody1 = document.getElementById("mensaPlanTable1Body");
var tableBody3 = document.getElementById("mensaPlanTable3Body");
var tableBody4 = document.getElementById("mensaPlanTable4Body");
tableBody1.innerHTML = ""; // clear
tableBody3.innerHTML = ""; // clear
tableBody4.innerHTML = ""; // clear
var a = 0;
var b = 0;
var c = 0;
var d = 0;
for (var i = 0; i < json.length; i++) {
var gericht = json[i];
var row = "";
switch (gericht.category) {
case "1": // Menu 1
var row = tableBody1.insertRow(a);
a++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "2": // Menu 2
var row = tableBody1.insertRow(a);
a++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "3": // Tagesgericht
var row = tableBody1.insertRow(a);
a++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "4": // Vegetarisch
var row = tableBody3.insertRow(c);
c++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "5": // Aktionsteller
var row = tableBody1.insertRow(a);
a++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "6": // Aktionsteller Fisch
var row = tableBody3.insertRow(c);
c++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "7": // Aktionsteller Vegan
var row = tableBody3.insertRow(c);
c++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
break;
case "16": // Beilagen
var beilagen = gericht.title.de.split(";");
for (var j = 0; j < beilagen.length; j++) {
if(beilagen[j] != "") {
var row = tableBody4.insertRow(d);
d++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(beilagen[j]);
}
}
break;
default:
var row = tableBody3.insertRow(c);
c++;
var cell = row.insertCell(0);
cell.innerHTML = handleGericht(gericht.title.de);
}
}
}
getMensaPlan();
$(function() {
$("#tabs").tabs();
});
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<canvas data-marquee></canvas>
\ No newline at end of file
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment