Skip to content
Snippets Groups Projects
Commit eb7aabf2 authored by Tilman Vatteroth's avatar Tilman Vatteroth :robot:
Browse files

Merge branch 'dev'

parents 036585c6 ca30b69d
Branches
No related tags found
No related merge requests found
......@@ -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
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
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();
}
......@@ -9,5 +9,6 @@
}
#lsfViewTitleBar {
background-color: #ffffff;
text-align: center;
}
\ No newline at end of file
......@@ -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;
......
......@@ -7,7 +7,7 @@ this.loaded=function(panel,config) {
img = $(panel).find("#background");
titleDiv=$(panel).find("#title span");
zeitDiv=$(panel).find("#zeit span");
$.ajax("panels/ufc/semester.json",{
$.ajax("https://ufc.tu-dortmund.de/semesters/current.json",{
async:false
})
.done(function(e) {
......@@ -75,4 +75,4 @@ this.show=function() {
);
this.resize();
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment