Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.22 KB | None | 0 0
  1. var eyex = null;
  2. var latestGazePoint;
  3. var _isUserPresent = false;
  4. var numberOfLooks = 0;
  5.  
  6. /** Initializes hotkeys and the eyex object which gives access to the Tobii EyeX API for Overwolf. */
  7. function init() {
  8. setWindowSize();
  9. setWindowPosition();
  10. }
  11.  
  12. function setWindowSize(){
  13. overwolf.windows.changeSize ("map", 350, 261);
  14. overwolf.windows.changeSize ("cooldowns", 420, 150);
  15. overwolf.windows.changeSize ("health", 220, 150);
  16. overwolf.windows.changeSize ("time", 500, 150);
  17. }
  18.  
  19. function setWindowPosition(){
  20. overwolf.windows.changePosition("time", 693, 0);
  21. overwolf.windows.changePosition("MainWindow", 0, 0);
  22. }
  23.  
  24. function openMap(){
  25. overwolf.windows.obtainDeclaredWindow("map",
  26. function(result) {
  27. if (result.status == "success") {
  28. overwolf.windows.restore(result.window.id,
  29. function(result) {}
  30. );
  31. }
  32. }
  33. );
  34. }
  35.  
  36. function openCooldowns(){
  37. overwolf.windows.obtainDeclaredWindow("cooldowns",
  38. function(result) {
  39. if (result.status == "success") {
  40. overwolf.windows.restore(result.window.id,
  41. function(result) {}
  42. );
  43. }
  44. }
  45. );
  46. }
  47.  
  48.  
  49. function openHealth(){
  50. overwolf.windows.obtainDeclaredWindow("health",
  51. function(result) {
  52. if (result.status == "success") {
  53. overwolf.windows.restore(result.window.id,
  54. function(result) {}
  55. );
  56. }
  57. }
  58. );
  59. }
  60.  
  61. function openTime(){
  62. overwolf.windows.obtainDeclaredWindow("time",
  63. function(result) {
  64. if (result.status == "success") {
  65. overwolf.windows.restore(result.window.id,
  66. function(result) {}
  67. );
  68. }
  69. }
  70. );
  71. }
  72.  
  73. function closeTime(){
  74. overwolf.windows.obtainDeclaredWindow("time",
  75. function(result){
  76. if (result.status=="success"){
  77. overwolf.windows.close(result.window.id);
  78. }
  79. });
  80. };
  81.  
  82. function closeHealth(){
  83. overwolf.windows.obtainDeclaredWindow("health",
  84. function(result){
  85. if (result.status=="success"){
  86. overwolf.windows.close(result.window.id);
  87. }
  88. });
  89. };
  90.  
  91. function closeCooldowns(){
  92. overwolf.windows.obtainDeclaredWindow("cooldowns",
  93. function(result){
  94. if (result.status=="success"){
  95. overwolf.windows.close(result.window.id);
  96. }
  97. });
  98. };
  99.  
  100. function closeMap(){
  101. overwolf.windows.obtainDeclaredWindow("map",
  102. function(result){
  103. if (result.status=="success"){
  104. overwolf.windows.close(result.window.id);
  105. }
  106. });
  107. };
  108.  
  109. function openWindows(){
  110. openMap();
  111. openCooldowns();
  112. openHealth();
  113. openTime();
  114. }
  115.  
  116. function closeWindows(){
  117. closeMap();
  118. closeTime();
  119. closeCooldowns();
  120. closeHealth();
  121. }
  122.  
  123. window.addEventListener("load", init);
  124.  
  125. var eyex = null;
  126. var latestGazePoint;
  127. var _isUserPresent = false;
  128. var numberOfLooks = 0;
  129. var maplooks = 1;
  130. var cooldownslooks = 1;
  131. var healthlooks = 1;
  132. var timelooks = 1;
  133. var isGazePointinHotspot = false;
  134.  
  135. function init() {
  136. overwolf.extensions.current.getExtraObject("eyex", function(result) {
  137. if (result.status == "success") {
  138. eyex = result.object;
  139. eyex.onGazePoint.addListener(onGazePoint);
  140. eyex.init();
  141. }
  142. });
  143. };
  144.  
  145. var status = 0; //0:stop 1:running
  146. var time = 0;
  147.  
  148. function start() {
  149. status = 1;
  150. timer();
  151. }
  152.  
  153. function stop() {
  154. status = 0;
  155. }
  156.  
  157. function reset() {
  158. status = 0;
  159. time = 0;
  160. document.getElementById('timerLabel').innerHTML = '00:00:00';
  161. }
  162.  
  163. function timer() {
  164. if (status == 1) {
  165. setTimeout(function() {
  166. time++;
  167. var min = Math.floor(time / 100 / 60);
  168. var sec = Math.floor(time / 100);
  169. var mSec = time % 100;
  170.  
  171. if (min < 10) {
  172. min = "0" + min;
  173. }
  174. if (sec >= 60) {
  175. sec = sec % 60;
  176. }
  177. if (sec < 10) {
  178. sec = "0" + sec;
  179. }
  180.  
  181. document.getElementById('timerLabel').innerHTML = min + ":" + sec + ":" + mSec;
  182. timer();
  183. }, 10);
  184. }
  185. }
  186.  
  187. function onGazePoint(gazePoint) {
  188. latestGazePoint = gazePoint;
  189.  
  190. overwolf.windows.getCurrentWindow(function(result) {
  191. if (result.status == "success") {
  192. if (isGazePointWithinWindow(result.window, gazePoint)) {
  193. var hotspotNum = document.getElementById('content').getAttribute('data-value');
  194. var hotspot = 0;
  195. switch (hotspotNum) {
  196. case '1':
  197. if (isGazePointinHotspot == false) {
  198. document.getElementById("numberOfLooks").innerHTML = maplooks++;
  199. isGazePointinHotspot = true;
  200. document.getElementById("content").style.opacity = "0.2";
  201. start();
  202. }
  203. break;
  204. case '2':
  205. if (isGazePointinHotspot == false) {
  206. document.getElementById("numberOfLooks").innerHTML = healthlooks++;
  207. document.getElementById("content").style.opacity = "0.2";
  208. isGazePointinHotspot = true;
  209. start();
  210. }
  211. break;
  212. case '3':
  213. if (isGazePointinHotspot == false) {
  214. document.getElementById("numberOfLooks").innerHTML = cooldownslooks++;
  215. isGazePointinHotspot = true;
  216. document.getElementById("content").style.opacity = "0.2";
  217. start();
  218. }
  219. break;
  220. case '4':
  221. if (isGazePointinHotspot == false) {
  222. document.getElementById("numberOfLooks").innerHTML = timelooks++;
  223. isGazePointinHotspot = true;
  224. document.getElementById("content").style.opacity = "0.2";
  225. start();
  226. }
  227. break;
  228. }
  229. } else {
  230. document.getElementById("content").style.opacity = "0.7";
  231. isGazePointinHotspot = false;
  232. stop();
  233. };
  234. }
  235. });
  236. }
  237.  
  238. function numberOfLooks(gazePoint) {
  239. latestGazePoint = gazePoint;
  240. var hotspot = document.getElementById('content');
  241. overwolf.windows.getCurrentWindow(function(result) {
  242. if (result.status == "success") {
  243. if (isGazePointWithinWindow(result.window, gazePoint)) {
  244.  
  245. } else {
  246.  
  247. };
  248. }
  249. });
  250. }
  251.  
  252.  
  253.  
  254. function isGazePointWithinWindow(window, gazePoint) {
  255. if ((gazePoint.X > window.left) && (gazePoint.X < (window.left + window.width)) && (gazePoint.Y > window.top) && (gazePoint.Y < (window.top + window.height))) {
  256. return true;
  257. } else {
  258. return false;
  259.  
  260. }
  261. }
  262.  
  263. window.addEventListener("load", init);
  264.  
  265. <head>
  266. <link rel="stylesheet" href="css/style.css" />
  267. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  268. <title>Tobii EyeX Interaction Demo</title>
  269. <script type="text/javascript" src="js/main.js"></script>
  270.  
  271.  
  272. </script>
  273. </head>
  274.  
  275. <body>
  276. <div id="main">
  277. <img class="logo" src="../hots.png" alt="hotslogo">
  278. <input type="image" src="../play.png" alt="Start" width="40" height="auto" onclick="openWindows()">
  279. <input type="image" src="../stop.png" alt="Stop" width="40" height="auto" onclick="closeWindows()">
  280. </div>
  281. </body>
  282.  
  283. <head>
  284. <link rel="stylesheet" href="../css/style.css" />
  285. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  286. <title>Tobii EyeX Interaction Demo</title>
  287. <script type="text/javascript" src="../js/hotspot.js"></script>
  288. </head>
  289.  
  290. <body>
  291. <div id="content" class="hotspot" data-value="1">
  292. <h1>Map</h1>
  293. <p>Number of looks: <span id="numberOfLooks"> </span> </p>
  294. <p>Time: <span id="timerLabel">00:00:00</span></p>
  295.  
  296. </div>
  297. </body>
  298.  
  299. {
  300. "manifest_version":1,
  301. "type":"WebApp",
  302. "meta":{
  303. "name":"xxxx",
  304. "version":"1.0.1",
  305. "minimum-overwolf-version":"0.81.14",
  306. "author":"xxxx",
  307. "icon":"xxxx",
  308. "icon_gray":"xxxx",
  309. "description":"xxxx"
  310. },
  311. "permissions": [
  312. "Extensions"
  313. ],
  314. "data": {
  315. "start_window":"MainWindow",
  316. "windows":{
  317. "MainWindow":{
  318. "file":"Files/index.html",
  319. "transparent":true,
  320. "resizable":false,
  321. "show_in_taskbar":true,
  322. "start_position":{"top":0, "left":0},
  323. "size":{"width":440, "height":330},
  324. "min_size":{"width":200, "height":200},
  325. "max_size":{"width":1000, "height":1000}
  326. },
  327. "map":{
  328. "file":"Files/html/map.html",
  329. "transparent":true,
  330. "resizable":false,
  331. "show_in_taskbar":false,
  332. /*"clickthrough":true,
  333. "start_position":{"top":806, "left":1550}, */
  334. "size":{"width":350, "height":261}
  335. },
  336. "cooldowns":{
  337. "file":"Files/html/cooldowns.html",
  338. "transparent":true,
  339. "resizable":false,
  340. "show_in_taskbar":false,
  341. /*"clickthrough":true,
  342. "start_position":{"top":984, "left":747}, */
  343. "size":{"width":420, "height":50}
  344. },
  345. "health":{
  346. "file":"Files/html/health.html",
  347. "transparent":true,
  348. "resizable":false,
  349. "show_in_taskbar":false,
  350. /*"clickthrough":true,
  351. "start_position":{"top":971, "left":196}, */
  352. "size":{"width":220, "height":100}
  353. },
  354. "time":{
  355. "file":"Files/html/time.html",
  356. "transparent":true,
  357. "resizable":false,
  358. "show_in_taskbar":false,
  359. /*"clickthrough":true,
  360. "start_position":{"top":0, "left":693}, */
  361. "size":{"width":500, "height":40}
  362. }
  363. },
  364. "extra-objects":{
  365. "eyex": {
  366. "file" : "plugins/OverwolfTobii.dll",
  367. "class" : "Overwolf.Tobii.TobiiHelper"
  368. }
  369. }
  370. }
  371. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement