diff --git a/panels/lsfView/config.php.skel b/panels/lsfView/config.php.skel index 938f878b1800e61c7c3a2d28a54e7b930e052167..d789806f47338fde3ae323b8042da406d885d7f0 100755 --- a/panels/lsfView/config.php.skel +++ b/panels/lsfView/config.php.skel @@ -25,7 +25,11 @@ $SUBJECT_LIST_WS = array ( ); // JSON -$JSON_NAME = "../../tmp/lsfView.json"; -$JSON_INC_NAME = true; -$JSON_INC_SHORT = true; +$JSON_NAME_SUBJECTS = "../../tmp/lsfViewSubjects.json"; +$JSON_INC_NAME_SUBJECTS = true; +$JSON_INC_SHORT_SUBJECTS = true; + +$JSON_NAME_EVENTS = "../../tmp/lsfViewEvents.json"; +$JSON_INC_NAME_EVENTS = true; +$JSON_INC_SHORT_EVENTS = true; ?> \ No newline at end of file diff --git a/panels/lsfView/event.php b/panels/lsfView/event.php index 8af1f855cd179335dd7a0b676af4e1febbdc575c..5963fbbab01dd94108451edce71012a02b9c24a7 100755 --- a/panels/lsfView/event.php +++ b/panels/lsfView/event.php @@ -45,6 +45,14 @@ class EVENT { return $json; } + public function toInnerJson() { + $json = '"Day": '.$this->day; + $json .= ',"StartTime": "'.$this->startTime . '"'; + $json .= ',"EndTime": "'.$this->endTime . '"'; + $json .= ',"Room": "'.$this->room . '"'; + return $json; + } + public function __toString() { return "Day: " . $this->day . ", StartTime: " . $this->startTime . ", EndTime: ". $this->endTime . ", Room: ".$this->room; } diff --git a/panels/lsfView/helper.php b/panels/lsfView/helper.php index d7dfa6e4fd8a60dd80482eff97eb5babe30a3af8..2daec933ad9ff8f25be7c8c47e6e483781642508 100755 --- a/panels/lsfView/helper.php +++ b/panels/lsfView/helper.php @@ -7,10 +7,9 @@ function booleanToString($bool) { } } -//TODO: -function toJson($subjects, $jsonName, $inc_name = true, $inc_short = true) { +function toJsonSubjects($subjects, $jsonName, $inc_name = true, $inc_short = true) { $kommata = false; - $json = '{'; + $json = '{"subjects": ['; foreach ( $subjects as $subject ) { if ($kommata) { $json .= ','; @@ -19,14 +18,27 @@ function toJson($subjects, $jsonName, $inc_name = true, $inc_short = true) { } $json .= $subject->toJson ( $inc_name, $inc_short); } - $json .= "}"; + $json .= "]}"; + file_put_contents ( $jsonName , $json ); +} + +function toJsonEvents($subjects, $jsonName, $inc_name = true, $inc_short = true) { + $kommata = false; + $json = '{"events": ['; + foreach ( $subjects as $subject ) { + if ($kommata) { + $json .= ','; + } else { + $kommata = true; + } + $json .= $subject->eventsToJson ( $inc_name, $inc_short); + } + $json .= "]}"; file_put_contents ( $jsonName , $json ); } function parsSubject($html,$subject) { echo "Parsing " . $subject->getSearchName() . "\n"; - //$subject->setNr($html->find('td',2)->innertext); - //$subject->setShort($html->find('td',3)->innertext); $html = $html->find('table[summary="Übersicht über alle Veranstaltungstermine"]',0); $html = $html->find('tr'); array_shift($html); diff --git a/panels/lsfView/lsfParser.php b/panels/lsfView/lsfParser.php index 3379dcd231a4d4789518abd0f62f1a8b8bea33bc..de35246595be35e56ab96164158689d167323b35 100755 --- a/panels/lsfView/lsfParser.php +++ b/panels/lsfView/lsfParser.php @@ -88,6 +88,6 @@ foreach ( $SUBJECT_LIST as $SUBJECT ) { } } -toJson ( $subjects, $JSON_NAME, $JSON_INC_NAME, $JSON_INC_SHORT); - +toJsonSubjects ( $subjects, $JSON_NAME_SUBJECTS, $JSON_INC_NAME_SUBJECTS, $JSON_INC_SHORT_SUBJECTS); +toJsonEvents ( $subjects, $JSON_NAME_EVENTS, $JSON_INC_NAME_EVENTS, $JSON_INC_SHORT_EVENTS); ?> \ No newline at end of file diff --git a/panels/lsfView/script.js b/panels/lsfView/script.js index 27ef8fb788e79b987814e7ea364b81d83fdf011b..fcb468bb51faad501367e1bf5bc03b849a784ae6 100755 --- a/panels/lsfView/script.js +++ b/panels/lsfView/script.js @@ -2,24 +2,23 @@ var lsfViewJson = null; this.checkShowCondition = function() { var date = new Date(); - if(date.getHours()%2 == 1 && date.getMinutes() > 44){ + if(date.getHours() >= 8 && date.getHours() <= 18 && date.getHours()%2 == 1 && date.getMinutes() > 44){ + console.log("TITTEN"); return 120; } else { - return 0; //Skip Panel + return 0; //Skip Panel? } } this.show = function() { - //SomeSortOfTimingStuff } this.hide = function() { - //CleanDat } this.loaded = function(panel, config) { function lsfDataUpdate() { - $.getJSON("tmp/lsfView.json?"+( new Date().getTime()) ).done(function(json) { + $.getJSON("tmp/lsfViewEvents.json?"+( new Date().getTime()) ).done(function(json) { lsfViewJson = json; fillTable(lsfViewJson); }).fail(function(jqxhr, textStatus, error) { @@ -37,8 +36,24 @@ this.loaded = function(panel, config) { function fillTable(json) { var date = new Date(); - document.getElementById("lsfViewTitleBar").innerHTML = "Vorlesungen zwischen " + toNextRound(date.getHours()) + " und " + (toNextRound(date.getHours())+2); + var roundH = toNextRound(date.getHours()); + var lsfTableBody = document.getElementById("lsfViewTableBody"); + document.getElementById("lsfViewTitleBar").innerHTML = "Vorlesungen zwischen " + roundH + " und " + (roundH+2) + " Uhr"; + lsfTableBody.innerHTML = ""; + + for (i = 0; i < lsfViewJson.events.length; i++) { + if(lsfViewJson.events[i].StartTime.substring(0, 2) == roundH) { + var row = lsfTableBody.insertRow(-1); + var cell1 = row.insertCell(-1); + cell1.innerHTML = lsfViewJson.events[i].StartTime+"-"+lsfViewJson.events[i].EndTime; + var cell2 = row.insertCell(-1); + cell2.innerHTML = lsfViewJson.events[i].Short; + var cell3 = row.insertCell(-1); + cell3.innerHTML = lsfViewJson.events[i].Room; + } + } } + lsfDataUpdate(); } diff --git a/panels/lsfView/style.less b/panels/lsfView/style.less index 102ba6ccf25b5a9b14e81ec86dcda500b5307c67..1805585b221fbf736494db5fd5599f469eb40133 100755 --- a/panels/lsfView/style.less +++ b/panels/lsfView/style.less @@ -9,5 +9,6 @@ } #lsfViewTitleBar { + background-color: #ffffff; text-align: center; } \ No newline at end of file diff --git a/panels/lsfView/subject.php b/panels/lsfView/subject.php index 3ae7b0a37d2661c7097d246bf29469d2a0b8c41e..f0b19f8b55f4737f2b8531d7eec2174c01eba2cc 100755 --- a/panels/lsfView/subject.php +++ b/panels/lsfView/subject.php @@ -39,12 +39,11 @@ class SUBJECT { } } - //TODO public function toJson($inc_name = true, $inc_short = true) { $kommata = false; $json = ''; if($inc_name){ - $json = '"Name": "'. $this->name . '", '; + $json .= '{"Name": "'. $this->name . '", '; } if($inc_short){ $json .= '"Short": "'. $this->short . '", '; @@ -58,9 +57,32 @@ class SUBJECT { } $json .= $event->toJson (); } - $json .= ']'; + $json .= ']}'; return $json; } + + public function eventsToJson($inc_name = true, $inc_short = true) { + $kommata = false; + $json = ''; + foreach ( $this->events as $event ) { + if ($kommata) { + $json .= ','; + } else { + $kommata = true; + } + $json .= '{'; + if($inc_name){ + $json .= '"Name": "'. $this->name . '", '; + } + if($inc_short){ + $json .= '"Short": "'. $this->short . '", '; + } + $json .= $event->toInnerJson (); + $json .= '}'; + } + return $json; + } + public function __toString() { $string = "Name: " . $this->name; $string .= ", Short: ".$this->short;