2 * Copyright (c) 2012, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 var isrotated = false;
12 /* string and various helper functions */
13 String.prototype.startsWith = function (str) {
15 return this.indexOf(str) === 0;
21 var piratesGame, rocketsGame, bowlingGame,
22 menushown = false, restart, close;
24 function closeMenu() {
25 $("#game_menu").removeClass("slide");
26 $("#game_menu_border").css("pointer-events", "none");
27 setTimeout(function () {menushown = false;}, 400);
31 $("#game_menu").addClass("slide");
32 $("#game_menu_border").css("pointer-events", "auto");
33 setTimeout(function () {menushown = true;}, 400);
36 /* need to set isrotated so we can swap x/y axis for touch events */
39 if($(window).width() > $(window).height())
47 license_init("license", "home_page");
48 help_init("home_help", "help_");
50 if (window.chrome&&window.chrome.i18n)
52 $("#home_pirates_text").html(chrome.i18n.getMessage("pirates_title"));
53 $("#home_rockets_text").html(chrome.i18n.getMessage("rockets_title"));
54 $("#home_bowling_text").html(chrome.i18n.getMessage("bowling_title"));
57 var touchToMouse = function(event) {
58 if (event.touches.length > 1) return;
59 var touch = event.changedTouches[0];
76 var simulatedEvent = document.createEvent("MouseEvent");
77 simulatedEvent.initMouseEvent(type, true, true, window, 1,
78 touch.screenX, touch.screenY,
79 touch.clientX, touch.clientY, false,
80 false, false, false, 0, null);
82 touch.target.dispatchEvent(simulatedEvent);
84 window.ontouchstart = touchToMouse;
85 window.ontouchmove = touchToMouse;
86 window.ontouchend = touchToMouse;
88 piratesGame = new Pirates();
89 $("#home_pirates").click(function() {
91 restart = piratesGame.start;
92 close = piratesGame.close;
93 $("#game_menu_border").show();
96 rocketsGame = new Rockets();
97 $("#home_rockets").click(function() {
99 restart = rocketsGame.start;
100 close = rocketsGame.close;
101 $("#game_menu_border").show();
104 bowlingGame = new Bowling();
105 $("#home_bowling").click(function() {
107 restart = bowlingGame.start;
108 close = bowlingGame.close;
109 $("#game_menu_border").show();
112 $("#game_menu").click(function(){
119 $("#game_menu_tab").click(function(){
126 $("#game_menu_new").click(function(){
131 $("#game_menu_home").click(function(){
136 $(window).bind('resize', resize);
143 window.addEventListener('load', function () {
145 var main = new TenFrame();