Skip to content
Snippets Groups Projects
Commit 1a6328e2 authored by Hotte's avatar Hotte
Browse files

working view

parent c73a789a
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,11 @@ $SUBJECT_LIST_WS = array ( ...@@ -25,7 +25,11 @@ $SUBJECT_LIST_WS = array (
); );
// JSON // JSON
$JSON_NAME = "../../tmp/lsfView.json"; $JSON_NAME_SUBJECTS = "../../tmp/lsfViewSubjects.json";
$JSON_INC_NAME = true; $JSON_INC_NAME_SUBJECTS = true;
$JSON_INC_SHORT = 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
...@@ -45,6 +45,14 @@ class EVENT { ...@@ -45,6 +45,14 @@ class EVENT {
return $json; 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() { public function __toString() {
return "Day: " . $this->day . ", StartTime: " . $this->startTime . ", EndTime: ". $this->endTime . ", Room: ".$this->room; return "Day: " . $this->day . ", StartTime: " . $this->startTime . ", EndTime: ". $this->endTime . ", Room: ".$this->room;
} }
......
...@@ -7,10 +7,9 @@ function booleanToString($bool) { ...@@ -7,10 +7,9 @@ function booleanToString($bool) {
} }
} }
//TODO: function toJsonSubjects($subjects, $jsonName, $inc_name = true, $inc_short = true) {
function toJson($subjects, $jsonName, $inc_name = true, $inc_short = true) {
$kommata = false; $kommata = false;
$json = '{'; $json = '{"subjects": [';
foreach ( $subjects as $subject ) { foreach ( $subjects as $subject ) {
if ($kommata) { if ($kommata) {
$json .= ','; $json .= ',';
...@@ -19,14 +18,27 @@ function toJson($subjects, $jsonName, $inc_name = true, $inc_short = true) { ...@@ -19,14 +18,27 @@ function toJson($subjects, $jsonName, $inc_name = true, $inc_short = true) {
} }
$json .= $subject->toJson ( $inc_name, $inc_short); $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 ); file_put_contents ( $jsonName , $json );
} }
function parsSubject($html,$subject) { function parsSubject($html,$subject) {
echo "Parsing " . $subject->getSearchName() . "\n"; 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('table[summary="Übersicht über alle Veranstaltungstermine"]',0);
$html = $html->find('tr'); $html = $html->find('tr');
array_shift($html); array_shift($html);
......
...@@ -88,6 +88,6 @@ foreach ( $SUBJECT_LIST as $SUBJECT ) { ...@@ -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
...@@ -2,24 +2,23 @@ var lsfViewJson = null; ...@@ -2,24 +2,23 @@ var lsfViewJson = null;
this.checkShowCondition = function() { this.checkShowCondition = function() {
var date = new Date(); 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; return 120;
} else { } else {
return 0; //Skip Panel return 0; //Skip Panel?
} }
} }
this.show = function() { this.show = function() {
//SomeSortOfTimingStuff
} }
this.hide = function() { this.hide = function() {
//CleanDat
} }
this.loaded = function(panel, config) { this.loaded = function(panel, config) {
function lsfDataUpdate() { function lsfDataUpdate() {
$.getJSON("tmp/lsfView.json?"+( new Date().getTime()) ).done(function(json) { $.getJSON("tmp/lsfViewEvents.json?"+( new Date().getTime()) ).done(function(json) {
lsfViewJson = json; lsfViewJson = json;
fillTable(lsfViewJson); fillTable(lsfViewJson);
}).fail(function(jqxhr, textStatus, error) { }).fail(function(jqxhr, textStatus, error) {
...@@ -37,8 +36,24 @@ this.loaded = function(panel, config) { ...@@ -37,8 +36,24 @@ this.loaded = function(panel, config) {
function fillTable(json) { function fillTable(json) {
var date = new Date(); 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(); lsfDataUpdate();
} }
...@@ -9,5 +9,6 @@ ...@@ -9,5 +9,6 @@
} }
#lsfViewTitleBar { #lsfViewTitleBar {
background-color: #ffffff;
text-align: center; text-align: center;
} }
\ No newline at end of file
...@@ -39,12 +39,11 @@ class SUBJECT { ...@@ -39,12 +39,11 @@ class SUBJECT {
} }
} }
//TODO
public function toJson($inc_name = true, $inc_short = true) { public function toJson($inc_name = true, $inc_short = true) {
$kommata = false; $kommata = false;
$json = ''; $json = '';
if($inc_name){ if($inc_name){
$json = '"Name": "'. $this->name . '", '; $json .= '{"Name": "'. $this->name . '", ';
} }
if($inc_short){ if($inc_short){
$json .= '"Short": "'. $this->short . '", '; $json .= '"Short": "'. $this->short . '", ';
...@@ -58,9 +57,32 @@ class SUBJECT { ...@@ -58,9 +57,32 @@ class SUBJECT {
} }
$json .= $event->toJson (); $json .= $event->toJson ();
} }
$json .= ']'; $json .= ']}';
return $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() { public function __toString() {
$string = "Name: " . $this->name; $string = "Name: " . $this->name;
$string .= ", Short: ".$this->short; $string .= ", Short: ".$this->short;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment