-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomputer.html
More file actions
384 lines (321 loc) · 10.4 KB
/
computer.html
File metadata and controls
384 lines (321 loc) · 10.4 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!DOCTYPE html>
<html>
<head>
<title>‎</title> <link rel="icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="resources/style.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="resources/script.js"></script>
<script type="text/javascript">
var printSound = new Sound('sounds/Printer.mp3',1);
var correctSound = new Sound('sounds/PasswordCorrect.mp3',1);
var incorrectSound = new Sound('sounds/PasswordIncorrect.mp3',1);
var cantPrintSound = new Sound('sounds/Interaction2.mp3',1);
function checkPaper()
{
if(!sessionStorage.printed)
{
if(!sessionStorage.loadedPaper)
{
//Play error sound
cantPrintSound.play();
}
else
{
//Play printing sound
sessionStorage.printed = "1";
printSound.play();
}
}
else
{
cantPrintSound.play();
//play error sound
}
}
function checkPassword()
{
var correctPass = "Jenny";
var pass = document.getElementById("hiddeninput").value;
if(pass.localeCompare(correctPass) == 0)
{
console.log("Correct password!")
correctSound.play();
sessionStorage.enteredPassword = "1";
hide_inline_view();
remove_clicker("clicker_computer");
show_inline_view("inlines/Monitor.png", function(){
var printButton = $("<div style='top:85px'; left:'100px'; width:'60px'; height:'60px';><button type='button' id='printButton' onclick='checkPaper()'>Print</button></div>");
$('#inline-clickers').append(printButton);
});
addPrintButton();
}
else
{
console.log("Incorrect password!")
incorrectSound.play();
}
}
function addPrintButton()
{
console.log("Add print button");
add_clicker(200,200,100,100,"clicker_computer_print", "clickers/puzzleroom_e/Computer.png", function(){
show_inline_view("inlines/Monitor.png", function(){
var printButton = $("<div style='top:85px'; left:'100px'; width:'60px'; height:'60px';><button type='button' id='printButton' onclick='checkPaper()'>Print</button></div>");
$('#inline-clickers').append(printButton);
});
});
}
</script>
<script>
$(document).ready(function(){
// change this to change the background image
// the dimensions should be 720px X 405px.
// ======================
picture_set("rooms/sampleroom.png");
// ======================
// clickerinos kids
// =====================================================
// very simple example: you can't go through the door unless you
// pick up the key on the table.
if(!sessionStorage.enteredPassword)
sessionStorage.enteredPassword = "0";
console.log(sessionStorage.enteredPassword);
if(sessionStorage.enteredPassword.localeCompare("0") == 0)
{
add_clicker(200,200,100,100,"clicker_computer", "clickers/puzzleroom_e/Computer.png", function(){
currentOrder = [];
show_inline_view("inlines/Monitor.png", function(){
//container.appendChild(input);
add_inline_text_form(85,60,60,60,"password","textBox",function(){
console.log("you clicked password");
var textBox = document.getElementById('hiddeninput');
//console.log(textBox.value);
});
var submitButton = $("<div style='top:85px'; left:'60px'; width:'60px'; height:'60px';><button type='button' id='submitButton' onclick='checkPassword()'>Submit</button></div>");
add_clicker(200,200,100,100,"clicker_computer", "clickers/puzzleroom_e/Computer.png", function(){
//Phone button sounds
phoneSound_1 = new Sound("sounds/Phone1.mp3",1)
phoneSound_2 = new Sound("sounds/Phone2.mp3",1)
phoneSound_3 = new Sound("sounds/Phone3.mp3",1)
phoneSound_4 = new Sound("sounds/Phone4.mp3",1)
phoneSound_5 = new Sound("sounds/Phone5.mp3",1)
phoneSound_6 = new Sound("sounds/Phone6.mp3",1)
phoneSound_7 = new Sound("sounds/Phone7.mp3",1)
phoneSound_8 = new Sound("sounds/Phone8.mp3",1)
phoneSound_9 = new Sound("sounds/Phone9.mp3",1)
phoneSound_0 = new Sound("sounds/Phone0.mp3",1)
//phoneSound_star = new Sound("sounds/PhoneStar.mp3")
phoneSound_pound = new Sound("sounds/PhonePound.mp3")
//Phone interaction sounds
phoneSound_dialtone = new Sound("sounds/PhoneTone.mp3", 1)
if(!enteredCorrect)
{
//if(phoneSound_dialtone.paused)
phoneSound_dialtone.playLooping();
}
else
{
playSoundsInOrder();
}
currentOrder = [];
show_inline_view("inlines/cordless_feature_big_buttons.png", function(){
var input = document.createElement("input");
input.type = "text";
input.className = "css-class-name"; // set the CSS class
//container.appendChild(input);
add_inline_clicker(85,60,60,60,"phone_1","",function(){
console.log("you clicked phone_1");
stopSound(phoneSound_dialtone);
checkOrder(1);
if(!phoneSound_1.paused)
phoneSound_1.currentTime = 0;
phoneSound_1.play();
//submitButton.setAttribute("onclick", checkPassword);
//console.log(document.getElementById("submitButton"));
//document.getElementById("submitButton").addEventListener("click",checkPassword);
$('#inline-clickers').append(submitButton);
});
});
}
else
{
addPrintButton();
}
});
// =====================================================
// set where clicking on the side links makes you go
nav_left("");
nav_right("shablammy.html");
nav_up("");
nav_down("");
//http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript
if(Array.prototype.equals)
console.warn("Overriding existing Array.prototype.equals. Possible causes: New API defines the method, there's a framework conflict or you've got double inclusions in your code.");
// attach the .equals method to Array's prototype to call it on any array
Array.prototype.equals = function (array)
{
// if the other array is a falsy value, return
if (!array)
return false;
// compare lengths - can save a lot of time
if (this.length != array.length)
return false;
for (var i = 0, l=this.length; i < l; i++)
{
// Check if we have nested arrays
if (this[i] instanceof Array && array[i] instanceof Array)
{
// recurse into the nested arrays
if (!this[i].equals(array[i]))
return false;
}
else if (this[i] != array[i])
{
// Warning - two different object instances will never be equal: {x:20} != {x:20}
return false;
}
}
return true;
};
// Hide method from for-in loops
Object.defineProperty(Array.prototype, "equals", {enumerable: false});
function stopSound(snd)
{
if(!snd.paused)
{
snd.pause();
snd = 0;
}
};
function playSoundsInOrder()
{
console.log("play sounds in order");
delay = 0;
delayStep = 1000;
for(i = 0; i < correctSounds.length; i++)
{
setTimeout(function()
{
playSound(soundIndex);
soundIndex++;
if(soundIndex >= correctSounds.length)
{
soundIndex = 0;
//setTimeout( playSoundsInOrder, delayAfterCorrect);
}
}, delay);
delay += delayStep;
}
//correctSounds[0].addEventListener("ended",playNext[0]);
//correctSounds[0].play();
//whatever is your audio element
//var container = phoneSound_dialtone;
//var sound = new Audio();
//this.Sound.src = "sounds/PhoneTone.mp3";
//play files in a row
//new Mp3Queue(sound, correctSounds);
};
function playSound(index)
{
console.log(index);
currentSound = new Sound(correctSounds[index], 1);
currentSound.play();
};
function playNext(index)
{
i = index + 1;
console.log("play next");
if(i < correctSounds.length)
{
correctSounds[i].addEventListener("ended",playNext(i));
//correctSounds[i].play();
}
};
function checkOrder(pressed)
{
if(!enteredCorrect)
{
currentOrder.push(pressed);
//If order is long enough check if right or wrong
if(currentOrder.length > correctOrder.length)
{
currentOrder.shift();
if(currentOrder.equals(correctOrder))
{
console.log("correct");
setTimeout( playSoundsInOrder, delayAfterCorrect);
//playSoundsInOrder();
enteredCorrect = true;
}
/*
else
{
console.log("incorrect");
if(phoneSound_dialtone.paused)
phoneSound_dialtone.playLooping();
currentOrder = [];
}
*/
}
else if(currentOrder.length == correctOrder.length)
{
if(currentOrder.equals(correctOrder))
{
console.log("correct");
setTimeout(playSoundsInOrder, delayAfterCorrect);
//playSoundsInOrder();
enteredCorrect = true;
}
}
console.log(currentOrder);
}
};
//http://stackoverflow.com/questions/16916896/playing-two-files-in-a-row-in-javascript
var Mp3Queue = function(container, files) {
console.log("play sounds");
var index = 1;
if(!container || !container.tagName || container.tagName !== 'AUDIO')throw 'Invalid container';
if(!files || !files.length)throw 'Invalid files array';
var playNext = function() {
if(index < files.length) {
container.src = files[index];
index += 1;
} else {
container.removeEventListener('ended', playNext, false);
}
};
container.addEventListener('ended', playNext);
container.src = files[0];
};
});
</script>
<script src="resources/postscript.js"></script>
</head>
<body>
<div class="inline-dismisser"></div>
<div id="wrapper">
<div id="picture"></div>
<div id="navclicks">
<div class="navclick" id="click-up"></div>
<div class="navclick" id="click-down"></div>
<div class="navclick" id="click-left"></div>
<div class="navclick" id="click-right"></div>
</div>
<div id="clickers">
<!-- in here, there go all the custom clicky boxes for items and stuff -->
<!-- this is handled with the javascript so DON'T PUT ANYTHING HERE. -->
<!-- ================================================================= -->
<!-- <div class="clicker" style="width:40px;height:40px;top:150px;left:400px;"></div> -->
<!-- ================================================================= -->
</div>
<div class="inline-dismisser"></div>
<div id="inline">
<div id="inline-clickers">
<!-- in here, go even more clickers for each inline view. -->
</div>
</div>
<div id="inventory"></div>
<div id="subtitle"></div>
</div>
</body>
</html>