changeset 48:d41b51cd4ae5

Implement switchable CSS support and a new default style + very minor code cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Oct 2012 14:02:24 +0300
parents ceca06576918
children 16aea8e5cb71
files index.php luk.css luk1.css luk2.css
diffstat 4 files changed, 395 insertions(+), 208 deletions(-) [+]
line wrap: on
line diff
--- a/index.php	Sat Oct 13 12:01:08 2012 +0300
+++ b/index.php	Wed Oct 17 14:02:24 2012 +0300
@@ -1,20 +1,20 @@
-<?php
+ <?php
 //
 // Yes, this is horrible. :|
 //
-$pageCSS = array("luk.css");
 $pageCharset = "utf-8";
 $internalCharset = "utf-8";
 $luokkaDefault = "TTE9SNO";
 $classFile = "luokat.txt";
-$mapFile = "kartta.png";
-$roomFile = "luokkatilat.txt";
 $cacheFile = "coursecache.txt";
 $baseURI = "http://tnsp.org/luk/";
 //$infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&opas=2010-2011&vuosi=10S11K&koodi1=";
 $infoURI = "http://www.oamk.fi/opiskelijalle/rakenne/opinto-opas/koulutusohjelmat/?sivu=oj&kieli=FI&koodi1=";
 $dayNames = array("Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai", "Sunnuntai");
 
+$pageCSSData = array("cookie" => "lukcss", "prefix" => $baseURI."luk");
+$altCSS = array("blue" => "1", "old" => "2");
+
 $hourStamps = array(
   array( 8, 15),
   array( 9, 15),
@@ -100,13 +100,6 @@
 }
 
 
-function lukMatchClass($matches)
-{
-  global $baseURI;
-  return "<b><a href=\"".$baseURI."?tila=".$matches[1]."\">".$matches[1]."</a></b> ".$matches[2];
-}
-
-
 // Check for mini-info mode
 $miniMode = isset($_GET["nyt"]);
 
@@ -126,18 +119,6 @@
 }
 
 
-if (isset($_GET["tila"])) {
-  $tila = $_GET["tila"];
-  echo "Luokkatilan n&auml;ytt&ouml;moodi ei viel&auml; tuettu.<br />\n";
-  exit;
-
-  $fp = @fopen($roomFile, "rb");
-  if ($fp) {
-    fclose($fp);
-  }
-}
-
-
 if (isset($_GET["next"])) {
   $nextPeriod = TRUE;
   $dataFile = "cache-next/".$luokka.".data";
@@ -191,16 +172,6 @@
 }
 
 
-function lukPrintHourInfo($dayHours, $showDays)
-{
-  $out = " <tr>\n  <td>Tunteja<br />(<b>ryhmä/vv</b>)</td>\n";
-  for ($day = 0; $day < $showDays; $day++) {
-    $out .=  "  <td>".$dayHours[$day]["total"]."h (<b>".$dayHours[$day]["grouped"]."h</b>)</td>\n";
-  }
-  return $out." </tr>\n";
-}
-
-
 function lukResolveHours($start, $day, $cmp, $mark = FALSE)
 {
   global $classHourTable, $classInfo;
@@ -405,8 +376,7 @@
     $out .= " </tr>\n";
   }
 
-  $out .= lukPrintHourInfo($dayHours, $classInfo["maxdays"]).
-  "</table>\n";
+  $out .= "</table>\n";
 
 } // haveData
 
@@ -414,8 +384,6 @@
 $pageTitle = $haveData ? $luokka." / ".join("; ", $classInfo["info"]) : $luokka;
 printPageHeader($pageTitle);
 
-if ($miniMode) echo "<div id=\"mini\">\n";
-
 echo
 "<form id=\"controls\" action=\"".$baseURI."\" method=\"get\">
  <table>
@@ -459,12 +427,16 @@
 
 echo $out;
 
