-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathttt.js
More file actions
71 lines (58 loc) · 1.58 KB
/
ttt.js
File metadata and controls
71 lines (58 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var turn = 0;
/*
var imageName="";
var pictureSource; // picture source
var destinationType; // sets the format of returned value
var counter = 0;
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
*/
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
function toggleBox(name) {
var box = document.getElementById(name);
if(endsWith(box.src, "blank.png")) {
if(turn == 0) {
box.src = "x.png";
turn = 1;
} else {
box.src = "o.png";
turn = 0;
}
}
}
function clearGame() {
turn = 0;
for(var i=1; i < 10; i++) {
var box = document.getElementById("box" + i);
box.src = "blank.png";
}
navigator.vibrate(3000);
alert('Game Over!');
}
/*
function changePhoto(name) {
imageName = name;
//alert('Changing Photo');
// Take picture using device camera and retrieve image as base64-encoded string
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.DATA_URL });
}
function onFail(message) {
alert('Failed because: ' + message);
}
function onPhotoDataSuccess(imageData) {
// Get image handle
//
var smallImage = document.getElementById(imageName);
// Unhide image elements
//
//smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
//
smallImage.src = "data:image/jpeg;base64," + imageData;}
*/