Mercurial > hg > lukkari
diff index.php @ 83:85068c8513b4
Add back mobile mode.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Oct 2012 13:58:00 +0300 |
parents | c553ad61e9c2 |
children | adaad33f929c |
line wrap: on
line diff
--- a/index.php Wed Oct 24 12:24:48 2012 +0300 +++ b/index.php Wed Oct 24 13:58:00 2012 +0300 @@ -237,7 +237,23 @@ // Check given parameters -$mobileMode = isset($_GET["mobile"]) || isset($_COOKIE["lukmobile"]); +$mobileMode = FALSE; +if (isset($_GET["m"])) +{ + $mobileMode = intval($_GET["m"]); + setcookie("lukmobile", $mobileMode, time() + 365*24*60*60); // expire in a year +} +else +if (isset($_COOKIE["lukmobile"])) +{ + $mobileMode = $_COOKIE["lukmobile"]; +} + +if ($mobileMode) +{ + $pageCSSData["prefix"] = $baseURI."mluk"; +} + if (isset($_GET["luokka"])) { @@ -351,7 +367,7 @@ } -function lukNormalTimeTable() +function lukPrintTimeTable($mini) { global $classInfo, $classHourDefs, $classHourTimes; @@ -362,27 +378,43 @@ $nextStamp = $currStamp + 30 * 60; $nextTime = $nextStamp - mktime(0, 0, 0); - $nextDay = lukGetWeekdayFromTimestamp($nextStamp); // Create the timetable table - $out = - "<p>".join("; ", $classInfo["general"])."</p>\n". - "<div>".lukMsg("viikossa", $classInfo["totalHours"])."</div>\n". - "<table class=\"timetable\">". - " <tr>\n <th></th>\n"; - $cellWidth = 100 / $classInfo["maxDays"]; - if ($cellWidth > 25) $cellWidth = 25; - for ($day = 0; $day < $classInfo["maxDays"]; $day++) + if ($mini) + { + $out = + "<table class=\"timetable\">". + " <tr>\n <th></th>". + " <th class=\"days\">".lukGetDayName($currDay)."</th>\n </tr>\n"; + + $startDay = $currDay; + $lastDay = $currDay + 1; + } + else { - $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".lukGetDayName($day)."</th>\n"; + $out = + "<p>".join("; ", $classInfo["general"])."</p>\n". + "<div>".lukMsg("viikossa", $classInfo["totalHours"])."</div>\n". + "<table class=\"timetable\">". + " <tr>\n <th></th>\n"; + $cellWidth = 100 / $classInfo["maxDays"]; + if ($cellWidth > 25) $cellWidth = 25; + + for ($day = 0; $day < $classInfo["maxDays"]; $day++) + { + $out .= " <th style=\"width: ".$cellWidth."%;\" class=\"days\">".lukGetDayName($day)."</th>\n"; + } + $out .= " </tr>\n"; + $startDay = 0; + $lastDay = $classInfo["maxDays"]; } - $out .= " </tr>\n"; + for ($hour = $classInfo["firstHour"]; $hour < $classInfo["lastHour"]; $hour++) { $out .= " <tr>\n". " <th class=\"hours\">".lukGetHourStr($hour)."</th>\n"; - for ($day = 0; $day < $classInfo["maxDays"]; $day++) + for ($day = $startDay; $day < $lastDay; $day++) { $id = lukFindClass($day, $hour); if ($id > 0) @@ -392,7 +424,7 @@ { $class["set"] = TRUE; - $nextActive = $day == $nextDay && + $nextActive = $day == $currDay && $nextTime >= $classHourTimes[$class["start"]]["start"] && $nextTime < $classHourTimes[$class["start"] + $class["hours"] - 1]["end"]; @@ -440,12 +472,20 @@ " </select> </th> <th><input class=\"submit\" type=\"submit\" value=\"".lukMsg("Switch")."\" /></th> - <th><a href=\"".$origBaseURI.$luokka.$origBaseExt."\">".lukMsg("Original")."</a></th> +"; - <th><a href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">". +if (!$mobileMode) +{ +echo " + <th><a id=\"next\" class=\"textctrl\" href=\"".$baseURI.($nextPeriod ? "" : "?next")."\">". ($nextPeriod ? lukMsg("Current period") : lukMsg("Next period"))."</a></th> + <th><a id=\"orig\" class=\"textctrl\" href=\"".$origBaseURI.$luokka.$origBaseExt."\">".lukMsg("Original")."</a></th> + <th><a id=\"xml\" class=\"textctrl\" href=\"".$baseURI.$cachePath."/".$luokka.".xml\">XML</a></th> +"; +} - <th><a href=\"".$baseURI.($nextPeriod ? "cache-next" : "cache")."/".$luokka.".xml\">XML</a></th> +echo " + <th><a id=\"mobile\" class=\"imgctrl\" href=\"".$baseURI."?m=".($mobileMode ? 0 : 1)."\"><img src=\"img/mobile-white.png\" alt=\"Mobile\"></a></th> </tr> </table> </form> @@ -464,7 +504,7 @@ if ($haveData) { - echo lukNormalTimeTable(); + echo lukPrintTimeTable($mobileMode); } echo