-echo "<div style=\"position: relative; top: 5em; font-size: 5pt;\"><hr />
+echo "<div id=\"footer\">
 Yhteydenotot <b>ccr @ IRCNet</b> tai <b>ccr at tnsp dot org</b>. En vastaa mahdollisista virheistä tiedoissa!
 </div>
+<div id=\"csssel\">
+Style: ";
+foreach ($altCSS as $name => $id)
+  echo "<a href=\"?css=".$id."\">".$name."</a>";
+echo "
+</div>
 ";
-
-if ($miniMode) echo "</div>\n";
 printPageFooter();
 
 
--- a/luk.css	Sat Oct 13 12:01:08 2012 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-body {
-	margin: 1em;
-	background-color: black;
-	color: white;
-
-	font-family: Verdana, Arial, helvetica, sans-serif;
-	font-size: 10pt;
-}
-
-a, a:visited, a:active {
-	text-decoration: underline;
-	color: white;
-}
-
-a:hover {
-	text-decoration: underline;
-	color: #555;
-}
-
-.noborder {
-	border: none;
-	padding: 0pt;
-}
-
-.icenter {
-	text-align: center;
-}
-
-h1, h2, h3 {
-	font-family: Arial, sans-serif;
-	font-weight: normal;
-	color: #eee;
-	background: #888;
-	padding: 4px;
-	padding-bottom: 8px;
-	text-shadow: 2px 2px 2px #000;
-}
-
-
-table {
-	border: 0px;
-	padding: 0px;
-	margin: 0px;
-}
-
-tr {
-	border: 0px;
-	padding: 0px;
-	margin: 0px;
-}
-
-table.timetable th {
-	padding: 2px;
-	margin: 2px;
-	background: #444;
-	text-align: center;
-}
-
-td {
-	padding: 4px;
-	margin: 2px;
-	background: #555;
-	color: #ccc;
-}
-
-table.timetable {
-	font-size: 10pt;
-}
-
-table.timetable td > a, table.timetable td > a:visited, table.timetable td > a:active {
-	text-decoration: none;
-	text-shadow: 2px 2px 2px #000;
-	color: #fff;
-}
-
-table.timetable td > a:hover {
-	color: yellow;
-}
-
-
-th.hours {
-	white-space: nowrap;
-}
-
-table.timetable * table {
-	width: 100%;
-	height: 100%;
-}
-
-table.timetable tr:hover th {
-	color: red;
-}
-
-td.clgrouped, td.clgrouped * td {
-	background: #454;
-}
-
-td.clnothing {
-	background: #222;
-}
-
-td.clnormal {
-}
-
-div.nhours {
-	text-align: right;
-}
-
-div.nhours span {
-	background: black;
-	padding: 2pt;
-	border: 1px solid gray;
-}
-
-
-
-#controls {
-	padding: 0px;
-	margin: 0px;
-}
-
-#controls table * {
-	padding: 0px;
-	margin: 0px;
-}
-
-#controls a {
-	padding: 3pt;
-	margin-bottom: 30pt;
-	border: 1px solid white;
-	-moz-border-radius: 8px;
-	border-radius: 8px;
-	text-decoration: none;
-	color: white;
-	background: #657;
-}
-
-#controls a:hover {
-	background: white;
-	color: black;
-}
-
-#controls select {
-	background: white;
-	border: 1px solid black;
-
-	padding: 5pt;
-	-moz-border-radius: 8px;
-	border-radius: 8px;
-}
-
-#controls input.submit {
-	color: white;
-	background: #686;
-	border: 1px solid white;
-
-	padding: 5pt;
-	-moz-border-radius: 8px;
-	border-radius: 8px;
-}
-
-#controls input.submit:hover {
-	background: white;
-	color: black;
-}
-
-#mini {
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/luk1.css	Wed Oct 17 14:02:24 2012 +0300
@@ -0,0 +1,202 @@
+body {
+	margin: 1em;
+	background: black;
+	color: white;
+
+	font-family: Verdana, Arial, helvetica, sans-serif;
+	font-size: 10pt;
+}
+
+a, a:visited, a:active {
+	text-decoration: underline;
+	color: white;
+}
+
+a:hover {
+	text-decoration: underline;
+	color: #555;
+}
+
+h1, h2, h3 {
+	font-family: Arial, sans-serif;
+//	font-family: impact;
+	font-weight: normal;
+	color: white;
+	background: rgb(10,114,133);
+	padding: 5pt;
+	padding-bottom: 8px;
+	text-shadow: 2px 2px 2px #000;
+	-moz-border-radius: 8pt;
+	border-radius: 8pt;
+}
+
+#csssel {
+	position: absolute;
+	right: 1em;
+	top: 1em;
+	font-size: 5pt;
+	background: rgb(10,114,133);
+	padding: 5pt;
+	-moz-border-radius: 5pt;
+	border-radius: 5pt;
+}
+
+#csssel a {
+	padding: 2pt;
+	color: #ccc;
+	text-decoration: none;
+}
+
+#csssel a:hover {
+	text-decoration: underline;
+}
+
+#contents {
+	z-index: 5;
+	position: absolute;
+	right: 0.5em;
+	left: 0.5em;
+	background: rgba(10,114,133,0.6);
+	padding: 10pt;
+	-moz-border-radius: 10pt;
+	border-radius: 10pt;
+	text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
+}
+
+
+table {
+	border: 0px;
+	padding: 0px;
+	margin: 0px;
+}
+
+tr {
+	border: 0px;
+	padding: 0px;
+	margin: 0px;
+}
+
+table.timetable th {
+	padding: 2px;
+	margin: 2px;
+	background: #444;
+	text-align: center;
+
+	background: rgba(10,114,133,0.6);
+	color: #ccc;
+	-moz-border-radius: 5pt;
+	border-radius: 5pt;
+}
+
+td {
+	padding: 4px;
+	margin: 2px;
+	background: rgba(0,84,103,0.7);
+	color: #ccc;
+	-moz-border-radius: 5pt;
+	border-radius: 5pt;
+}
+
+table.timetable {
+	font-size: 10pt;
+}
+
+table.timetable td > a, table.timetable td > a:visited, table.timetable td > a:active {
+	text-decoration: none;
+	text-shadow: 2px 2px 2px #000;
+	color: #fff;
+}
+
+table.timetable td > a:hover {
+	color: yellow;
+}
+
+
+th.hours {
+	white-space: nowrap;
+}
+
+table.timetable * table {
+	width: 100%;
+	height: 100%;
+}
+
+table.timetable tr:hover th {
+	color: red;
+}
+
+td.clgrouped, td.clgrouped * td {
+	background: rgb(63,80,63);
+}
+
+td.clnothing {
+	background: rgb(0,84,103);
+}
+
+td.clnormal {
+}
+
+div.nhours {
+	text-align: right;
+}
+
+div.nhours span {
+	background: black;
+	padding: 2pt;
+	border: 1px solid gray;
+}
+
+#footer {
+	padding-top: 5pt;
+	font-size: 5pt;
+}
+
+#controls {
+	padding: 0px;
+	margin: 0px;
+}
+
+#controls table * {
+	padding: 0px;
+	margin: 0px;
+}
+
+#controls a {
+	padding: 5pt;
+	margin-bottom: 30pt;
+//	border: 1px solid rgba(10,114,133,0.3);
+	-moz-border-radius: 8px;
+	border-radius: 8px;
+	text-decoration: none;
+	color: white;
+	background: rgba(255,255,255,0.2);
+}
+
+#controls a:hover {
+	color: white;
+	background: rgba(255,255,255,0.5);
+}
+
+#controls select {
+	background: white;
+	border: 1px solid black;
+
+	padding: 5pt;
+	-moz-border-radius: 8px;
+	border-radius: 8px;
+}
+
+#controls input.submit {
+	color: white;
+	background: rgba(200,255,200,0.2);
+	border: 1px solid rgba(255,255,255,0.3);
+
+	padding: 5pt;
+	-moz-border-radius: 8px;
+	border-radius: 8px;
+}
+
+#controls input.submit:hover {
+	color: white;
+	background: rgba(200,255,200,0.5);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/luk2.css	Wed Oct 17 14:02:24 2012 +0300
@@ -0,0 +1,181 @@
+body {
+	margin: 1em;
+	background-color: black;
+	color: white;
+
+	font-family: Verdana, Arial, helvetica, sans-serif;
+	font-size: 10pt;
+}
+
+a, a:visited, a:active {
+	text-decoration: underline;
+	color: white;
+}
+
+a:hover {
+	text-decoration: underline;
+	color: #555;
+}
+
+h1, h2, h3 {
+	font-family: Arial, sans-serif;
+	font-weight: normal;
+	color: #eee;
+	background: #888;
+	padding: 4px;
+	padding-bottom: 8px;
+	text-shadow: 2px 2px 2px #000;
+}
+
+
+#csssel {
+	position: absolute;
+	right: 1em;
+	top: 1em;
+	font-size: 5pt;
+	background: rgb(10,114,133);
+	padding: 5pt;
+	-moz-border-radius: 5pt;
+	border-radius: 5pt;
+}
+
+#csssel a {
+	padding: 2pt;
+	color: #ccc;
+	text-decoration: none;
+}
+
+#csssel a:hover {
+	text-decoration: underline;
+}
+
+
+table {
+	border: 0px;
+	padding: 0px;
+	margin: 0px;
+}
+
+tr {
+	border: 0px;
+	padding: 0px;
+	margin: 0px;
+}
+
+table.timetable th {
+	padding: 2px;
+	margin: 2px;
+	background: #444;
+	text-align: center;
+}
+
+td {
+	padding: 4px;
+	margin: 2px;
+	background: #555;
+	color: #ccc;
+}
+
+table.timetable {
+	font-size: 10pt;
+}
+
+table.timetable td > a, table.timetable td > a:visited, table.timetable td > a:active {
+	text-decoration: none;
+	text-shadow: 2px 2px 2px #000;
+	color: #fff;
+}
+
+table.timetable td > a:hover {
+	color: yellow;
+}
+
+
+th.hours {
+	white-space: nowrap;
+}
+
+table.timetable * table {
+	width: 100%;
+	height: 100%;
+}
+
+table.timetable tr:hover th {
+	color: red;
+}
+
+td.clgrouped, td.clgrouped * td {
+	background: #454;
+}
+
+td.clnothing {
+	background: #222;
+}
+
+td.clnormal {
+}
+
+div.nhours {
+	text-align: right;
+}
+
+div.nhours span {
+	background: black;
+	padding: 2pt;
+	border: 1px solid gray;
+}
+
+#footer {
+	padding-top: 5pt;
+	font-size: 5pt;
+}
+
+#controls {
+	padding: 0px;
+	margin: 0px;
+}
+
+#controls table * {
+	padding: 0px;
+	margin: 0px;
+}
+
+#controls a {
+	padding: 3pt;
+	margin-bottom: 30pt;
+	border: 1px solid white;
+	-moz-border-radius: 8px;
+	border-radius: 8px;
+	text-decoration: none;
+	color: white;
+	background: #657;
+}
+
+#controls a:hover {
+	background: white;
+	color: black;
+}
+
+#controls select {
+	background: white;
+	border: 1px solid black;
+
+	padding: 5pt;
+	-moz-border-radius: 8px;
+	border-radius: 8px;
+}
+
+#controls input.submit {
+	color: white;
+	background: #686;
+	border: 1px solid white;
+
+	padding: 5pt;
+	-moz-border-radius: 8px;
+	border-radius: 8px;
+}
+
+#controls input.submit:hover {
+	background: white;
+	color: black;
+}