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 phoneNumberTextTemplate = {"font" : "bold 40pt Arial", "lineWidth" : 2.5, "fillStyle" : "black", "strokeStyle" : "white", "textAlign" : "center", "textBaseline" : "middle",
11 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 32, "shadowColor" : "rgba(0,100,150, 0.6)"};
13 var sideTextTemplate = {"font" : "bold 40pt Arial", "lineWidth" : 2.5, "fillStyle" : "grey", "strokeStyle" : "white", "textAlign" : "center", "textBaseline" : "middle",
14 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 52, "shadowColor" : "rgba(0, 0, 110, 1.0)", "wordWrap" : true};
16 var errorTextTemplate = {"font" : "bold 50px Arial", "lineWidth" : 2.5, "fillStyle" : "red", "strokeStyle" : "rgba(150, 0, 0, 1.0)", "textAlign" : "center", "textBaseline" : "middle",
17 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 52, "shadowColor" : "rgba(0, 0, 0, 1.0)", "wordWrap" : true};
23 if (dialNumber.length === 10)
25 var number = mainPage.getObj("textArea").textObj.text
26 number = number.slice(0,3) + '-' + number.slice(3,6) + '-' + number.slice(6,10);
27 mainPage.getObj("textArea").textObj.text = number;
30 mainPage.getObj("textArea").textObj.text = dialNumber;
33 function addButtonGrid (gridX, gridY, gridWidth, gridHeight)
36 var iconWidth = ((gridWidth - (spacer * 4)) / 3);
37 var iconHeight = ((gridHeight - (spacer * 6)) / 5);
39 var iconXPosition = gridX + spacer;
40 var iconYPosition = gridY + spacer;
41 var firstIconXPosition = iconXPosition;
45 for (var i = 0; i < 12; i++)
63 buttonText = buttonNum.toString();
65 var button = mainPage.addObject(buttonCtx, "button", {"name" : buttonText, "image": images.numberButton, "text" : buttonText, "textTemplate" : buttonTextTemplate, "xLoc" : iconXPosition,
66 "yLoc" : iconYPosition, "width" : iconWidth, "height" : iconHeight} );
68 button.onClick = function(){
69 this.img = images.numberButtonActive;
70 dialNumber += this.name;
71 mainPage.getObj("textArea").textObj.text += this.name;
76 button.onRelease = function() {
77 this.img = images.numberButton;
81 iconXPosition += (iconWidth + spacer);
83 if ((i + 1) % 3 === 0)
85 iconYPosition += (iconHeight + spacer);
86 iconXPosition = firstIconXPosition;
93 button = mainPage.addObject(buttonCtx, "button", {"name" : "del", "image": images.deleteButton, "icon": images.deleteIcon, "iconWidth" : iconHeight * 0.9, "iconHeight" : iconHeight * 0.9,
94 "xLoc" : iconXPosition, "yLoc" : iconYPosition, "width" : iconWidth, "height" : iconHeight} );
95 iconXPosition += (iconWidth + spacer);
96 button.onClick = function(){
97 this.img = images.deleteButtonActive;
98 this.holdTimeOut = setTimeout(function() {dialNumber = ""; mainPage.getObj("textArea").textObj.text = ""; mainPage.drawMenu();}, 600);
99 dialNumber = dialNumber.slice(0,-1);
100 mainPage.getObj("textArea").textObj.text = mainPage.getObj("textArea").textObj.text.slice(0,-1);
105 button.onRelease = function() {
106 clearTimeout(this.holdTimeOut);
107 this.img = images.deleteButton;
112 button = mainPage.addObject(buttonCtx, "button", {"name" : "call", "image": images.callButton, "icon": images.callIcon, "iconWidth" : iconHeight * 0.9, "iconHeight" : iconHeight * 0.9,
113 "xLoc" : iconXPosition, "yLoc" : iconYPosition, "width" : iconWidth * 2 + spacer, "height" : iconHeight} );
115 button.onClick = function(){
116 this.img = images.callButtonActive;
118 activeService.makeCall(dialNumber);
120 console.log("Attempting to make call without an available modem");
123 initCallPage("dialing");
124 updateNumber(dialNumber);
125 updateCallStateText("Dialing...");
126 //switchMenu(callPage);
128 currentState = "dialing";
131 button.onRelease = function() {
132 this.img = images.callButton;
137 function initMainPage()
140 var textAreaHeight = screenHeight / 4;
141 var buttonPadWidth = screenWidth - (spacer * 2);// * 0.75;
142 var buttonPadHeight = screenHeight - textAreaHeight - 60;
143 errorTextTemplate.font = "bold " + ((screenHeight * 0.6) / 6) + "px Arial";
145 addButtonGrid(20, textAreaHeight + 40, buttonPadWidth, buttonPadHeight);
146 mainPage.addObject(mainCtx, "image", {"name" : "textArea", "image": images.textArea, "text" : "", "textTemplate" : phoneNumberTextTemplate, "xLoc" : 20, "yLoc" : 20, "width" : buttonPadWidth, "height" : textAreaHeight} );
148 mainPage.addObject(mainCtx, "image", {"name" : "buttonBG","image": images.buttonBG, "xLoc" : 20, "yLoc" : textAreaHeight + 40, "width" : buttonPadWidth, "height" : buttonPadHeight} );
150 // var myobj = mainPage.addObject(mainCtx, "shape", {"name" : "optionsBG", "xLoc" : 40 + buttonPadWidth, "yLoc" : 0, "width" : (screenWidth * 0.25) - 60, "height" : screenHeight,
151 // "fillStyle" : "#51504F", "strokeStyle" : "#373736", "lineWidth" : 5});
153 // var myobj = mainPage.addObject(mainCtx, "shape", {"name" : "optionsBG", "xLoc" : 40 + buttonPadWidth, "yLoc" : 0, "width" : (screenWidth * 0.25) - 60, "height" : screenHeight,
154 // "fillStyle" : "#51504F", "strokeStyle" : "#373736", "lineWidth" : 5});
156 /************************************** Lock Screen Objects *************************************/
158 var fog = mainPage.addObject(mouseCtx, "shape", {"name" : "fog", "xLoc" : 0, "yLoc" : 0, "zLoc" : 3, "width" : screenWidth,
159 "height" : screenHeight, "fillStyle" : "rgba(100,100,100,0.7)", "visible" : noModems});
161 var textBox = mainPage.addObject(mouseCtx, "shape", {"name" : "textBox", "rounded" : true, "xLoc" : screenWidth * 0.1, "yLoc" : screenHeight * 0.2, "zLoc" : 4, "width" : screenWidth * 0.8,
162 "height" : screenHeight * 0.6, "fillStyle" : "white", "strokeStyle" : "#85322A", "lineWidth" : 35, "visible" : noModems, "text" : "No modems available!", "textTemplate" : errorTextTemplate});