/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php

	function menulayout($forward, $backward, $downloadlink, $heading, $headinglink, $filecontent) {
		echo "<body onload='resize();' onresize='resize();'>";
		echo "<script language=\"javascript\" src=\"../jquery/jquery-1.8.2.min.js\"></script>";

		echo "<div class='Topmenu'>";
			echo "<table style='width:100%;height:100%;border:solid 1px;'>";
				echo "<tr>";
					echo "<td class='buttonstyle'>";
						echo "<a href='http://wwwlab.iki.his.se/~gush/Webbprogrammering/' title='Back to examples page'><img src='../img/back.png'></a>";
					echo "</td>";
					
					if($backward != "") {
						echo "<td class='buttonstyle'>";
							echo "<a href='".$backward."'><img src='../img/prev.png'></a>";
						echo "</td>";
					}
					
					if($forward != "") {
						echo "<td class='buttonstyle'>";
							echo "<a href='".$forward."'><img src='../img/next.png'></a>";
						echo "</td>";
					}

					echo "<td class='verticalaligntext'>";
						echo "<a STYLE='text-decoration:none'>".$heading."</a>";
					echo "</td>";

					echo "<td class='buttonstyle'>";
						echo "<a href=\"$headinglink\"><img src='../img/play.png'></a>";
					echo "</td>";

					echo "<td class='buttonstyle'>";
						echo "<img src='../img/code.png' onclick=\"$('.lineno').toggle();$('.linenointeresting').toggle();$('.panel').toggle();\">";
					echo "</td>";

				echo "</tr>";
			echo "</table>";

		echo "</div>";

		echo "<div id='bottom' class='RestContainer'>";

		echo "<div style='float:left;'>";
		echo "<div id='panel' class='panel' onmousemove='resizepanel(event)' onmousedown='mdpanel(event)' onmouseup='mupanel(event)'>";
			include($filecontent);
		echo "</div>";
		echo "</div>";
		echo "<div class='codecontent'>";
	}

	function menulayoutend() {
		echo "</div>";
		echo "</div>";
		echo "<div style='clear:both;'></div>";
		echo "</body>";
	}

	function showfile($interestingrows, $keywords, $highlight, $filename) {
		echo "<pre>";
		$handle = @fopen($filename, "r");
		if ($handle) {
			$lineno = 1;
			while (($buffer = fgets($handle, 4096)) !== false) {
				$buffer = str_replace("\n", "", $buffer);
				$buffer = str_replace("\r", "", $buffer);
				$buffer = str_pad($buffer, 150, " ", STR_PAD_RIGHT);
				$buffer = str_replace("<", "&lt;", $buffer);
				$buffer = str_replace(">", "&gt;", $buffer);
				$buffer = str_replace("\t", "&nbsp;" , $buffer);

				$interesting = 0;
				$startspan = 0;
				foreach($interestingrows as $row) {
					if($lineno >= $row[0] && $lineno <= $row[1]){
						$interesting = true;
					}
				}

				foreach($keywords as $keyword) {
					if($interesting) {
						$buffer = str_replace($keyword, "<span class='keywordinteresting'>".$keyword."</span>", $buffer);
					} else {
						$buffer = str_replace($keyword, "<span class='keyword'>".$keyword."</span>", $buffer);
					}
				}

				$commentpos = strpos($buffer, "//");
				if(!$commentpos) {
					$commentpos = 5000;
				}
				foreach($highlight as $highlightkeyword) {
					$foundpos = strpos($buffer, $highlightkeyword[0]);
					if($foundpos <= $commentpos) {
						$buffer = str_replace($highlightkeyword[0], "<span class='".$highlightkeyword[1]."'>".$highlightkeyword[0]."</span>", $buffer);
					}
				}

				if($commentpos < 5000) {
					$buffer = str_replace("//","<span class='commented'>//", $buffer);
					$buffer .= "</span>";
				}

				$linenostr = $lineno;
				$linenostr = str_pad($linenostr, 3, " ", STR_PAD_RIGHT);

				if($interesting) {
					echo "<span class='interesting'>";
					echo "<span class='linenointeresting'>".$linenostr."</span>&nbsp;";
					$startspan = 1;
				} else {
					echo "<span class='lineno'>".$linenostr."</span>&nbsp;";				
				}

				echo $buffer;

				if($startspan) {
					echo "</span>";
				}
				$lineno++;

				echo "<br>";
			}
			if (!feof($handle)) {
				echo "Error: unexpected fgets() fail\n";
			}
			fclose($handle);
		}
		echo "</pre>";	
	}
?>