<?php
/*
* Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
?> <?php
# Check if json.txt file needs to be generated
# 判断json.txt是否存在
# 这个文件定义了一些数据,如app的名字、图标存放的路径、
# shell脚本执行的位置及参数等等内容
if(!file_exists("json.txt"))
{
//Generate the json.txt file
# 为什么这里可以用php?,主要是没看到哪里配置了环境变量
# 答案好像是因为lighttpd配置文件里配置了php的位置
# 另外generate.php能够生成json.txt文件
system("php generate.php");
//Remove the cache since it is based on the previous json.txt file
# 删除缓冲文件
system("rm -rf cache/*");
} if(!file_exists("cache"))
{
mkdir("cache",); # 缓冲文件不存在,那么就创建它,并给出相应的权限
} $supportedResolutions = null; # 这个是保存了屏幕分辨率,以及一屏中有多少行、多少列图标
if(file_exists("supported_resolutions.txt")==true)
{
# 将文件读入一个数组中
$supportedResolutions = file ("supported_resolutions.txt",FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
} # count: 计算数组中的单元数目或对象中的属性个数,对于数组,返回其元素个数
if($supportedResolutions == null || count($supportedResolutions) == )
{
echo "supported_resolutions.txt doesn't exist or is empty";
exit;
} # SERVER_NAME: 当前运行脚本所在服务器主机的名称
# REMOTE_ADDR: 正在浏览当前页面用户的IP地址
$client_is_host = $_SERVER['SERVER_NAME']==$_SERVER['REMOTE_ADDR']||$_SERVER['SERVER_NAME'] == "localhost";
?> <html>
<head>
<title>Matrix Application Launcher</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> <!-- 添加元信息 --> <link rel="stylesheet" type="text/css" href="css/fonts-min.css"> <!-- 加载样式 -->
<script type="text/javascript" src="/javascript/jquery-latest.js"></script> <!-- 加载jquery库 -->
<link rel='stylesheet' type='text/css' href='css/global.css'> <!-- 加载样式 --> </head> <body class="unselectable" style = "-webkit-user-select: none;-moz-user-select: none;">
<div id = "complete_container"></div> <script>
var has_graphics = true;
var link_history = ["submenu.php?submenu=main_menu&page=0"]; // 创建历史记录数组
var uri = "submenu.php?submenu=main_menu&page=0"; // 当前需要加载的URI地址
var previous_clicked = uri; // 第一次之前URI的就是现在的 <?php
if($client_is_host == true)
echo "var client_is_host = true;"; # 自动生成js变量
else
echo "var client_is_host = false;";
?> $(document).ready(function() // 文档加载完毕时运行该函数
{
var supportedResolutions=new Array(); // 创建数组 <?php
# 从这里可以知道,$supportedResolutions是前面的PHP里的变量,不是这里js中的
# supportedResolutions变量,这个一定要分清楚,要不然很难理解
for($x = ;$x<count($supportedResolutions);$x++)
{
# PHP字符串连接的方式很简单,只需要一个(.)就能实现
echo "supportedResolutions[".$x."]=\"".$supportedResolutions[$x]."\";";
}
?> var screenWidth = ; // 屏幕宽
var screenHeight = ; // 屏幕高
var iconGridCol = ; // 图标格点列数
var iconGridRow = ; // 图标格点行数 // 这里大致意思是取一个合适的尺寸来分配桌面
for(var i=; i<supportedResolutions.length; i++)
{
// 是用字符串x字符将字符串切分,x在字符串里的含义是乘,如800x600x4x3
var value = supportedResolutions[i].split('x'); screenWidth = value[];
screenHeight = value[];
iconGridCol = value[];
iconGridRow = value[]; if(screen.width >= screenWidth && screen.height >= screenHeight)
break;
} document.cookie="iconGridCol="+iconGridCol; // 通过js创建cookie
document.cookie="iconGridRow="+iconGridRow; // 加载对应尺寸的css样式,这样使得显示更合理
$('head').append('<link rel="stylesheet" type="text/css" href="css/'+screenWidth+'x'+screenHeight+'.css" />');
//alert("screenHeight:"+screenWidth+"\n"+"screenWidth:"+screenHeight); // 本地的Qt程序是无法进行远程传输的,所以会有这个判断
if(client_is_host==false)
{
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.");
if (r==true)
has_graphics = true;
else
has_graphics = false;
} // var uri = "submenu.php?submenu=main_menu&page=0";
// var link_history = ["submenu.php?submenu=main_menu&page=0"];
// 加载显示的html文件,放在complete_container div中
$.get(uri, function(data)
{
$('#complete_container').html(data);
//其实这里的-2没搞清楚,不知道为什么要用这么写
$("#back_link").attr("href",link_history[link_history.length-]);
}); }); // delegate()方法为指定的元素添加一个或多个事件处理程序, // 并规定当这些事件发生时运行的函数
$("#complete_container").delegate("img", "mousedown", function(e)
{
// preventDefault()方法阻止元素发生默认的行为
// 例如: 当点击提交按钮时阻止表单的提交
e.preventDefault();
}); // 制定complete_container中的a标签的click事件的运行方式
$("#complete_container").delegate("a", "click", function(e)
{
e.preventDefault();
// 防止事件冒泡到DOM树上,也就是不触发任何前辈元素上的事件处理函数
e.stopPropagation();
var className = $(this).attr('class'); // 获取对应的属性
var idName = $(this).attr('id');
var link = $(this).attr('href'); //Sometimes if a request is taking a long time you might try clicking a link more then once thinking that
//your click request was not accepted. This causes multiple request for the same page to be sent which in turn
//sometimes results in every link you click causing 2+ request to go through. This code checks to make sure
//your requesting a new pageand not the same page twice
if(link==previous_clicked) // 防止连续点击两次,也就是避免同一个应用连续运行2次
return false; previous_clicked = link; // 将当前连接看作是上一次的链接 if(idName=="back_link") // 返回上一次链接
{
link_history.pop(); // 从堆栈中弹出最后的一次链接
}
else if(idName=="main_menu_link") // 转到主页
{
link_history = ["submenu.php?submenu=main_menu&page=0"];
}
else
link_history.push(link); // 将当前的链接加入堆栈 //Adds a random string to the end of the $_GET Query String for page accessed.
//This prevents IE from caching the Ajax request.
link = link + "&rand="+Math.round((Math.random()*))+Math.round((Math.random()*))+Math.round((Math.random()*));
$.get(link, function(data)
{
$('#complete_container').html(data); // 往div里添加另一个网页内容
$("#back_link").attr("href",link_history[link_history.length-]);
});
}); </script> </body>
</html>

Texas Instruments matrix-gui-2.0 hacking -- index.php的更多相关文章

  1. Texas Instruments matrix-gui-2.0 hacking -- submenu.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  2. Texas Instruments matrix-gui-2.0 hacking -- run_script.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  3. Texas Instruments matrix-gui-2.0 hacking -- app_description.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  4. Texas Instruments matrix-gui-2.0 hacking -- menubar.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  5. Texas Instruments matrix-gui-2.0 hacking -- generate.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  6. Texas Instruments matrix-gui-2.0 hacking -- execute_command.sh

    #!/bin/sh #Copyright (C) Texas Instruments Incorporated - http://www.ti.com/ # # # Redistribution an ...

  7. 【LeetCode每天一题】Set Matrix Zeroes(设置0矩阵)

    Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Exampl ...

  8. 答案{{index==0 ? '一' : (index==1 ? '二':'三' )}}

    答案{{index==0 ? '一' : (index==1 ? '二':'三' )}}    

  9. elasticsearch5.3.0 bulk index 性能调优实践

    elasticsearch5.3.0 bulk index 性能调优实践 通俗易懂

随机推荐

  1. ubuntu server 16.04(amd 64) 配置网桥,多网卡使用激活

    安装了Ubuntu16.04的server版本,结果进入系统输入ifconfig后发现,只有一个网卡enp1s0,还有一个网络回路lo,ifconfig -a 发现其实一共有四个网卡,enp1s0,e ...

  2. 中文名文件上传到linux服务器上以后文件名会乱码(openoffice)

    1.中文名文件上传后保存在linux服务器上文件名会乱码,但是我们通过SSH直接对服务器上的一个文件进行重命名是可以使用中文的,而且显示出来是正确的,这说明服务器是可以支持中文的. 2.而为什么上传的 ...

  3. Codeforces 861D - Polycarp's phone book

    861D - Polycarp's phone book 思路:用map做的话,只能出现一次循环,否则会超时. 代码: #include<bits/stdc++.h> using name ...

  4. 3.5 MIPS体系结构

    计算机组成 3 指令系统体系结构 3.5 MIPS体系结构 MIPS是精简指令系统的代表,采用了与X86相反的设计理念,并引领了精简指令系统的潮流,那就让我们一起来看一看这究竟是怎么一回事. 要探讨M ...

  5. 20170706pptVBA演示文稿批量删除图片

    Public Sub StartRecursionFolder() Dim Pre As Presentation Dim FolderPath As String Dim pp As String ...

  6. codeforces 568a//Primes or Palindromes?// Codeforces Round #315 (Div. 1)

    题意:求使pi(n)*q<=rub(n)*p成立的最大的n. 先收集所有的质数和回文数.质数好搜集.回文数奇回文就0-9的数字,然后在头尾添加一个数.在x前后加a,就是x*10+a+a*pow( ...

  7. android--------ExpandableListView的使用多级列表

    多级列表ExpandableListView 扩展列表能够显示一个指示在每项显示项的当前状态(状态通常是一个扩展的组,组的孩子,或倒塌,最后一个孩子).使用setchildindicator(draw ...

  8. 浅浅的分析LED呼吸灯的实现和PWM的关系

    前言 在本周,我们在python课上做了一个实验,用ARDUINO使小LED灯模仿出呼吸灯的效果,实验进行的很成功,但是机器当仅输出高/低电平的时候是怎么样才能做到渐亮渐暗(输出电压)的变化呢?在这里 ...

  9. Apache Spark探秘:利用Intellij IDEA构建开发环境

    1)准备工作 1)  安装JDK 6或者JDK 7      或者JDK8  mac 的  参看http://docs.oracle.com/javase/8/docs/technotes/guide ...

  10. .net 外部CSS文件不起作用总结

    外部css文件样式全部不起作用 asp.net 页面引用路径的问题 缺少必须属性<link rel="stylesheet" type="text/css" ...