xref: /OK3568_Linux_fs/buildroot/board/rockchip/rk3566_rk3568/fs-overlay/usr/share/matrix-gui-2.0/index.php (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1<?php
2/*
3 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 *
6 *  Redistribution and use in source and binary forms, with or without
7 *  modification, are permitted provided that the following conditions
8 *  are met:
9 *
10 *    Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 *
13 *    Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the
16 *    distribution.
17 *
18 *    Neither the name of Texas Instruments Incorporated nor the names of
19 *    its contributors may be used to endorse or promote products derived
20 *    from this software without specific prior written permission.
21 *
22 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34*/
35?>
36
37<?php
38	# Check if json.txt file needs to be generated
39	if(!file_exists("json.txt") || filesize("json.txt") == 0)
40	{
41		//Generate the json.txt file
42		system("php generate.php");
43		//Remove the cache since it is based on the previous json.txt file
44		system("rm -rf cache/*");
45	}
46
47	if(!file_exists("cache"))
48	{
49		mkdir("cache",6666);
50	}
51
52	$supportedResolutions = null;
53
54
55	if(file_exists("supported_resolutions.txt")==true)
56	{
57		$supportedResolutions = file ("supported_resolutions.txt",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
58
59	}
60
61	if($supportedResolutions == null || count($supportedResolutions) == 0)
62	{
63		echo "supported_resolutions.txt doesn't exist or is empty";
64		exit;
65	}
66
67	$client_is_host = $_SERVER['SERVER_NAME']==$_SERVER['REMOTE_ADDR']||$_SERVER['SERVER_NAME'] == "localhost";
68?>
69
70<html>
71<head>
72<title>Matrix Application Launcher</title>
73<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
74
75<link rel="stylesheet" type="text/css" href="css/fonts-min.css">
76<script type="text/javascript" src="/javascript/jquery-latest.js"></script>
77<link rel='stylesheet' type='text/css' href='css/global.css'>
78
79</head>
80
81
82<body class="unselectable" style = "-webkit-user-select: none;-moz-user-select: none;">
83<div id = "complete_container"></div>
84
85<script>
86var has_graphics = true;
87var link_history = ["submenu.php?submenu=main_menu&page=0"];
88var uri = "submenu.php?submenu=main_menu&page=0";
89var previous_clicked = uri;
90
91<?php
92if($client_is_host == true)
93	echo "var client_is_host = true;";
94else
95	echo "var client_is_host = false;";
96?>
97
98$(document).ready(function()
99{
100
101
102
103	var supportedResolutions=new Array();
104
105	<?php
106		for($x = 0;$x<count($supportedResolutions);$x++)
107		{
108			echo "supportedResolutions[".$x."]=\"".$supportedResolutions[$x]."\";";
109		}
110	?>
111
112	var screenWidth = 0;
113	var screenHeight = 0;
114	var iconGridCol = 0;
115	var iconGridRow = 0;
116
117	for(var i=0; i<supportedResolutions.length; i++)
118	{
119		var value = supportedResolutions[i].split('x');
120
121		screenWidth = value[0];
122		screenHeight = value[1];
123		iconGridCol = value[2];
124		iconGridRow = value[3];
125
126		if(screen.width >= screenWidth && screen.height >= screenHeight)
127			break;
128	}
129
130	document.cookie="iconGridCol="+iconGridCol;
131	document.cookie="iconGridRow="+iconGridRow;
132
133	$('head').append('<link rel="stylesheet" type="text/css" href="/css/'+screenWidth+'x'+screenHeight+'.css" />');
134
135	if(client_is_host==false)
136	{
137		var r=confirm("Does your target system have an attached display device?\nClick Ok and Remote Matrix will assume that a proper display device is attached to your target system.\nClick Cancel and Remote Matrix will assume that you do not have a display device attached to your target system.");
138		if (r==true)
139			has_graphics = true;
140		else
141			has_graphics = false;
142	}
143
144	$.get(uri, function(data)
145	{
146				$('#complete_container').html(data);
147				$("#back_link").attr("href",link_history[link_history.length-2]);
148	});
149
150
151});
152
153
154
155
156
157
158
159$("#complete_container").delegate("img", "mousedown", function(e)
160{
161       e.preventDefault();
162});
163
164$("#complete_container").delegate("a", "click", function(e)
165{
166	e.preventDefault();
167	e.stopPropagation();
168	var className = $(this).attr('class');
169	var idName = $(this).attr('id');
170	var link =  $(this).attr('href');
171
172	//Sometimes if a request is taking a long time you might try clicking a link more then once thinking that
173	//your click request was not accepted. This causes multiple request for the same page to be sent which in turn
174	//sometimes results in every link you click causing 2+ request to go through. This code checks to make sure
175	//your requesting a new pageand not the same page twice
176	if(link==previous_clicked)
177		return false;
178
179	previous_clicked = link;
180
181	if(idName=="back_link")
182	{
183		link_history.pop();
184	}
185	else if(idName=="main_menu_link")
186	{
187		link_history = ["submenu.php?submenu=main_menu&page=0"];
188	}
189	else
190		link_history.push(link);
191
192	//Adds a random string to the end of the $_GET Query String for page accessed.
193	//This prevents IE from caching the Ajax request.
194	link = link + "&rand="+Math.round((Math.random()*2356))+Math.round((Math.random()*4321))+Math.round((Math.random()*3961));
195	$.get(link, function(data)
196	{
197		$('#complete_container').html(data);
198		$("#back_link").attr("href",link_history[link_history.length-2]);
199	});
200});
201
202</script>
203
204	</body>
205</html>
206
207