Best JavaScript code snippet using cypress
content-2.srt.js
Source:content-2.srt.js
100:00:00,000 --> 00:00:19,2202/* CAUTION : Each sections of subtitle has independent scope. */3/* Ver1.0 */4doOnce[index] = true;5player.pauseVideo();6//7const myApp = {8 path : {9 answer : "https://raw.githubusercontent.com/t-yokota/quizBattle/master/contents/lamy_abc_12th/answer-2.csv",10 sound : "https://raw.githubusercontent.com/t-yokota/quizBattle/master/sounds/sounds_3", //+ext;11 btn1 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_1.png",12 btn2 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_2.png",13 btn3 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_3.png",14 btn4 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_4.png",15 },16 state : {17 ButtonCheck : 0, //ãã¿ã³ãã§ãã¯å¾
æ©18 Question : 1, //åãèªã¿ä¸ï¼æ©æ¼ãå¯è½ï¼19 MyAnswer : 2, //èªåã解ç権ãææï¼è§£çå
¥åã»éä¿¡å¯è½ï¼20 OthAnswer : 3, //ä»è
ã解ç権ãææï¼æ©æ¼ãä¸å¯è½ï¼21 Talk : 4, //ãã®ä»22 },23 videoState : {24 Playing : 1,25 Stopped : 2,26 },27 elem : {28 text : document.createElement("text"),29 subText : document.createElement("text"),30 ansCol : document.createElement("textarea"),31 ansBtn : document.createElement("button"),32 numOX : document.createElement("text"),33 pushBtn : document.createElement("img"),34 imgBtn1 : document.createElement("img"),35 imgBtn2 : document.createElement("img"),36 imgBtn3 : document.createElement("img"),37 imgBtn4 : document.createElement("img"),38 sounds : document.createElement("audio"),39 paramText : document.createElement("text"),40 //41 divUI : document.createElement('div'),42 divElem : document.createElement('div'),43 divBtn : document.createElement('div'),44 },45 val : {46 srtFuncArray : null, //array of functions that are executed in each subtitle47 viewFuncArray : null, //array of functions for setting view elements48 //49 os : null,50 browser : null,51 //52 touchObject : null,53 //54 audioExt : null,55 audioSpriteData : null,56 //57 loadCount : 0,58 initLoadBool : false,59 loadErrorBool : false,60 loadAlertBool : false,61 //62 initOrientation : null,63 orientationAlertBool : false,64 //65 playingCount : 0,66 pageHiddenBool : false,67 processDelayAlertBool : false,68 //69 composingBool : false,70 //71 disableSeekbarBool : false,72 //73 playerWidth : 0,74 playerHeight : 0,75 pushBtnWidth : 0,76 pushBtnHeight : 0,77 //78 prevPlayerWidth : 0,79 prevPlayerHeight : 0,80 prevClientWidth : 0,81 prevClientHeight : 0,82 //83 elemHeight : 0,84 //85 pushBtnArea : {86 left : 0,87 right : 0,88 top : 0,89 bottom : 0,90 },91 //92 divUIHeight : 0,93 divUIWidth : 0,94 divElemWidth : 0,95 divBtnWidth : 0,96 //97 hidePlayerBool : {98 phone : false,99 other : false,100 },101 //102 /* keycode (for keyboard) */103 space : 32, //push buttion104 enter : 13,105 //106 /* button check param */107 btnCheck : {108 sndInterval : 1500, //[ms]109 playInterval : 3000, //[ms]110 },111 //112 /* for question manegament */113 numQues : 1, //åé¡çªå·114 ansArray : [], //æ£çãªã¹ã115 cntO : 0, //æ£çæ°116 cntX : 0, //誤çæ°117 cntPush : 0, //1åãããã®è§£çåæ°118 limPush : 1, //1åãããã®ä¸é解çåæ°119 correctBool : false, //çãåããçµæ(çµæã«å¿ãã¦ç¶æ
é·ç§»)120 ansFile : new XMLHttpRequest(), //æ£çãã¡ã¤ã«.csv121 //122 /* for status management */123 status : null,124 cntIndex : 0, //(index value has current section of subtitle)125 //126 /* for time management */127 ansTime : {128 limit : 20000, //解çå¶éæé[ms]129 elapsed : 0, //解ççµéæé[ms]130 },131 currTime : {132 playing : 0, //be updated during the video is playing133 stopped : 0, //be updated when the video is stopped134 },135 watchedTime : 0, //136 diffTime : 0, //difference between watchedTime and currentTime (for preventing to jump playback position by seekbar)137 //138 ansIndex: 0,139 ansIndexStartTime : 0,140 jumpToAnsBool: false,141 //142 firstQuesStartTime : 0,143 },144};145//146/* get os type */147myApp.val.os = fetchOSType();148myApp.val.browser = fetchBrowserType();149//150/* set id to the elements */151myApp.elem.ansCol.id = 'anscol';152myApp.elem.ansBtn.id = 'ansbtn';153myApp.elem.pushBtn.id = 'pushbtn';154myApp.elem.divUI.id = 'divui';155myApp.elem.divElem.id = 'divelem';156myApp.elem.divBtn.id = 'divbtn';157//158/* set init value to the elements */159myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";160myApp.elem.ansBtn.innerHTML = "ï¼åç®ã¾ã§ç§»å";161myApp.elem.ansCol.disabled = true;162myApp.elem.ansBtn.disabled = true;163myApp.elem.numOX.innerHTML = "âï¸ï¼"+myApp.val.cntO+"ãâï¼"+myApp.val.cntX;164//165if(myApp.val.os != 'other'){166 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";167}else{168 myApp.elem.text.innerHTML = "QuizBattle on YouTube";169 /* set tabindex for adding focus */170 myApp.elem.pushBtn.tabIndex = 0;171}172//173/* set initial state (button check) */174myApp.val.status = myApp.state.ButtonCheck;175//176/* VIEW */177resizePlayer();178//179/* set style sheets */180document.styleSheets.item(0).insertRule('html { touch-action: manipulation; }'); //disable double tap gesture181document.styleSheets.item(0).insertRule('body { text-align: center; margin: auto; background: #EFEFEF; }');182document.styleSheets.item(0).insertRule('.blinkImg { animation: blinkImg 0.7s infinite alternate; }');183document.styleSheets.item(0).insertRule('@keyframes blinkImg{ 0% { opacity: 0.3; } 100% { opacity: 1; }}');184document.styleSheets.item(0).insertRule('.blinkText { animation: blinkText 0.7s infinite alternate; }');185document.styleSheets.item(0).insertRule('@keyframes blinkText{ 0% { opacity: 0; } 100% { opacity: 1; }}');186//187/* set elements */188if(myApp.val.os != 'other'){189 myApp.elem.text.style.fontSize = '42px';190 myApp.elem.text.style.lineHeight = '60px';191 myApp.elem.text.style.fontWeight = 'bold';192 myApp.elem.text.style.display = 'block';193 myApp.elem.text.style.marginTop = '32px';194 myApp.elem.text.style.marginBottom = '32px';195 myApp.elem.text.style.padding = '0px 10px';196 myApp.elem.subText.style.fontSize = '42px';197 myApp.elem.subText.style.lineHeight = '60px';198 myApp.elem.subText.style.display = 'block';199 myApp.elem.ansCol.style.fontSize = '50px';200 myApp.elem.ansCol.style.height = '100px';201 myApp.elem.ansCol.style.textAlign = 'center';202 myApp.elem.ansCol.style.marginBottom = '10px';203 myApp.elem.ansCol.style.marginLeft = 'auto';204 myApp.elem.ansCol.style.marginRight = 'auto';205 myApp.elem.ansCol.style.display = 'block'206 myApp.elem.ansBtn.style.fontSize = '42px';207 myApp.elem.ansBtn.style.width = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*10+'px';208 myApp.elem.ansBtn.style.height = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*2+'px';209 myApp.elem.ansBtn.style.marginBottom = '20px';210 myApp.elem.ansBtn.style.marginLeft = 'auto';211 myApp.elem.ansBtn.style.marginRight = 'auto';212 myApp.elem.ansBtn.style.display = 'block';213 myApp.elem.numOX.style.fontSize = '42px';214 myApp.elem.numOX.style.lineHeight = '80px';215 myApp.elem.numOX.style.fontWeight = 'bold';216 myApp.elem.numOX.style.display = 'block';217 //218 myApp.val.elemHeight = (function(e){219 let res = 0;220 res += parseInt(e.text.style.lineHeight, 10);221 res += parseInt(e.text.style.marginTop, 10);222 res += parseInt(e.text.style.marginBottom, 10);223 res += parseInt(e.ansCol.style.height, 10);224 res += parseInt(e.ansCol.style.marginBottom, 10);225 res += parseInt(e.ansBtn.style.height, 10);226 res += parseInt(e.ansBtn.style.marginBottom, 10);227 res += parseInt(e.numOX.style.lineHeight, 10);228 return res229 })(myApp.elem);230 //231 myApp.val.viewFuncArray = [232 function(){233 document.getElementsByTagName("body")[0].appendChild(myApp.elem.text);234 document.getElementsByTagName("body")[0].appendChild(myApp.elem.ansBtn);235 document.getElementsByTagName("body")[0].appendChild(myApp.elem.pushBtn);236 document.getElementsByTagName("body")[0].appendChild(myApp.elem.numOX);237 document.getElementsByTagName("body")[0].appendChild(myApp.elem.paramText);238 },239 function(){240 myApp.elem.text.style.marginTop = '40px';241 myApp.elem.text.style.marginBottom = '20px';242 myApp.elem.subText.style.marginBottom = '40px';243 myApp.elem.subText.style.padding = '0px 10px';244 document.getElementsByTagName("body")[0].insertBefore(myApp.elem.subText, myApp.elem.text.nextSibling);245 },246 function(){247 myApp.elem.text.style.marginTop = '32px';248 myApp.elem.text.style.marginBottom = '32px';249 myApp.elem.text.parentNode.removeChild(myApp.elem.subText);250 document.getElementsByTagName("body")[0].insertBefore(myApp.elem.ansCol, myApp.elem.text.nextSibling);251 },252 ];253 myApp.val.viewFuncArray.shift()();254}else{255 myApp.val.divUIHeight = myApp.val.playerHeight*0.9;256 myApp.val.divUIWidth = myApp.val.playerWidth;257 myApp.val.divElemWidth = myApp.val.playerWidth*2/3;258 myApp.val.divBtnWidth = myApp.val.playerWidth*1/3;259 document.styleSheets.item(0).insertRule('body { width:'+myApp.val.playerWidth+'px; }');260 document.styleSheets.item(0).insertRule('div#divui { width:'+myApp.val.divUIWidth +'px; height:'+myApp.val.divUIHeight+'px; }');261 document.styleSheets.item(0).insertRule('div#divelem { width:'+myApp.val.divElemWidth+'px; height:'+myApp.val.divUIHeight+'px; float: left; display: flex; align-items: center; justify-content: center; flex-direction: column; }');262 document.styleSheets.item(0).insertRule('div#divbtn { width:'+myApp.val.divBtnWidth +'px; height:'+myApp.val.divUIHeight+'px; float: left; display: flex; align-items: center; justify-content: center; }');263 document.getElementsByTagName("body")[0].appendChild(myApp.elem.divUI);264 myApp.elem.divUI.appendChild(myApp.elem.divElem); //divElem is assigned to ('div')[4]265 myApp.elem.divUI.appendChild(myApp.elem.divBtn); //divBtn is assigned to ('div')[5]266 //267 myApp.elem.text.style.fontSize = '25px';268 myApp.elem.text.style.lineHeight = '45px';269 myApp.elem.text.style.fontWeight = 'bold';270 myApp.elem.text.style.display = 'block';271 myApp.elem.subText.style.fontSize = '20px';272 myApp.elem.subText.style.lineHeight = '30px';273 myApp.elem.subText.style.display = 'block';274 myApp.elem.ansCol.style.fontSize = '23px';275 myApp.elem.ansCol.style.textAlign = 'center';276 myApp.elem.ansCol.style.width = myApp.val.divElemWidth*0.75+'px';277 myApp.elem.ansCol.style.margin = '0px ' +(myApp.val.divElemWidth-parseInt(myApp.elem.ansCol.style.width, 10))/2+'px 15px';278 myApp.elem.ansBtn.style.fontSize = '23px';279 myApp.elem.ansBtn.style.width = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*8+'px';280 myApp.elem.ansBtn.style.margin = '0px '+(myApp.val.divElemWidth-parseInt(myApp.elem.ansBtn.style.width, 10))/2+'px 20px';281 myApp.elem.numOX.style.fontSize = '25px';282 myApp.elem.numOX.style.lineHeight = '45px';283 myApp.elem.numOX.style.fontWeight = 'bold';284 myApp.elem.numOX.style.display = 'block';285 //286 myApp.val.viewFuncArray = [287 function(){288 myApp.elem.text.style.margin = '0px auto';289 myApp.elem.text.style.padding = '0px 40px';290 document.getElementsByTagName("div")[4].appendChild(myApp.elem.text);291 document.getElementsByTagName("div")[4].appendChild(myApp.elem.paramText);292 },293 function(){294 myApp.elem.text.style.margin = '0px auto 30px';295 myApp.elem.subText.style.margin = '0px auto 50px';296 myApp.elem.subText.style.padding = '0px 40px';297 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.subText, myApp.elem.text.nextSibling);298 document.getElementsByTagName("div")[5].appendChild(myApp.elem.pushBtn);299 },300 function(){301 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.ansBtn, myApp.elem.subText.nextSibling);302 },303 function(){304 myApp.elem.text.style.margin = '0px auto 15px';305 myApp.elem.text.parentNode.removeChild(myApp.elem.subText);306 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.ansCol, myApp.elem.text.nextSibling);307 document.getElementsByTagName("div")[4].appendChild(myApp.elem.numOX);308 },309 ];310 myApp.val.viewFuncArray.shift()();311}312//313const num_of_materials = 6;314myApp.elem.sounds.onloadedmetadata = function(){ myApp.val.loadCount += 1; };315myApp.elem.imgBtn1.onload = function(){ myApp.val.loadCount += 1; };316myApp.elem.imgBtn2.onload = function(){ myApp.val.loadCount += 1; };317myApp.elem.imgBtn3.onload = function(){ myApp.val.loadCount += 1; };318myApp.elem.imgBtn4.onload = function(){ myApp.val.loadCount += 1; };319myApp.val.ansFile.onload = function(){ myApp.val.loadCount += 1; myApp.val.ansArray = CSVtoArray(myApp.val.ansFile.responseText); };320//321myApp.elem.sounds.onerror = function(){ myApp.val.loadErrorBool = true; };322myApp.elem.imgBtn1.onerror = function(){ myApp.val.loadErrorBool = true; };323myApp.elem.imgBtn2.onerror = function(){ myApp.val.loadErrorBool = true; };324myApp.elem.imgBtn3.onerror = function(){ myApp.val.loadErrorBool = true; };325myApp.elem.imgBtn4.onerror = function(){ myApp.val.loadErrorBool = true; };326myApp.val.ansFile.onerror = function(){ myApp.val.loadErrorBool = true; };327//328/* load audio data */329if (myApp.elem.sounds.canPlayType('audio/mp3') == 'probably'){ myApp.val.audioExt = '.mp3'; }330else if(myApp.elem.sounds.canPlayType('audio/aac') == 'probably'){ myApp.val.audioExt = '.aac'; }331else if(myApp.elem.sounds.canPlayType('audio/wav') == 'probably'){ myApp.val.audioExt = '.wav'; }332else if(myApp.elem.sounds.canPlayType('audio/mp3') == 'maybe' ){ myApp.val.audioExt = '.mp3'; }333else if(myApp.elem.sounds.canPlayType('audio/aac') == 'maybe' ){ myApp.val.audioExt = '.aac'; }334else if(myApp.elem.sounds.canPlayType('audio/wav') == 'maybe' ){ myApp.val.audioExt = '.wav'; }335myApp.elem.sounds.src = myApp.path.sound+myApp.val.audioExt;336//337/* load push button image */338myApp.elem.imgBtn1.src = myApp.path.btn1;339myApp.elem.imgBtn2.src = myApp.path.btn2;340myApp.elem.imgBtn3.src = myApp.path.btn3;341myApp.elem.imgBtn4.src = myApp.path.btn4;342if(myApp.val.os != 'other'){343 myApp.elem.pushBtn.className = "blinkImg";344}345//346/* load answer file */347myApp.val.ansFile.open("get", myApp.path.answer, true);348myApp.val.ansFile.send(null);349//350/* set audio sprite */351myApp.val.audioSpriteData = {352 pushBtn : { start : 0.0, end : 2.0 }, //[sec]353 sndO : { start : 3.0, end : 5.0 }, 354 sndX : { start : 6.0, end : 8.0 },355};356myApp.elem.sounds.addEventListener('timeupdate', spriteHandler, false);357function spriteHandler(){358 if(Math.abs(myApp.val.audioSpriteData.pushBtn.end - this.currentTime) < 0.25){359 this.pause();360 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;361 }362 if(Math.abs(myApp.val.audioSpriteData.sndO.end - this.currentTime) < 0.25){363 this.pause();364 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;365 }366 if(Math.abs(myApp.val.audioSpriteData.sndX.end - this.currentTime) < 0.25){367 this.pause();368 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;369 }370};371//372/* set function executed after initial loading */373myApp.elem.pushBtn.onerror = function(){374 myApp.val.loadErrorBool = true;375 myApp.val.loadAlertBool = true;376 alert("ç»åã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã" );377};378myApp.elem.pushBtn.onload = function(){379 if(myApp.val.initLoadBool == false){380 /* change player and push button size after loading image */381 resizePlayer();382 resizePushButton();383 myApp.val.initLoadBool = true;384 if(myApp.val.os == 'other'){ myApp.val.viewFuncArray.shift()(); }385 }386};387function materialCheckFunction(){388 if(myApp.val.loadErrorBool == false){389 if(myApp.val.initLoadBool == false && myApp.val.loadCount == num_of_materials){390 myApp.val.loadCount = 0;391 /* assign push button image and main text */392 myApp.elem.pushBtn.width = document.documentElement.clientWidth/5; /* init size before loading */393 if(myApp.val.os != "other"){394 if(Math.abs(window.orientation) != 90){395 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;396 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";397 myApp.val.initOrientation = 'portrait';398 }else{399 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;400 myApp.elem.text.innerHTML = "端æ«ã縦åãã«ãã¦ã¯ã¤ãºãã¯ããã";401 myApp.val.initOrientation = 'landscape';402 alert("ãã®ãµã¤ãã¯ã¹ãã¼ããã©ã³/ã¿ãã¬ããã縦åãã«ãã¦ã楽ãã¿ãã ããã");403 }404 }else{405 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;406 if(detectTouchPanel() == true){407 myApp.elem.subText.innerHTML = "<span class='blinkText'>ã¹ãã¼ã¹ãã¼ãæ¼ãã¦åç»ãéå§ãã</span>";408 }else{409 myApp.elem.subText.innerHTML = "<span class='blinkText'>ã¹ãã¼ã¹ãã¼ãæ¼ãã¦åç»ãéå§ãã</span>";410 }411 }412 }else if(myApp.val.initLoadBool == true && myApp.val.loadAlertBool == false){413 if(myApp.val.os != 'other'){414 if(Math.abs(myApp.elem.numOX.getBoundingClientRect().top - myApp.elem.ansBtn.getBoundingClientRect().bottom) < 50){415 myApp.val.loadErrorBool = true;416 myApp.val.loadAlertBool = true;417 player.pauseVideo();418 alert("ç»åã®è¡¨ç¤ºã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã");419 }420 }421 }422 }else{423 if(myApp.val.loadAlertBool == false){424 myApp.val.loadAlertBool = true;425 alert("ãã¼ã¸ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã");426 }427 }428}429//430/* EVENT */431/* orientation change event function */432window.addEventListener('orientationchange', myOrientationChangeEvent);433function myOrientationChangeEvent(){434 setTimeout(function(){435 resizePlayer();436 resizePushButton();437 if(myApp.val.status == myApp.state.MyAnswer){438 if(myApp.val.hidePlayerBool.phone == true){439 hidePlayer();440 }441 }442 if(Math.abs(window.orientation) != 90){443 if(myApp.val.status == myApp.state.MyAnswer){444 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;445 }else{446 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;447 }448 if(myApp.val.status == myApp.state.ButtonCheck){449 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";450 }451 }else{452 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;453 if(myApp.val.status == myApp.state.ButtonCheck){454 myApp.elem.text.innerHTML = "端æ«ã縦åãã«ãã¦ã¯ã¤ãºãã¯ããã";455 }456 if(myApp.val.orientationAlertBool == false && myApp.val.initOrientation == 'portrait'){457 myApp.val.playingCount = -10;458 myApp.val.orientationAlertBool = true;459 alert("ãã®ãµã¤ãã¯ã¹ãã¼ããã©ã³/ã¿ãã¬ããã縦åãã«ãã¦ã楽ãã¿ãã ããã");460 }461 }462 }, 800);463}464//465/* page hidden check event function */466document.addEventListener('webkitvisibilitychange', myPageHiddenCheckEvent, false);467function myPageHiddenCheckEvent(){468 if(document.webkitHidden){469 myApp.val.pageHiddenBool = true;470 // console.log('Hidden.');471 }else{472 myApp.val.pageHiddenBool = false;473 myApp.val.currTime.playing = player.getCurrentTime();474 myApp.val.watchedTime = myApp.val.currTime.playing;475 myApp.val.playingCount = 0;476 // console.log('Opened.');477 }478}479//480/* keydown event function */481document.onkeydown = myKeyDownEvent;482//483document.addEventListener("compositionstart", function(){ myApp.val.composingBool = true; });484document.addEventListener('compositionend', function(){ myApp.val.composingBool = false; });485function myKeyDownEvent(){486 if(myApp.val.loadErrorBool == false && myApp.val.initLoadBool == true && Math.abs(window.orientation) != 90){487 if(event.keyCode == myApp.val.space){488 myButtonAction();489 }490 /* prevent to start new line in text area */491 if(event.keyCode == myApp.val.enter){492 if(myApp.val.composingBool == false){493 return false;494 }495 }496 }497}498//499/* touchstart event function (for smartphonea and tablet) */500document.addEventListener("touchstart", myTouchEvent);501function myTouchEvent(event){502 if(myApp.val.loadErrorBool == false && myApp.val.initLoadBool == true && Math.abs(window.orientation) != 90){503 myApp.val.touchObject = event.changedTouches[0];504 if(myApp.val.pushBtnArea.left < myApp.val.touchObject.pageX && myApp.val.touchObject.pageX < myApp.val.pushBtnArea.right){505 if(myApp.val.pushBtnArea.top < myApp.val.touchObject.pageY && myApp.val.touchObject.pageY < myApp.val.pushBtnArea.bottom){506 myButtonAction();507 }508 }509 }510}511//512/* common button action */513function myButtonAction(){514 if(myApp.val.status == myApp.state.ButtonCheck){515 myApp.val.status = myApp.state.Talk;516 myApp.elem.pushBtn.className = "";517 buttonCheck(myApp.val.btnCheck.sndInterval);518 setTimeout(function(){519 player.playVideo();520 myApp.elem.ansBtn.disabled = false;521 if(myApp.val.os != 'other'){522 myApp.val.viewFuncArray.shift()();523 myApp.elem.text.innerHTML = "ï¼ éã³æ¹ ï¼";524 myApp.elem.subText.innerHTML = "ç»é¢ä¸ã®æ©æ¼ããã¿ã³ã§<br>åç»å
ã®ã¯ã¤ãºã«åå ãããã¨ãã§ãã¾ã";525 }else{526 myApp.val.viewFuncArray.shift()();527 myApp.elem.text.innerHTML = "ï¼ éã³æ¹ ï¼"528 myApp.elem.subText.innerHTML = "ã¹ãã¼ã¹ãã¼ãæ©æ¼ããã¿ã³ã«ãã¦<br>åç»å
ã®ã¯ã¤ãºã«åå ãããã¨ãã§ãã¾ã";529 }530 }, myApp.val.btnCheck.playInterval);531 }532 if(myApp.val.status == myApp.state.Question){533 myApp.val.status = myApp.state.MyAnswer;534 player.pauseVideo();535 pushButton();536 }537}538//539/* player's state change event function */540player.addEventListener('onStateChange', myPlayerStateChangeEvent);541function myPlayerStateChangeEvent(){542 if(player.getPlayerState() == myApp.videoState.Playing){543 myApp.val.currTime.playing = player.getCurrentTime();544 myApp.val.watchedTime = updateWatchedTime(myApp.val.currTime.playing, myApp.val.watchedTime);545 /* check answer if the video is restarted manually without sending answer */546 if(myApp.val.status == myApp.state.MyAnswer){547 player.pauseVideo();548 checkAnswer();549 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){550 myApp.val.status = myApp.state.Talk;551 }else{552 myApp.val.status = myApp.state.Question;553 }554 player.playVideo();555 }556 if(myApp.val.disableSeekbarBool == true){557 /* prevent to jump playback position by seekbar */558 if(myApp.val.status == myApp.state.Question){559 myApp.val.diffTime = Math.abs(myApp.val.currTime.playing - myApp.val.watchedTime);560 if(myApp.val.diffTime > 1.0){561 player.seekTo(myApp.val.watchedTime);562 }563 }else{564 myApp.val.diffTime = Math.abs(myApp.val.currTime.playing - myApp.val.watchedTime);565 // myApp.val.diffTime = myApp.val.currTime.playing - myApp.val.watchedTime; /* allow to jump to previous positon on timeline */566 if(myApp.val.diffTime > 1.0){567 player.seekTo(myApp.val.watchedTime);568 }569 }570 }571 }572 if(player.getPlayerState() == myApp.videoState.Stopped){573 myApp.val.currTime.stopped = player.getCurrentTime();574 if(myApp.val.disableSeekbarBool == true){575 /* prevent to jump video playback position by seekbar */576 /* and prevent to pause video during each question */577 if(myApp.val.status == myApp.state.Question || myApp.val.status == myApp.state.OthAnswer){578 myApp.val.diffTime = Math.abs(myApp.val.currTime.stopped - myApp.val.watchedTime);579 if(myApp.val.diffTime > 1.0){580 player.seekTo(myApp.val.watchedTime);581 }582 player.playVideo();583 }else{584 myApp.val.diffTime = Math.abs(myApp.val.currTime.stopped - myApp.val.watchedTime);585 // myApp.val.diffTime = myApp.val.currTime.stopped - myApp.val.watchedTime; /* allow to jump to previous position on timeline */586 if(myApp.val.diffTime > 1.0){587 player.seekTo(myApp.val.watchedTime);588 player.playVideo(); /* allow to pause video except during the question status */589 }590 // player.playVideo();591 }592 }593 }594}595//596/* interval event function that are executed at a certain interval */597setInterval(myIntervalEvent, interval = 10);598function myIntervalEvent(){599 if(myApp.val.pageHiddenBool == false){600 if(player.getPlayerState() == myApp.videoState.Playing){601 myApp.val.currTime.playing = player.getCurrentTime();602 myApp.val.watchedTime = updateWatchedTime(myApp.val.currTime.playing, myApp.val.watchedTime);603 if(myApp.val.disableSeekbarBool == true){604 /* check delay of processing */605 if(myApp.val.playingCount < 0 ){ myApp.val.watchedTime = myApp.val.currTime.playing; } // fix delay of watchedTime caused by showing orientation alert.606 if(myApp.val.playingCount < 10){ myApp.val.playingCount += 1; }ã// allow initial delay of watchedTime just after playing video.607 if(myApp.val.currTime.playing - myApp.val.watchedTime > 1.0 && myApp.val.playingCount >= 10){608 if(myApp.val.processDelayAlertBool == false){609 myApp.val.processDelayAlertBool = true;610 alert('ãã¼ã¸å
ã®å¦çãé
ããªã£ã¦ãã¾ããæ©æ¼ãã®å¤å®ã«æ¯éãåºãå¯è½æ§ããããããä»ã®ããã»ã¹ãçµäºãã¦ããæ¹ãã¦ã¯ã¤ãºãã楽ãã¿ãã ããããã®ãããã¢ããã¯ä¸åº¦ã®ã¿è¡¨ç¤ºããã¾ãã');611 }612 myApp.val.watchedTime = myApp.val.currTime.playing;613 }614 }615 /* prevent to play video before button check */616 if(myApp.val.status == myApp.state.ButtonCheck){617 player.pauseVideo();618 }619 /* execute srt function in each sections of subtitle */620 if(myApp.val.status != myApp.state.MyAnswer){621 if(myApp.val.disableSeekbarBool == true){622 if(index - myApp.val.cntIndex == 1){623 myApp.val.srtFuncArray.shift()();624 myApp.val.cntIndex += 1;625 }626 }else{627 if(index - myApp.val.cntIndex >= 1){628 for(let i = 0; i < index-myApp.val.cntIndex; i++){629 myApp.val.srtFuncArray.shift()();630 }631 myApp.val.cntIndex = index;632 // console.log(myApp.val.cntIndex);633 }634 }635 }636 }else if(player.getPlayerState() == myApp.videoState.Stopped){637 myApp.val.playingCount = 0;638 }639 if(myApp.val.status == myApp.state.ButtonCheck){640 if(myApp.val.cntIndex > 0 && myApp.val.loadAlertBool == false){641 myApp.val.loadErrorBool = true;642 myApp.val.loadAlertBool = true;643 player.pauseVideo();644 alert('ãã¼ã¸ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã');645 }646 }647 if(myApp.val.status == myApp.state.MyAnswer){648 /* reforcus when anscol is blank */649 // if(document.activeElement.id != "anscol" && myApp.elem.ansCol.value.valueOf() === ""){650 // myApp.elem.ansCol.focus();651 // }652 /* answer time managemant */653 if(document.activeElement.id == "anscol" || myApp.val.ansTime.elapsed != 0){654 myApp.val.ansTime.elapsed += interval;655 myApp.elem.text.innerHTML = "ã®ãã"+Math.floor((myApp.val.ansTime.limit-myApp.val.ansTime.elapsed)/1000+1)+"ç§";656 if(myApp.val.ansTime.elapsed >= myApp.val.ansTime.limit){657 checkAnswer();658 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){659 myApp.val.status = myApp.state.Talk;660 }else{661 myApp.val.status = myApp.state.Question;662 }663 player.playVideo();664 }665 }666 }else{667 if(myApp.val.os == 'other' && document.activeElement.id == "player"){668 /* preparation of js keydown event */669 instantFocusToElement(myApp.elem.pushBtn);670 }671 myApp.val.ansTime.elapsed = 0;672 }673 /* check results of importing material */674 materialCheckFunction();675 /* update push button area (mainly for when the window is zoomed in iOS)*/676 updatePushButtonArea();677 /* print parameters for debug */678 printParams();679 }680}681//682/* onclick event function of send answer button */683myApp.elem.ansBtn.onclick = myOnClickEvent;684function myOnClickEvent(){685 /* jump to init question */686 if(index == 0){687 let tmpTime = myApp.val.firstQuesStartTime-0.1;688 if(myApp.val.currTime.playing < tmpTime){689 myApp.elem.ansBtn.disabled = true;690 myApp.val.watchedTime = tmpTime;691 player.seekTo(tmpTime);692 }693 }694 /* send answer */695 if(myApp.val.status == myApp.state.MyAnswer){696 checkAnswer();697 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){698 myApp.val.status = myApp.state.Talk;699 }else{700 myApp.val.status = myApp.state.Question;701 }702 player.playVideo();703 }704}705//706/* onfocus event function of answer column */707myApp.elem.ansCol.onfocus = function(){ myApp.elem.ansCol.val = ""; }708//709/* FUNCTION */710function detectTouchPanel(){711 return window.ontouchstart === null;712}713//714function fetchOSType(){715 let osType = null;716 const ua = navigator.userAgent;717 if(ua.match(/Android/)){718 osType = "Android";719 return osType;720 }else if(ua.match(/iPhone/)) {721 osType = "iOS"; // iPhone OS722 return osType;723 }else if(ua.match(/iPad/)) {724 osType = "iOS"; // iPad OS725 return osType;726 }else if(ua.match(/Macintosh/) && detectTouchPanel() == true){727 osType = 'iOS'; // iPad OS with Safari728 return osType;729 }else{730 osType = "other";731 return osType;732 }733}734//735function fetchBrowserType(){736 let bwType = null;737 const ua = navigator.userAgent;738 if(ua.match(/Firefox/)){739 bwType = "Firefox";740 return bwType;741 }else if(ua.match(/EdgiOS/) || ua.match(/EdgA/)){742 bwType = "Edge";743 return bwType;744 }else if(ua.match(/OPR/)){745 bwType = "Opera";746 return bwType;747 }else if(ua.match(/OPT/)){748 bwType = "OperaTouch";749 return bwType;750 }else if(ua.match(/YJApp/)){751 bwType = "Yahoo";752 return bwType;753 }else if(ua.match(/Smooz/)){754 bwType = "Smooz";755 return bwType;756 }else if(ua.match(/CriOS/) || ua.match(/Chrome/)){757 //Chrome or Others ...758 bwType = "Chrome";759 return bwType;760 }else{761 //Safari, Firefox(iOS), Brave or Others ...762 bwType = "Other";763 return bwType;764 }765}766/**767 * @param {string} str768 * @returns {array} (rows: num of question, columns: num of patterns of answerï¼769 */770function CSVtoArray(str){771 const array = new Array();772 const tmp = str.split("\r\n");773 for(let i = 0; i < tmp.length; i++){774 array[i] = tmp[i].split(",");775 }776 return array;777}778//779function resizePlayer(){780 if(myApp.val.os != 'other'){781 if(Math.abs(window.orientation) != 90){782 // myApp.val.playerWidth = document.documentElement.clientWidth;783 if(myApp.val.os == 'Android'){ myApp.val.playerWidth = window.innerWidth; } // In Android, clientWidth doesn't include scrollbar.784 if(myApp.val.os == 'iOS'){ myApp.val.playerWidth = document.documentElement.clientWidth; } // In iOS, innerWidth isn't static (it changes with device orientation).785 myApp.val.playerHeight = myApp.val.playerWidth/16*9;786 }else{787 myApp.val.playerWidth = document.documentElement.clientWidth*2/3;788 myApp.val.playerHeight = myApp.val.playerWidth/16*9;789 }790 /* set special width of anscol to prevent the window is zoomed when the focus moveds to anscol */791 if(myApp.val.os == 'Android' && myApp.val.browser == "Firefox"){792 myApp.elem.ansCol.style.width = myApp.val.playerWidth*0.98+'px';793 }else{794 myApp.elem.ansCol.style.width = myApp.val.playerWidth*0.9+'px';795 }796 }else{797 const tmpPlayerHeight = document.documentElement.clientHeight/2;798 const tmpPlayerWidth = tmpPlayerHeight/9*16;799 if(tmpPlayerWidth < document.documentElement.clientWidth){800 myApp.val.playerHeight = tmpPlayerHeight;801 myApp.val.playerWidth = tmpPlayerWidth;802 }else{803 myApp.val.playerWidth = document.documentElement.clientWidth;804 myApp.val.playerHeight = myApp.val.playerWidth/16*9;805 }806 }807 if(myApp.val.initLoadBool == false || myApp.val.prevPlayerWidth != myApp.val.playerWidth){808 player.setSize(myApp.val.playerWidth, myApp.val.playerHeight);809 //810 myApp.val.prevPlayerWidth = myApp.val.playerWidth;811 myApp.val.prevPlayerHeight = myApp.val.playerHeight;812 }813}814//815function resizePushButton(){816 if(myApp.val.os != "other"){817 if(Math.abs(window.orientation) != 90){818 const tmpImgHeight = document.documentElement.clientHeight-myApp.val.playerHeight-myApp.val.elemHeight-20;819 const tmpImgWidth = myApp.elem.pushBtn.naturalWidth*tmpImgHeight/myApp.elem.pushBtn.naturalHeight;820 if(tmpImgWidth < document.documentElement.clientWidth){821 if(tmpImgHeight <= myApp.val.playerHeight){822 myApp.val.pushBtnWidth = tmpImgWidth;823 myApp.val.pushBtnHeight = tmpImgHeight;824 }else{825 myApp.val.pushBtnWidth = myApp.elem.pushBtn.naturalWidth*myApp.val.playerHeight*1.25/myApp.elem.pushBtn.naturalHeight;826 myApp.val.pushBtnHeight = myApp.val.playerHeight*1.25;827 }828 }else{829 myApp.val.pushBtnWidth = document.documentElement.clientWidth/5;830 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;831 }832 }else{833 myApp.val.pushBtnWidth = document.documentElement.clientWidth/5;834 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;835 }836 myApp.elem.pushBtn.style.margin = 'auto '+(document.documentElement.clientWidth-myApp.val.pushBtnWidth)/2+'px';837 }else{838 myApp.val.pushBtnWidth = myApp.val.divBtnWidth;839 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;840 } 841 if(myApp.val.initLoadBool == false || myApp.val.prevClientHeight != document.documentElement.clientHeight){842 myApp.elem.pushBtn.width = myApp.val.pushBtnWidth;843 myApp.elem.pushBtn.height = myApp.val.pushBtnHeight;844 updatePushButtonArea();845 //846 myApp.val.prevClientWidth = document.documentElement.clientWidth;847 myApp.val.prevClientHeight = document.documentElement.clientHeight;848 }849}850//851function updatePushButtonArea(){852 myApp.val.pushBtnArea.left = myApp.elem.pushBtn.getBoundingClientRect().left;853 myApp.val.pushBtnArea.right = myApp.elem.pushBtn.getBoundingClientRect().right;854 myApp.val.pushBtnArea.top = myApp.elem.pushBtn.getBoundingClientRect().top;855 myApp.val.pushBtnArea.bottom = myApp.elem.pushBtn.getBoundingClientRect().bottom;856 //857 /* In iOS, value of getBoundingClientRect is changed when the window is zoomed */858 if(myApp.val.os == 'iOS'){859 myApp.val.pushBtnArea.left += window.pageXOffset;860 myApp.val.pushBtnArea.right += window.pageXOffset;861 myApp.val.pushBtnArea.top += window.pageYOffset;862 myApp.val.pushBtnArea.bottom += window.pageYOffset;863 }864}865//866function instantFocusToElement(focusUsableElement){867 /* keydown event is ready during the focus is in a js element */868 focusUsableElement.disabled = false;869 focusUsableElement.focus();870 focusUsableElement.blur();871 focusUsableElement.disabled = true;872}873//874function updateWatchedTime(currentPlayingTime, watchedTime){875 if(0.0 < currentPlayingTime - watchedTime && currentPlayingTime - watchedTime < 1.0){876 watchedTime = currentPlayingTime;877 }878 return watchedTime;879}880//881function playSndPushBtn(){882 if(myApp.elem.sounds.currentTime != myApp.val.audioSpriteData.pushBtn.start){883 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;884 }885 myApp.elem.sounds.play();886}887//888function playSndO(){889 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.sndO.start;890 myApp.elem.sounds.play();891}892//893function playSndX(){894 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.sndX.start;895 myApp.elem.sounds.play();896}897//898function hidePlayer(){899 player.setSize(myApp.val.playerWidth, 0);900}901//902function opposePlayer(){903 player.setSize(myApp.val.playerWidth, myApp.val.playerHeight);904}905//906function buttonCheck(responseInterval){907 playSndPushBtn();908 if(myApp.val.os == 'iOS'){909 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;910 }else{911 myApp.elem.pushBtn.src = myApp.elem.imgBtn2.src;912 setTimeout(function(){ myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src; }, 100);913 }914 setTimeout(function(){915 playSndO();916 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;917 }, responseInterval);918}919//920function pushButton(){921 // hide player during answer.922 if(myApp.val.os != 'other'){923 if(myApp.val.hidePlayerBool.phone == true){924 hidePlayer();925 }926 }else{927 if(myApp.val.hidePlayerBool.other == true){928 hidePlayer();929 }930 }931 playSndPushBtn();932 if(myApp.val.os == 'iOS'){933 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;934 if(myApp.val.browser == 'Chrome' || myApp.val.browser == 'Edge' || myApp.val.browser == 'Smooz'){935 setTimeout(function(){ focusToAnsCol(); }, 500); // In above browsers, focus() doesn't work by the script below.936 }else{937 focusToAnsCol(); // In iOS, focus() doesn't work properly in setTimeout (keyboard doesn't appear).938 }939 }else{940 myApp.elem.pushBtn.src = myApp.elem.imgBtn2.src;941 setTimeout(function(){ myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src; }, 100); 942 setTimeout(function(){ focusToAnsCol(); }, 500);943 }944 myApp.val.cntPush = myApp.val.cntPush+1;945}946//947function focusToAnsCol(){948 myApp.elem.ansBtn.disabled = false;949 myApp.elem.ansCol.disabled = false;950 myApp.elem.ansCol.value = "";951 myApp.elem.ansCol.focus();952}953//954function checkAnswer(){955 myApp.val.correctBool = false;956 myApp.elem.ansCol.blur();957 myApp.elem.ansCol.disabled = true;958 myApp.elem.ansBtn.disabled = true;959 const answer = myApp.elem.ansCol.value;960 const length = myApp.val.ansArray[myApp.val.numQues-1].length;961 for(let i = 0; i < length; i++){962 if(answer.valueOf() === myApp.val.ansArray[myApp.val.numQues-1][i].valueOf()){963 myApp.val.correctBool = true;964 }965 }966 if(myApp.val.correctBool == true){967 playSndO();968 myApp.val.cntO += 1;969 myApp.elem.text.innerHTML = "æ£è§£ï¼";970 if(myApp.val.jumpToAnsBool){ jumpToAnswerIndex(myApp.val.ansIndex, myApp.val.ansIndexStartTime); }971 }else{972 playSndX();973 myApp.val.cntX += 1;974 myApp.elem.text.innerHTML = "ä¸æ£è§£ï¼"; //ãã¨"+(myApp.val.limPush-myApp.val.cntPush)+"å解çã§ãã¾ãã";975 if(myApp.val.jumpToAnsBool){ jumpToAnswerIndex(myApp.val.ansIndex, myApp.val.ansIndexStartTime); }976 }977 myApp.elem.numOX.innerHTML = "âï¸ï¼"+myApp.val.cntO+"ãâï¼"+myApp.val.cntX;978 if(window.orientation != 90){979 if(myApp.val.correctBool == false && myApp.val.limPush - myApp.val.cntPush == 0){980 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;981 }else{982 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;983 }984 }else{985 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;986 }987 // oppose player after answer.988 if(myApp.val.os != 'other'){989 if(myApp.val.hidePlayerBool.phone == true){990 opposePlayer();991 }992 }else{993 if(myApp.val.hidePlayerBool.other == true){994 opposePlayer();995 }996 }997}998//999function jumpToAnswerIndex(index, time){1000 myApp.val.cntIndex = index-1;1001 myApp.val.watchedTime = time-0.1;1002 player.seekTo(time-0.1);1003}1004//1005function printParams(){1006 // myApp.elem.paramText.innerHTML = "timePlay: " + myApp.val.currTime.playing.toFixed(3)+"<br>"+1007 // "timeStop: " +myApp.val.currTime.stopped.toFixed(3)+"<br>"+1008 // "WatchedTime: " + myApp.val.watchedTime.toFixed(3)+"<br>"+1009 // "diffTime: " + myApp.val.diffTime.toFixed(3);1010 // myApp.elem.paramText.innerHTML = myApp.val.browser;1011 // myApp.elem.paramText.innerHTML = myApp.val.os + ', ' + navigator.userAgent;1012 // myApp.elem.paramText.innerHTML = document.styleSheets.item(0).cssRules;1013 // myApp.elem.subText.innerHTML = "sounds.currentTime: " + Math.abs(Math.floor(myApp.elem.sounds.currentTime*1000)/1000);1014 // myApp.elem.subText.innerHTML = Math.floor(myApp.val.touchObject.pageX) +', '+ Math.floor(myApp.val.touchObject.pageY) +' '+1015 // '[' + Math.floor(myApp.val.pushBtnArea.left) +', '+ Math.floor(myApp.val.pushBtnArea.right) +'] '+1016 // '[' + Math.floor(myApp.val.pushBtnArea.top) +', '+ Math.floor(myApp.val.pushBtnArea.bottom)+'] '+1017 // '| '+ window.pageXOffset +', '+ window.pageYOffset;1018 // myApp.elem.subText.innerHTML = myApp.elem.numOX.getBoundingClientRect().top - myApp.elem.ansBtn.getBoundingClientRect().bottom;1019 // myApp.elem.subText.innerHTML = 'loadErrorBool: ' + myApp.val.loadErrorBool + ', initLoadBool: ' + myApp.val.initLoadBool + ', loadCount: ' + myApp.val.loadCount;1020 // myApp.elem.subText.innerHTML = 'playerWidth: ' + myApp.val.playerWidth + ', innerWidth: ' + window.innerWidth;1021 // myApp.elem.paramText.innerHTML = "<br>"+ 1022 // "device: " + myApp.val.os+"<br>"+1023 // "browser: " + myApp.val.browser+"<br>"+1024 // "activeElem: " + document.activeElement.id+"<br>"+ 1025 // "status: " + myApp.val.status+"<br>"+1026 // "timePlay: " + myApp.val.currTime.playing.toFixed(3)+"<br>"+1027 // "timeStop: " + myApp.val.currTime.stopped.toFixed(3)+"<br>"+1028 // "WatchedTime: " + myApp.val.watchedTime.toFixed(3)+"<br>"+1029 // "diffTime: " + myApp.val.diffTime.toFixed(3)+"<br>"+1030 // "limPush: " + myApp.val.limPush+"<br>"+ 1031 // "cntPush: " + myApp.val.cntPush+"<br>"+1032 // "remainingAnsTime: " + Math.floor((myApp.val.ansTime.limit-myApp.val.ansTime.elapsed)/1000)+"<br>"+1033 // "answer: " + myApp.val.ansArray[myApp.val.numQues-1][0].valueOf()+", "+1034 // myApp.val.ansArray[myApp.val.numQues-1][1].valueOf()+", "+1035 // myApp.val.ansArray[myApp.val.numQues-1][2].valueOf()+", "+1036 // myApp.val.ansArray[myApp.val.numQues-1][3].valueOf()+", "+1037 // myApp.val.ansArray[myApp.val.numQues-1][4].valueOf()+", "+1038 // myApp.val.ansArray[myApp.val.numQues-1][5].valueOf()+"<br>"+1039 // "numAnswer: " + myApp.val.ansArray.length+"<br>"+1040 // "answerLength: " + myApp.val.ansArray[myApp.val.numQues-1].length+"<br>"+1041 // "correctBool: " + myApp.val.correctBool+"<br>"+1042 // "composing: " + myApp.val.composingBool+"<br>"+1043 // "index: " + index+"<br>"+1044 // "cntIndex: " + myApp.val.cntIndex+"<br>"+1045 // "cssRules: " + document.styleSheets.item(0).cssRules.item(0).selectorText;1046}1047//1048//---------------------------------------------------------------------------------------------------------------1049/* set functions executed in each subtitle */1050myApp.val.jumpToAnsBool = true;1051myApp.val.disableSeekbarBool = false;1052myApp.val.hidePlayerBool.phone = true;1053myApp.val.hidePlayerBool.other = false;1054myApp.val.firstQuesStartTime = 19.22;1055myApp.val.srtFuncArray = [1056 function(){1057 myApp.val.viewFuncArray.shift()();1058 myApp.elem.ansBtn.innerHTML = "解çãéä¿¡";1059 /* 第1å */1060 myApp.val.ansIndex = 2;1061 myApp.val.ansIndexStartTime = 30.26;1062 //1063 myApp.val.status = myApp.state.Question;1064 myApp.val.numQues = 1;1065 myApp.val.cntPush = 0;1066 myApp.val.correctBool = false;1067 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1068 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1069 myApp.elem.ansCol.disabled = true;1070 myApp.elem.ansBtn.disabled = true;1071 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1072 },1073 function(){1074 myApp.val.status = myApp.state.Talk;1075 myApp.elem.ansCol.disabled = true;1076 myApp.elem.ansBtn.disabled = true;1077 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1078 },1079 function(){1080 /* 第2å */1081 myApp.val.ansIndex = 4;1082 myApp.val.ansIndexStartTime = 46.69;1083 //1084 myApp.val.status = myApp.state.Question;1085 myApp.val.numQues = 2;1086 myApp.val.cntPush = 0;1087 myApp.val.correctBool = false;1088 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1089 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1090 myApp.elem.ansCol.disabled = true;1091 myApp.elem.ansBtn.disabled = true;1092 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1093 },1094 function(){1095 myApp.val.status = myApp.state.Talk;1096 myApp.elem.ansCol.disabled = true;1097 myApp.elem.ansBtn.disabled = true;1098 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1099 },1100 function(){1101 /* 第3å */1102 myApp.val.ansIndex = 6;1103 myApp.val.ansIndexStartTime = 61.83;1104 //1105 myApp.val.status = myApp.state.Question;1106 myApp.val.numQues = 3;1107 myApp.val.cntPush = 0;1108 myApp.val.correctBool = false;1109 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1110 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1111 myApp.elem.ansCol.disabled = true;1112 myApp.elem.ansBtn.disabled = true;1113 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1114 },1115 function(){1116 myApp.val.status = myApp.state.Talk;1117 myApp.elem.ansCol.disabled = true;1118 myApp.elem.ansBtn.disabled = true;1119 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1120 },1121 function(){1122 /* 第4å */1123 myApp.val.ansIndex = 8;1124 myApp.val.ansIndexStartTime = 77.83;1125 //1126 myApp.val.status = myApp.state.Question;1127 myApp.val.numQues = 4;1128 myApp.val.cntPush = 0;1129 myApp.val.correctBool = false;1130 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1131 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1132 myApp.elem.ansCol.disabled = true;1133 myApp.elem.ansBtn.disabled = true;1134 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1135 },1136 function(){1137 myApp.val.status = myApp.state.Talk;1138 myApp.elem.ansCol.disabled = true;1139 myApp.elem.ansBtn.disabled = true;1140 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1141 },1142 function(){1143 /* 第5å */1144 myApp.val.ansIndex = 10;1145 myApp.val.ansIndexStartTime = 93.07;1146 //1147 myApp.val.status = myApp.state.Question;1148 myApp.val.numQues = 5;1149 myApp.val.cntPush = 0;1150 myApp.val.correctBool = false;1151 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1152 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1153 myApp.elem.ansCol.disabled = true;1154 myApp.elem.ansBtn.disabled = true;1155 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1156 },1157 function(){1158 myApp.val.status = myApp.state.Talk;1159 myApp.elem.ansCol.disabled = true;1160 myApp.elem.ansBtn.disabled = true;1161 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1162 },1163 function(){1164 /* 第6å */1165 myApp.val.ansIndex = 12;1166 myApp.val.ansIndexStartTime = 104.11;1167 //1168 myApp.val.status = myApp.state.Question;1169 myApp.val.numQues = 6;1170 myApp.val.cntPush = 0;1171 myApp.val.correctBool = false;1172 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1173 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1174 myApp.elem.ansCol.disabled = true;1175 myApp.elem.ansBtn.disabled = true;1176 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1177 },1178 function(){1179 myApp.val.status = myApp.state.Talk;1180 myApp.elem.ansCol.disabled = true;1181 myApp.elem.ansBtn.disabled = true;1182 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1183 },1184 function(){1185 /* 第7å */1186 myApp.val.ansIndex = 14;1187 myApp.val.ansIndexStartTime = 120.2;1188 //1189 myApp.val.status = myApp.state.Question;1190 myApp.val.numQues = 7;1191 myApp.val.cntPush = 0;1192 myApp.val.correctBool = false;1193 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1194 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1195 myApp.elem.ansCol.disabled = true;1196 myApp.elem.ansBtn.disabled = true;1197 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1198 },1199 function(){1200 myApp.val.status = myApp.state.Talk;1201 myApp.elem.ansCol.disabled = true;1202 myApp.elem.ansBtn.disabled = true;1203 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1204 },1205 function(){1206 /* 第8å */1207 myApp.val.ansIndex = 16;1208 myApp.val.ansIndexStartTime = 136.73;1209 //1210 myApp.val.status = myApp.state.Question;1211 myApp.val.numQues = 8;1212 myApp.val.cntPush = 0;1213 myApp.val.correctBool = false;1214 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1215 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1216 myApp.elem.ansCol.disabled = true;1217 myApp.elem.ansBtn.disabled = true;1218 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1219 },1220 function(){1221 myApp.val.status = myApp.state.Talk;1222 myApp.elem.ansCol.disabled = true;1223 myApp.elem.ansBtn.disabled = true;1224 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1225 },1226 function(){1227 /* 第9å */1228 myApp.val.ansIndex = 18;1229 myApp.val.ansIndexStartTime = 152.22;1230 //1231 myApp.val.status = myApp.state.Question;1232 myApp.val.numQues = 9;1233 myApp.val.cntPush = 0;1234 myApp.val.correctBool = false;1235 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1236 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1237 myApp.elem.ansCol.disabled = true;1238 myApp.elem.ansBtn.disabled = true;1239 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1240 },1241 function(){1242 myApp.val.status = myApp.state.Talk;1243 myApp.elem.ansCol.disabled = true;1244 myApp.elem.ansBtn.disabled = true;1245 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1246 },1247 function(){1248 /* 第10å */1249 myApp.val.ansIndex = 20;1250 myApp.val.ansIndexStartTime = 166.8;1251 //1252 myApp.val.status = myApp.state.Question;1253 myApp.val.numQues = 10;1254 myApp.val.cntPush = 0;1255 myApp.val.correctBool = false;1256 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1257 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1258 myApp.elem.ansCol.disabled = true;1259 myApp.elem.ansBtn.disabled = true;1260 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1261 },1262 function(){1263 myApp.val.status = myApp.state.Talk;1264 myApp.elem.ansCol.disabled = true;1265 myApp.elem.ansBtn.disabled = true;1266 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1267 },1268 function(){1269 /* 第11å */1270 myApp.val.ansIndex = 22;1271 myApp.val.ansIndexStartTime = 180.54;1272 //1273 myApp.val.status = myApp.state.Question;1274 myApp.val.numQues = 11;1275 myApp.val.cntPush = 0;1276 myApp.val.correctBool = false;1277 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1278 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1279 myApp.elem.ansCol.disabled = true;1280 myApp.elem.ansBtn.disabled = true;1281 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1282 },1283 function(){1284 myApp.val.status = myApp.state.Talk;1285 myApp.elem.ansCol.disabled = true;1286 myApp.elem.ansBtn.disabled = true;1287 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1288 },1289 function(){1290 /* 第12å */1291 myApp.val.ansIndex = 24;1292 myApp.val.ansIndexStartTime = 195.26;1293 //1294 myApp.val.status = myApp.state.Question;1295 myApp.val.numQues = 12;1296 myApp.val.cntPush = 0;1297 myApp.val.correctBool = false;1298 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1299 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1300 myApp.elem.ansCol.disabled = true;1301 myApp.elem.ansBtn.disabled = true;1302 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1303 },1304 function(){1305 myApp.val.status = myApp.state.Talk;1306 myApp.elem.ansCol.disabled = true;1307 myApp.elem.ansBtn.disabled = true;1308 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1309 },1310 function(){1311 /* 第13å */1312 myApp.val.ansIndex = 26;1313 myApp.val.ansIndexStartTime = 211.41;1314 //1315 myApp.val.status = myApp.state.Question;1316 myApp.val.numQues = 13;1317 myApp.val.cntPush = 0;1318 myApp.val.correctBool = false;1319 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1320 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1321 myApp.elem.ansCol.disabled = true;1322 myApp.elem.ansBtn.disabled = true;1323 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1324 },1325 function(){1326 myApp.val.status = myApp.state.Talk;1327 myApp.elem.ansCol.disabled = true;1328 myApp.elem.ansBtn.disabled = true;1329 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1330 },1331 function(){1332 /* 第14å */1333 myApp.val.ansIndex = 28;1334 myApp.val.ansIndexStartTime = 226.77;1335 //1336 myApp.val.status = myApp.state.Question;1337 myApp.val.numQues = 14;1338 myApp.val.cntPush = 0;1339 myApp.val.correctBool = false;1340 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1341 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1342 myApp.elem.ansCol.disabled = true;1343 myApp.elem.ansBtn.disabled = true;1344 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1345 },1346 function(){1347 myApp.val.status = myApp.state.Talk;1348 myApp.elem.ansCol.disabled = true;1349 myApp.elem.ansBtn.disabled = true;1350 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1351 },1352 function(){1353 /* 第15å */1354 myApp.val.ansIndex = 30;1355 myApp.val.ansIndexStartTime = 241.76;1356 //1357 myApp.val.status = myApp.state.Question;1358 myApp.val.numQues = 15;1359 myApp.val.cntPush = 0;1360 myApp.val.correctBool = false;1361 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1362 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1363 myApp.elem.ansCol.disabled = true;1364 myApp.elem.ansBtn.disabled = true;1365 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1366 },1367 function(){1368 myApp.val.status = myApp.state.Talk;1369 myApp.elem.ansCol.disabled = true;1370 myApp.elem.ansBtn.disabled = true;1371 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1372 },1373 function(){1374 /* 第16å */1375 myApp.val.ansIndex = 32;1376 myApp.val.ansIndexStartTime = 257.99;1377 //1378 myApp.val.status = myApp.state.Question;1379 myApp.val.numQues = 16;1380 myApp.val.cntPush = 0;1381 myApp.val.correctBool = false;1382 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1383 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1384 myApp.elem.ansCol.disabled = true;1385 myApp.elem.ansBtn.disabled = true;1386 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1387 },1388 function(){1389 myApp.val.status = myApp.state.Talk;1390 myApp.elem.ansCol.disabled = true;1391 myApp.elem.ansBtn.disabled = true;1392 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1393 },1394 function(){1395 /* 第17å */1396 myApp.val.ansIndex = 34;1397 myApp.val.ansIndexStartTime = 274.94;1398 //1399 myApp.val.status = myApp.state.Question;1400 myApp.val.numQues = 17;1401 myApp.val.cntPush = 0;1402 myApp.val.correctBool = false;1403 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1404 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1405 myApp.elem.ansCol.disabled = true;1406 myApp.elem.ansBtn.disabled = true;1407 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1408 },1409 function(){1410 myApp.val.status = myApp.state.Talk;1411 myApp.elem.ansCol.disabled = true;1412 myApp.elem.ansBtn.disabled = true;1413 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1414 },1415 function(){1416 /* 第18å */1417 myApp.val.ansIndex = 36;1418 myApp.val.ansIndexStartTime = 290.35;1419 //1420 myApp.val.status = myApp.state.Question;1421 myApp.val.numQues = 18;1422 myApp.val.cntPush = 0;1423 myApp.val.correctBool = false;1424 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1425 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1426 myApp.elem.ansCol.disabled = true;1427 myApp.elem.ansBtn.disabled = true;1428 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1429 },1430 function(){1431 myApp.val.status = myApp.state.Talk;1432 myApp.elem.ansCol.disabled = true;1433 myApp.elem.ansBtn.disabled = true;1434 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1435 },1436 function(){1437 /* 第19å */1438 myApp.val.ansIndex = 38;1439 myApp.val.ansIndexStartTime = 302.48;1440 //1441 myApp.val.status = myApp.state.Question;1442 myApp.val.numQues = 19;1443 myApp.val.cntPush = 0;1444 myApp.val.correctBool = false;1445 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1446 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1447 myApp.elem.ansCol.disabled = true;1448 myApp.elem.ansBtn.disabled = true;1449 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1450 },1451 function(){1452 myApp.val.status = myApp.state.Talk;1453 myApp.elem.ansCol.disabled = true;1454 myApp.elem.ansBtn.disabled = true;1455 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1456 },1457 function(){1458 /* 第20å */1459 myApp.val.ansIndex = 40;1460 myApp.val.ansIndexStartTime = 317.07;1461 //1462 myApp.val.status = myApp.state.Question;1463 myApp.val.numQues = 20;1464 myApp.val.cntPush = 0;1465 myApp.val.correctBool = false;1466 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1467 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1468 myApp.elem.ansCol.disabled = true;1469 myApp.elem.ansBtn.disabled = true;1470 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1471 },1472 function(){1473 myApp.val.status = myApp.state.Talk;1474 myApp.elem.ansCol.disabled = true;1475 myApp.elem.ansBtn.disabled = true;1476 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1477 },1478 function(){1479 /* 第21å */1480 myApp.val.ansIndex = 42;1481 myApp.val.ansIndexStartTime = 333.88;1482 //1483 myApp.val.status = myApp.state.Question;1484 myApp.val.numQues = 21;1485 myApp.val.cntPush = 0;1486 myApp.val.correctBool = false;1487 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1488 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1489 myApp.elem.ansCol.disabled = true;1490 myApp.elem.ansBtn.disabled = true;1491 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1492 },1493 function(){1494 myApp.val.status = myApp.state.Talk;1495 myApp.elem.ansCol.disabled = true;1496 myApp.elem.ansBtn.disabled = true;1497 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1498 },1499 function(){1500 /* 第22å */1501 myApp.val.ansIndex = 44;1502 myApp.val.ansIndexStartTime = 349.54;1503 //1504 myApp.val.status = myApp.state.Question;1505 myApp.val.numQues = 22;1506 myApp.val.cntPush = 0;1507 myApp.val.correctBool = false;1508 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1509 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1510 myApp.elem.ansCol.disabled = true;1511 myApp.elem.ansBtn.disabled = true;1512 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1513 },1514 function(){1515 myApp.val.status = myApp.state.Talk;1516 myApp.elem.ansCol.disabled = true;1517 myApp.elem.ansBtn.disabled = true;1518 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1519 },1520 function(){1521 /* 第23å */1522 myApp.val.ansIndex = 46;1523 myApp.val.ansIndexStartTime = 365.93;1524 //1525 myApp.val.status = myApp.state.Question;1526 myApp.val.numQues = 23;1527 myApp.val.cntPush = 0;1528 myApp.val.correctBool = false;1529 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1530 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1531 myApp.elem.ansCol.disabled = true;1532 myApp.elem.ansBtn.disabled = true;1533 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1534 },1535 function(){1536 myApp.val.status = myApp.state.Talk;1537 myApp.elem.ansCol.disabled = true;1538 myApp.elem.ansBtn.disabled = true;1539 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1540 },1541 function(){1542 /* 第24å */1543 myApp.val.ansIndex = 48;1544 myApp.val.ansIndexStartTime = 381.07;1545 //1546 myApp.val.status = myApp.state.Question;1547 myApp.val.numQues = 24;1548 myApp.val.cntPush = 0;1549 myApp.val.correctBool = false;1550 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1551 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1552 myApp.elem.ansCol.disabled = true;1553 myApp.elem.ansBtn.disabled = true;1554 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1555 },1556 function(){1557 myApp.val.status = myApp.state.Talk;1558 myApp.elem.ansCol.disabled = true;1559 myApp.elem.ansBtn.disabled = true;1560 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1561 },1562 function(){1563 /* 第25å */1564 myApp.val.ansIndex = 50;1565 myApp.val.ansIndexStartTime = 394.07;1566 //1567 myApp.val.status = myApp.state.Question;1568 myApp.val.numQues = 25;1569 myApp.val.cntPush = 0;1570 myApp.val.correctBool = false;1571 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1572 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1573 myApp.elem.ansCol.disabled = true;1574 myApp.elem.ansBtn.disabled = true;1575 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1576 },1577 function(){1578 myApp.val.status = myApp.state.Talk;1579 myApp.elem.ansCol.disabled = true;1580 myApp.elem.ansBtn.disabled = true;1581 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1582 },1583 function(){1584 /* 第26å */1585 myApp.val.ansIndex = 52;1586 myApp.val.ansIndexStartTime = 408.43;1587 //1588 myApp.val.status = myApp.state.Question;1589 myApp.val.numQues = 26;1590 myApp.val.cntPush = 0;1591 myApp.val.correctBool = false;1592 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1593 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1594 myApp.elem.ansCol.disabled = true;1595 myApp.elem.ansBtn.disabled = true;1596 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1597 },1598 function(){1599 myApp.val.status = myApp.state.Talk;1600 myApp.elem.ansCol.disabled = true;1601 myApp.elem.ansBtn.disabled = true;1602 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1603 },1604 function(){1605 /* 第27å */1606 myApp.val.ansIndex = 54;1607 myApp.val.ansIndexStartTime = 424.86;1608 //1609 myApp.val.status = myApp.state.Question;1610 myApp.val.numQues = 27;1611 myApp.val.cntPush = 0;1612 myApp.val.correctBool = false;1613 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1614 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1615 myApp.elem.ansCol.disabled = true;1616 myApp.elem.ansBtn.disabled = true;1617 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1618 },1619 function(){1620 myApp.val.status = myApp.state.Talk;1621 myApp.elem.ansCol.disabled = true;1622 myApp.elem.ansBtn.disabled = true;1623 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1624 },1625 function(){1626 /* 第28å */1627 myApp.val.ansIndex = 56;1628 myApp.val.ansIndexStartTime = 437.53;1629 //1630 myApp.val.status = myApp.state.Question;1631 myApp.val.numQues = 28;1632 myApp.val.cntPush = 0;1633 myApp.val.correctBool = false;1634 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1635 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1636 myApp.elem.ansCol.disabled = true;1637 myApp.elem.ansBtn.disabled = true;1638 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1639 },1640 function(){1641 myApp.val.status = myApp.state.Talk;1642 myApp.elem.ansCol.disabled = true;1643 myApp.elem.ansBtn.disabled = true;1644 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1645 },1646 function(){1647 /* 第29å */1648 myApp.val.ansIndex = 58;1649 myApp.val.ansIndexStartTime = 453.19;1650 //1651 myApp.val.status = myApp.state.Question;1652 myApp.val.numQues = 29;1653 myApp.val.cntPush = 0;1654 myApp.val.correctBool = false;1655 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1656 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1657 myApp.elem.ansCol.disabled = true;1658 myApp.elem.ansBtn.disabled = true;1659 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1660 },1661 function(){1662 myApp.val.status = myApp.state.Talk;1663 myApp.elem.ansCol.disabled = true;1664 myApp.elem.ansBtn.disabled = true;1665 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1666 },1667 function(){1668 /* 第30å */1669 myApp.val.ansIndex = 60;1670 myApp.val.ansIndexStartTime = 468.93;1671 //1672 myApp.val.status = myApp.state.Question;1673 myApp.val.numQues = 30;1674 myApp.val.cntPush = 0;1675 myApp.val.correctBool = false;1676 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1677 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1678 myApp.elem.ansCol.disabled = true;1679 myApp.elem.ansBtn.disabled = true;1680 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1681 },1682 function(){1683 myApp.val.status = myApp.state.Talk;1684 myApp.elem.ansCol.disabled = true;1685 myApp.elem.ansBtn.disabled = true;1686 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1687 },1688];16891169000:00:19,220 --> 00:00:30,26016912169200:00:30,260 --> 00:00:33,44016933169400:00:33,440 --> 00:00:46,69016954169600:00:46,690 --> 00:00:49,66016975169800:00:49,660 --> 00:01:01,83016996170000:01:01,830 --> 00:01:05,74017017170200:01:05,740 --> 00:01:17,83017038170400:01:17,830 --> 00:01:20,78017059170600:01:20,780 --> 00:01:33,070170710170800:01:33,070 --> 00:01:36,200170911171000:01:36,200 --> 00:01:44,110171112171200:01:44,110 --> 00:01:47,400171313171400:01:47,400 --> 00:02:00,200171514171600:02:00,200 --> 00:02:03,770171715171800:02:03,770 --> 00:02:16,730171916172000:02:16,730 --> 00:02:21,210172117172200:02:21,210 --> 00:02:32,220172318172400:02:32,220 --> 00:02:35,370172519172600:02:35,370 --> 00:02:46,800172720172800:02:46,800 --> 00:02:50,380172921173000:02:50,380 --> 00:03:00,540173122173200:03:00,540 --> 00:03:04,260173323173400:03:04,260 --> 00:03:15,260173524173600:03:15,260 --> 00:03:18,590173725173800:03:18,590 --> 00:03:31,410173926174000:03:31,410 --> 00:03:34,350174127174200:03:34,350 --> 00:03:46,770174328174400:03:46,770 --> 00:03:50,870174529174600:03:50,870 --> 00:04:01,760174730174800:04:01,760 --> 00:04:05,000174931175000:04:05,000 --> 00:04:17,990175132175200:04:17,990 --> 00:04:21,420175333175400:04:21,420 --> 00:04:34,940175534175600:04:34,940 --> 00:04:39,260175735175800:04:39,260 --> 00:04:50,350175936176000:04:50,350 --> 00:04:53,800176137176200:04:53,800 --> 00:05:02,480176338176400:05:02,480 --> 00:05:05,480176539176600:05:05,480 --> 00:05:17,070176740176800:05:17,070 --> 00:05:20,480176941177000:05:20,480 --> 00:05:33,880177142177200:05:33,880 --> 00:05:37,350177343177400:05:37,350 --> 00:05:49,540177544177600:05:49,540 --> 00:05:53,840177745177800:05:53,840 --> 00:06:05,930177946178000:06:05,930 --> 00:06:08,870178147178200:06:08,870 --> 00:06:21,070178348178400:06:21,070 --> 00:06:24,450178549178600:06:24,450 --> 00:06:34,070178750178800:06:34,070 --> 00:06:37,080178951179000:06:37,080 --> 00:06:48,430179152179200:06:48,430 --> 00:06:52,010179353179400:06:52,010 --> 00:07:04,860179554179600:07:04,860 --> 00:07:07,780179755179800:07:07,780 --> 00:07:17,530179956180000:07:17,530 --> 00:07:20,170180157180200:07:20,170 --> 00:07:33,190180358180400:07:33,190 --> 00:07:36,930180559180600:07:36,930 --> 00:07:48,930180760...
content-3.srt.js
Source:content-3.srt.js
100:00:00,000 --> 00:00:16,2402/* CAUTION : Each sections of subtitle has independent scope. */3/* Ver1.0 */4doOnce[index] = true;5player.pauseVideo();6//7const myApp = {8 path : {9 answer : "https://raw.githubusercontent.com/t-yokota/quizBattle/master/contents/lamy_abc_12th/answer-1.csv",10 sound : "https://raw.githubusercontent.com/t-yokota/quizBattle/master/sounds/sounds_3", //+ext;11 btn1 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_1.png",12 btn2 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_2.png",13 btn3 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_3.png",14 btn4 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_4.png",15 },16 state : {17 ButtonCheck : 0, //ãã¿ã³ãã§ãã¯å¾
æ©18 Question : 1, //åãèªã¿ä¸ï¼æ©æ¼ãå¯è½ï¼19 MyAnswer : 2, //èªåã解ç権ãææï¼è§£çå
¥åã»éä¿¡å¯è½ï¼20 OthAnswer : 3, //ä»è
ã解ç権ãææï¼æ©æ¼ãä¸å¯è½ï¼21 Talk : 4, //ãã®ä»22 },23 videoState : {24 Playing : 1,25 Stopped : 2,26 },27 elem : {28 text : document.createElement("text"),29 subText : document.createElement("text"),30 ansCol : document.createElement("textarea"),31 ansBtn : document.createElement("button"),32 numOX : document.createElement("text"),33 pushBtn : document.createElement("img"),34 imgBtn1 : document.createElement("img"),35 imgBtn2 : document.createElement("img"),36 imgBtn3 : document.createElement("img"),37 imgBtn4 : document.createElement("img"),38 sounds : document.createElement("audio"),39 paramText : document.createElement("text"),40 //41 divUI : document.createElement('div'),42 divElem : document.createElement('div'),43 divBtn : document.createElement('div'),44 },45 val : {46 srtFuncArray : null, //array of functions that are executed in each subtitle47 viewFuncArray : null, //array of functions for setting view elements48 //49 os : null,50 browser : null,51 //52 touchObject : null,53 //54 audioExt : null,55 audioSpriteData : null,56 //57 loadCount : 0,58 initLoadBool : false,59 loadErrorBool : false,60 loadAlertBool : false,61 //62 initOrientation : null,63 orientationAlertBool : false,64 //65 playingCount : 0,66 pageHiddenBool : false,67 processDelayAlertBool : false,68 //69 composingBool : false,70 //71 disableSeekbarBool : false,72 //73 playerWidth : 0,74 playerHeight : 0,75 pushBtnWidth : 0,76 pushBtnHeight : 0,77 //78 prevPlayerWidth : 0,79 prevPlayerHeight : 0,80 prevClientWidth : 0,81 prevClientHeight : 0,82 //83 elemHeight : 0,84 //85 pushBtnArea : {86 left : 0,87 right : 0,88 top : 0,89 bottom : 0,90 },91 //92 divUIHeight : 0,93 divUIWidth : 0,94 divElemWidth : 0,95 divBtnWidth : 0,96 //97 hidePlayerBool : {98 phone : false,99 other : false,100 },101 //102 /* keycode (for keyboard) */103 space : 32, //push buttion104 enter : 13,105 //106 /* button check param */107 btnCheck : {108 sndInterval : 1500, //[ms]109 playInterval : 3000, //[ms]110 },111 //112 /* for question manegament */113 numQues : 1, //åé¡çªå·114 ansArray : [], //æ£çãªã¹ã115 cntO : 0, //æ£çæ°116 cntX : 0, //誤çæ°117 cntPush : 0, //1åãããã®è§£çåæ°118 limPush : 1, //1åãããã®ä¸é解çåæ°119 correctBool : false, //çãåããçµæ(çµæã«å¿ãã¦ç¶æ
é·ç§»)120 ansFile : new XMLHttpRequest(), //æ£çãã¡ã¤ã«.csv121 //122 /* for status management */123 status : null,124 cntIndex : 0, //(index value has current section of subtitle)125 //126 /* for time management */127 ansTime : {128 limit : 20000, //解çå¶éæé[ms]129 elapsed : 0, //解ççµéæé[ms]130 },131 currTime : {132 playing : 0, //be updated during the video is playing133 stopped : 0, //be updated when the video is stopped134 },135 watchedTime : 0, //136 diffTime : 0, //difference between watchedTime and currentTime (for preventing to jump playback position by seekbar)137 //138 ansIndex: 0,139 ansIndexStartTime : 0,140 jumpToAnsBool: false,141 //142 firstQuesStartTime : 0,143 },144};145//146/* get os type */147myApp.val.os = fetchOSType();148myApp.val.browser = fetchBrowserType();149//150/* set id to the elements */151myApp.elem.ansCol.id = 'anscol';152myApp.elem.ansBtn.id = 'ansbtn';153myApp.elem.pushBtn.id = 'pushbtn';154myApp.elem.divUI.id = 'divui';155myApp.elem.divElem.id = 'divelem';156myApp.elem.divBtn.id = 'divbtn';157//158/* set init value to the elements */159myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";160myApp.elem.ansBtn.innerHTML = "ï¼åç®ã¾ã§ç§»å";161myApp.elem.ansCol.disabled = true;162myApp.elem.ansBtn.disabled = true;163myApp.elem.numOX.innerHTML = "âï¸ï¼"+myApp.val.cntO+"ãâï¼"+myApp.val.cntX;164//165if(myApp.val.os != 'other'){166 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";167}else{168 myApp.elem.text.innerHTML = "QuizBattle on YouTube";169 /* set tabindex for adding focus */170 myApp.elem.pushBtn.tabIndex = 0;171}172//173/* set initial state (button check) */174myApp.val.status = myApp.state.ButtonCheck;175//176/* VIEW */177resizePlayer();178//179/* set style sheets */180document.styleSheets.item(0).insertRule('html { touch-action: manipulation; }'); //disable double tap gesture181document.styleSheets.item(0).insertRule('body { text-align: center; margin: auto; background: #EFEFEF; }');182document.styleSheets.item(0).insertRule('.blinkImg { animation: blinkImg 0.7s infinite alternate; }');183document.styleSheets.item(0).insertRule('@keyframes blinkImg{ 0% { opacity: 0.3; } 100% { opacity: 1; }}');184document.styleSheets.item(0).insertRule('.blinkText { animation: blinkText 0.7s infinite alternate; }');185document.styleSheets.item(0).insertRule('@keyframes blinkText{ 0% { opacity: 0; } 100% { opacity: 1; }}');186//187/* set elements */188if(myApp.val.os != 'other'){189 myApp.elem.text.style.fontSize = '42px';190 myApp.elem.text.style.lineHeight = '60px';191 myApp.elem.text.style.fontWeight = 'bold';192 myApp.elem.text.style.display = 'block';193 myApp.elem.text.style.marginTop = '32px';194 myApp.elem.text.style.marginBottom = '32px';195 myApp.elem.text.style.padding = '0px 10px';196 myApp.elem.subText.style.fontSize = '42px';197 myApp.elem.subText.style.lineHeight = '60px';198 myApp.elem.subText.style.display = 'block';199 myApp.elem.ansCol.style.fontSize = '50px';200 myApp.elem.ansCol.style.height = '100px';201 myApp.elem.ansCol.style.textAlign = 'center';202 myApp.elem.ansCol.style.marginBottom = '10px';203 myApp.elem.ansCol.style.marginLeft = 'auto';204 myApp.elem.ansCol.style.marginRight = 'auto';205 myApp.elem.ansCol.style.display = 'block'206 myApp.elem.ansBtn.style.fontSize = '42px';207 myApp.elem.ansBtn.style.width = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*10+'px';208 myApp.elem.ansBtn.style.height = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*2+'px';209 myApp.elem.ansBtn.style.marginBottom = '20px';210 myApp.elem.ansBtn.style.marginLeft = 'auto';211 myApp.elem.ansBtn.style.marginRight = 'auto';212 myApp.elem.ansBtn.style.display = 'block';213 myApp.elem.numOX.style.fontSize = '42px';214 myApp.elem.numOX.style.lineHeight = '80px';215 myApp.elem.numOX.style.fontWeight = 'bold';216 myApp.elem.numOX.style.display = 'block';217 //218 myApp.val.elemHeight = (function(e){219 let res = 0;220 res += parseInt(e.text.style.lineHeight, 10);221 res += parseInt(e.text.style.marginTop, 10);222 res += parseInt(e.text.style.marginBottom, 10);223 res += parseInt(e.ansCol.style.height, 10);224 res += parseInt(e.ansCol.style.marginBottom, 10);225 res += parseInt(e.ansBtn.style.height, 10);226 res += parseInt(e.ansBtn.style.marginBottom, 10);227 res += parseInt(e.numOX.style.lineHeight, 10);228 return res229 })(myApp.elem);230 //231 myApp.val.viewFuncArray = [232 function(){233 document.getElementsByTagName("body")[0].appendChild(myApp.elem.text);234 document.getElementsByTagName("body")[0].appendChild(myApp.elem.ansBtn);235 document.getElementsByTagName("body")[0].appendChild(myApp.elem.pushBtn);236 document.getElementsByTagName("body")[0].appendChild(myApp.elem.numOX);237 document.getElementsByTagName("body")[0].appendChild(myApp.elem.paramText);238 },239 function(){240 myApp.elem.text.style.marginTop = '40px';241 myApp.elem.text.style.marginBottom = '20px';242 myApp.elem.subText.style.marginBottom = '40px';243 myApp.elem.subText.style.padding = '0px 10px';244 document.getElementsByTagName("body")[0].insertBefore(myApp.elem.subText, myApp.elem.text.nextSibling);245 },246 function(){247 myApp.elem.text.style.marginTop = '32px';248 myApp.elem.text.style.marginBottom = '32px';249 myApp.elem.text.parentNode.removeChild(myApp.elem.subText);250 document.getElementsByTagName("body")[0].insertBefore(myApp.elem.ansCol, myApp.elem.text.nextSibling);251 },252 ];253 myApp.val.viewFuncArray.shift()();254}else{255 myApp.val.divUIHeight = myApp.val.playerHeight*0.9;256 myApp.val.divUIWidth = myApp.val.playerWidth;257 myApp.val.divElemWidth = myApp.val.playerWidth*2/3;258 myApp.val.divBtnWidth = myApp.val.playerWidth*1/3;259 document.styleSheets.item(0).insertRule('body { width:'+myApp.val.playerWidth+'px; }');260 document.styleSheets.item(0).insertRule('div#divui { width:'+myApp.val.divUIWidth +'px; height:'+myApp.val.divUIHeight+'px; }');261 document.styleSheets.item(0).insertRule('div#divelem { width:'+myApp.val.divElemWidth+'px; height:'+myApp.val.divUIHeight+'px; float: left; display: flex; align-items: center; justify-content: center; flex-direction: column; }');262 document.styleSheets.item(0).insertRule('div#divbtn { width:'+myApp.val.divBtnWidth +'px; height:'+myApp.val.divUIHeight+'px; float: left; display: flex; align-items: center; justify-content: center; }');263 document.getElementsByTagName("body")[0].appendChild(myApp.elem.divUI);264 myApp.elem.divUI.appendChild(myApp.elem.divElem); //divElem is assigned to ('div')[4]265 myApp.elem.divUI.appendChild(myApp.elem.divBtn); //divBtn is assigned to ('div')[5]266 //267 myApp.elem.text.style.fontSize = '25px';268 myApp.elem.text.style.lineHeight = '45px';269 myApp.elem.text.style.fontWeight = 'bold';270 myApp.elem.text.style.display = 'block';271 myApp.elem.subText.style.fontSize = '20px';272 myApp.elem.subText.style.lineHeight = '30px';273 myApp.elem.subText.style.display = 'block';274 myApp.elem.ansCol.style.fontSize = '23px';275 myApp.elem.ansCol.style.textAlign = 'center';276 myApp.elem.ansCol.style.width = myApp.val.divElemWidth*0.75+'px';277 myApp.elem.ansCol.style.margin = '0px ' +(myApp.val.divElemWidth-parseInt(myApp.elem.ansCol.style.width, 10))/2+'px 15px';278 myApp.elem.ansBtn.style.fontSize = '23px';279 myApp.elem.ansBtn.style.width = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*8+'px';280 myApp.elem.ansBtn.style.margin = '0px '+(myApp.val.divElemWidth-parseInt(myApp.elem.ansBtn.style.width, 10))/2+'px 20px';281 myApp.elem.numOX.style.fontSize = '25px';282 myApp.elem.numOX.style.lineHeight = '45px';283 myApp.elem.numOX.style.fontWeight = 'bold';284 myApp.elem.numOX.style.display = 'block';285 //286 myApp.val.viewFuncArray = [287 function(){288 myApp.elem.text.style.margin = '0px auto';289 myApp.elem.text.style.padding = '0px 40px';290 document.getElementsByTagName("div")[4].appendChild(myApp.elem.text);291 document.getElementsByTagName("div")[4].appendChild(myApp.elem.paramText);292 },293 function(){294 myApp.elem.text.style.margin = '0px auto 30px';295 myApp.elem.subText.style.margin = '0px auto 50px';296 myApp.elem.subText.style.padding = '0px 40px';297 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.subText, myApp.elem.text.nextSibling);298 document.getElementsByTagName("div")[5].appendChild(myApp.elem.pushBtn);299 },300 function(){301 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.ansBtn, myApp.elem.subText.nextSibling);302 },303 function(){304 myApp.elem.text.style.margin = '0px auto 15px';305 myApp.elem.text.parentNode.removeChild(myApp.elem.subText);306 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.ansCol, myApp.elem.text.nextSibling);307 document.getElementsByTagName("div")[4].appendChild(myApp.elem.numOX);308 },309 ];310 myApp.val.viewFuncArray.shift()();311}312//313const num_of_materials = 6;314myApp.elem.sounds.onloadedmetadata = function(){ myApp.val.loadCount += 1; };315myApp.elem.imgBtn1.onload = function(){ myApp.val.loadCount += 1; };316myApp.elem.imgBtn2.onload = function(){ myApp.val.loadCount += 1; };317myApp.elem.imgBtn3.onload = function(){ myApp.val.loadCount += 1; };318myApp.elem.imgBtn4.onload = function(){ myApp.val.loadCount += 1; };319myApp.val.ansFile.onload = function(){ myApp.val.loadCount += 1; myApp.val.ansArray = CSVtoArray(myApp.val.ansFile.responseText); };320//321myApp.elem.sounds.onerror = function(){ myApp.val.loadErrorBool = true; };322myApp.elem.imgBtn1.onerror = function(){ myApp.val.loadErrorBool = true; };323myApp.elem.imgBtn2.onerror = function(){ myApp.val.loadErrorBool = true; };324myApp.elem.imgBtn3.onerror = function(){ myApp.val.loadErrorBool = true; };325myApp.elem.imgBtn4.onerror = function(){ myApp.val.loadErrorBool = true; };326myApp.val.ansFile.onerror = function(){ myApp.val.loadErrorBool = true; };327//328/* load audio data */329if (myApp.elem.sounds.canPlayType('audio/mp3') == 'probably'){ myApp.val.audioExt = '.mp3'; }330else if(myApp.elem.sounds.canPlayType('audio/aac') == 'probably'){ myApp.val.audioExt = '.aac'; }331else if(myApp.elem.sounds.canPlayType('audio/wav') == 'probably'){ myApp.val.audioExt = '.wav'; }332else if(myApp.elem.sounds.canPlayType('audio/mp3') == 'maybe' ){ myApp.val.audioExt = '.mp3'; }333else if(myApp.elem.sounds.canPlayType('audio/aac') == 'maybe' ){ myApp.val.audioExt = '.aac'; }334else if(myApp.elem.sounds.canPlayType('audio/wav') == 'maybe' ){ myApp.val.audioExt = '.wav'; }335myApp.elem.sounds.src = myApp.path.sound+myApp.val.audioExt;336//337/* load push button image */338myApp.elem.imgBtn1.src = myApp.path.btn1;339myApp.elem.imgBtn2.src = myApp.path.btn2;340myApp.elem.imgBtn3.src = myApp.path.btn3;341myApp.elem.imgBtn4.src = myApp.path.btn4;342if(myApp.val.os != 'other'){343 myApp.elem.pushBtn.className = "blinkImg";344}345//346/* load answer file */347myApp.val.ansFile.open("get", myApp.path.answer, true);348myApp.val.ansFile.send(null);349//350/* set audio sprite */351myApp.val.audioSpriteData = {352 pushBtn : { start : 0.0, end : 2.0 }, //[sec]353 sndO : { start : 3.0, end : 5.0 }, 354 sndX : { start : 6.0, end : 8.0 },355};356myApp.elem.sounds.addEventListener('timeupdate', spriteHandler, false);357function spriteHandler(){358 if(Math.abs(myApp.val.audioSpriteData.pushBtn.end - this.currentTime) < 0.25){359 this.pause();360 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;361 }362 if(Math.abs(myApp.val.audioSpriteData.sndO.end - this.currentTime) < 0.25){363 this.pause();364 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;365 }366 if(Math.abs(myApp.val.audioSpriteData.sndX.end - this.currentTime) < 0.25){367 this.pause();368 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;369 }370};371//372/* set function executed after initial loading */373myApp.elem.pushBtn.onerror = function(){374 myApp.val.loadErrorBool = true;375 myApp.val.loadAlertBool = true;376 alert("ç»åã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã" );377};378myApp.elem.pushBtn.onload = function(){379 if(myApp.val.initLoadBool == false){380 /* change player and push button size after loading image */381 resizePlayer();382 resizePushButton();383 myApp.val.initLoadBool = true;384 if(myApp.val.os == 'other'){ myApp.val.viewFuncArray.shift()(); }385 }386};387function materialCheckFunction(){388 if(myApp.val.loadErrorBool == false){389 if(myApp.val.initLoadBool == false && myApp.val.loadCount == num_of_materials){390 myApp.val.loadCount = 0;391 /* assign push button image and main text */392 myApp.elem.pushBtn.width = document.documentElement.clientWidth/5; /* init size before loading */393 if(myApp.val.os != "other"){394 if(Math.abs(window.orientation) != 90){395 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;396 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";397 myApp.val.initOrientation = 'portrait';398 }else{399 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;400 myApp.elem.text.innerHTML = "端æ«ã縦åãã«ãã¦ã¯ã¤ãºãã¯ããã";401 myApp.val.initOrientation = 'landscape';402 alert("ãã®ãµã¤ãã¯ã¹ãã¼ããã©ã³/ã¿ãã¬ããã縦åãã«ãã¦ã楽ãã¿ãã ããã");403 }404 }else{405 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;406 if(detectTouchPanel() == true){407 myApp.elem.subText.innerHTML = "<span class='blinkText'>ã¹ãã¼ã¹ãã¼ãæ¼ãã¦åç»ãéå§ãã</span>";408 }else{409 myApp.elem.subText.innerHTML = "<span class='blinkText'>ã¹ãã¼ã¹ãã¼ãæ¼ãã¦åç»ãéå§ãã</span>";410 }411 }412 }else if(myApp.val.initLoadBool == true && myApp.val.loadAlertBool == false){413 if(myApp.val.os != 'other'){414 if(Math.abs(myApp.elem.numOX.getBoundingClientRect().top - myApp.elem.ansBtn.getBoundingClientRect().bottom) < 50){415 myApp.val.loadErrorBool = true;416 myApp.val.loadAlertBool = true;417 player.pauseVideo();418 alert("ç»åã®è¡¨ç¤ºã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã");419 }420 }421 }422 }else{423 if(myApp.val.loadAlertBool == false){424 myApp.val.loadAlertBool = true;425 alert("ãã¼ã¸ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã");426 }427 }428}429//430/* EVENT */431/* orientation change event function */432window.addEventListener('orientationchange', myOrientationChangeEvent);433function myOrientationChangeEvent(){434 setTimeout(function(){435 resizePlayer();436 resizePushButton();437 if(myApp.val.status == myApp.state.MyAnswer){438 if(myApp.val.hidePlayerBool.phone == true){439 hidePlayer();440 }441 }442 if(Math.abs(window.orientation) != 90){443 if(myApp.val.status == myApp.state.MyAnswer){444 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;445 }else{446 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;447 }448 if(myApp.val.status == myApp.state.ButtonCheck){449 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";450 }451 }else{452 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;453 if(myApp.val.status == myApp.state.ButtonCheck){454 myApp.elem.text.innerHTML = "端æ«ã縦åãã«ãã¦ã¯ã¤ãºãã¯ããã";455 }456 if(myApp.val.orientationAlertBool == false && myApp.val.initOrientation == 'portrait'){457 myApp.val.playingCount = -10;458 myApp.val.orientationAlertBool = true;459 alert("ãã®ãµã¤ãã¯ã¹ãã¼ããã©ã³/ã¿ãã¬ããã縦åãã«ãã¦ã楽ãã¿ãã ããã");460 }461 }462 }, 800);463}464//465/* page hidden check event function */466document.addEventListener('webkitvisibilitychange', myPageHiddenCheckEvent, false);467function myPageHiddenCheckEvent(){468 if(document.webkitHidden){469 myApp.val.pageHiddenBool = true;470 // console.log('Hidden.');471 }else{472 myApp.val.pageHiddenBool = false;473 myApp.val.currTime.playing = player.getCurrentTime();474 myApp.val.watchedTime = myApp.val.currTime.playing;475 myApp.val.playingCount = 0;476 // console.log('Opened.');477 }478}479//480/* keydown event function */481document.onkeydown = myKeyDownEvent;482//483document.addEventListener("compositionstart", function(){ myApp.val.composingBool = true; });484document.addEventListener('compositionend', function(){ myApp.val.composingBool = false; });485function myKeyDownEvent(){486 if(myApp.val.loadErrorBool == false && myApp.val.initLoadBool == true && Math.abs(window.orientation) != 90){487 if(event.keyCode == myApp.val.space){488 myButtonAction();489 }490 /* prevent to start new line in text area */491 if(event.keyCode == myApp.val.enter){492 if(myApp.val.composingBool == false){493 return false;494 }495 }496 }497}498//499/* touchstart event function (for smartphonea and tablet) */500document.addEventListener("touchstart", myTouchEvent);501function myTouchEvent(event){502 if(myApp.val.loadErrorBool == false && myApp.val.initLoadBool == true && Math.abs(window.orientation) != 90){503 myApp.val.touchObject = event.changedTouches[0];504 if(myApp.val.pushBtnArea.left < myApp.val.touchObject.pageX && myApp.val.touchObject.pageX < myApp.val.pushBtnArea.right){505 if(myApp.val.pushBtnArea.top < myApp.val.touchObject.pageY && myApp.val.touchObject.pageY < myApp.val.pushBtnArea.bottom){506 myButtonAction();507 }508 }509 }510}511//512/* common button action */513function myButtonAction(){514 if(myApp.val.status == myApp.state.ButtonCheck){515 myApp.val.status = myApp.state.Talk;516 myApp.elem.pushBtn.className = "";517 buttonCheck(myApp.val.btnCheck.sndInterval);518 setTimeout(function(){519 player.playVideo();520 myApp.elem.ansBtn.disabled = false;521 if(myApp.val.os != 'other'){522 myApp.val.viewFuncArray.shift()();523 myApp.elem.text.innerHTML = "ï¼ éã³æ¹ ï¼";524 myApp.elem.subText.innerHTML = "ç»é¢ä¸ã®æ©æ¼ããã¿ã³ã§<br>åç»å
ã®ã¯ã¤ãºã«åå ãããã¨ãã§ãã¾ã";525 }else{526 myApp.val.viewFuncArray.shift()();527 myApp.elem.text.innerHTML = "ï¼ éã³æ¹ ï¼"528 myApp.elem.subText.innerHTML = "ã¹ãã¼ã¹ãã¼ãæ©æ¼ããã¿ã³ã«ãã¦<br>åç»å
ã®ã¯ã¤ãºã«åå ãããã¨ãã§ãã¾ã";529 }530 }, myApp.val.btnCheck.playInterval);531 }532 if(myApp.val.status == myApp.state.Question){533 myApp.val.status = myApp.state.MyAnswer;534 player.pauseVideo();535 pushButton();536 }537}538//539/* player's state change event function */540player.addEventListener('onStateChange', myPlayerStateChangeEvent);541function myPlayerStateChangeEvent(){542 if(player.getPlayerState() == myApp.videoState.Playing){543 myApp.val.currTime.playing = player.getCurrentTime();544 myApp.val.watchedTime = updateWatchedTime(myApp.val.currTime.playing, myApp.val.watchedTime);545 /* check answer if the video is restarted manually without sending answer */546 if(myApp.val.status == myApp.state.MyAnswer){547 player.pauseVideo();548 checkAnswer();549 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){550 myApp.val.status = myApp.state.Talk;551 }else{552 myApp.val.status = myApp.state.Question;553 }554 player.playVideo();555 }556 if(myApp.val.disableSeekbarBool == true){557 /* prevent to jump playback position by seekbar */558 if(myApp.val.status == myApp.state.Question){559 myApp.val.diffTime = Math.abs(myApp.val.currTime.playing - myApp.val.watchedTime);560 if(myApp.val.diffTime > 1.0){561 player.seekTo(myApp.val.watchedTime);562 }563 }else{564 myApp.val.diffTime = Math.abs(myApp.val.currTime.playing - myApp.val.watchedTime);565 // myApp.val.diffTime = myApp.val.currTime.playing - myApp.val.watchedTime; /* allow to jump to previous positon on timeline */566 if(myApp.val.diffTime > 1.0){567 player.seekTo(myApp.val.watchedTime);568 }569 }570 }571 }572 if(player.getPlayerState() == myApp.videoState.Stopped){573 myApp.val.currTime.stopped = player.getCurrentTime();574 if(myApp.val.disableSeekbarBool == true){575 /* prevent to jump video playback position by seekbar */576 /* and prevent to pause video during each question */577 if(myApp.val.status == myApp.state.Question || myApp.val.status == myApp.state.OthAnswer){578 myApp.val.diffTime = Math.abs(myApp.val.currTime.stopped - myApp.val.watchedTime);579 if(myApp.val.diffTime > 1.0){580 player.seekTo(myApp.val.watchedTime);581 }582 player.playVideo();583 }else{584 myApp.val.diffTime = Math.abs(myApp.val.currTime.stopped - myApp.val.watchedTime);585 // myApp.val.diffTime = myApp.val.currTime.stopped - myApp.val.watchedTime; /* allow to jump to previous position on timeline */586 if(myApp.val.diffTime > 1.0){587 player.seekTo(myApp.val.watchedTime);588 player.playVideo(); /* allow to pause video except during the question status */589 }590 // player.playVideo();591 }592 }593 }594}595//596/* interval event function that are executed at a certain interval */597setInterval(myIntervalEvent, interval = 10);598function myIntervalEvent(){599 if(myApp.val.pageHiddenBool == false){600 if(player.getPlayerState() == myApp.videoState.Playing){601 myApp.val.currTime.playing = player.getCurrentTime();602 myApp.val.watchedTime = updateWatchedTime(myApp.val.currTime.playing, myApp.val.watchedTime);603 if(myApp.val.disableSeekbarBool == true){604 /* check delay of processing */605 if(myApp.val.playingCount < 0 ){ myApp.val.watchedTime = myApp.val.currTime.playing; } // fix delay of watchedTime caused by showing orientation alert.606 if(myApp.val.playingCount < 10){ myApp.val.playingCount += 1; }ã// allow initial delay of watchedTime just after playing video.607 if(myApp.val.currTime.playing - myApp.val.watchedTime > 1.0 && myApp.val.playingCount >= 10){608 if(myApp.val.processDelayAlertBool == false){609 myApp.val.processDelayAlertBool = true;610 alert('ãã¼ã¸å
ã®å¦çãé
ããªã£ã¦ãã¾ããæ©æ¼ãã®å¤å®ã«æ¯éãåºãå¯è½æ§ããããããä»ã®ããã»ã¹ãçµäºãã¦ããæ¹ãã¦ã¯ã¤ãºãã楽ãã¿ãã ããããã®ãããã¢ããã¯ä¸åº¦ã®ã¿è¡¨ç¤ºããã¾ãã');611 }612 myApp.val.watchedTime = myApp.val.currTime.playing;613 }614 }615 /* prevent to play video before button check */616 if(myApp.val.status == myApp.state.ButtonCheck){617 player.pauseVideo();618 }619 /* execute srt function in each sections of subtitle */620 if(myApp.val.status != myApp.state.MyAnswer){621 if(myApp.val.disableSeekbarBool == true){622 if(index - myApp.val.cntIndex == 1){623 myApp.val.srtFuncArray.shift()();624 myApp.val.cntIndex += 1;625 }626 }else{627 if(index - myApp.val.cntIndex >= 1){628 for(let i = 0; i < index-myApp.val.cntIndex; i++){629 myApp.val.srtFuncArray.shift()();630 }631 myApp.val.cntIndex = index;632 // console.log(myApp.val.cntIndex);633 }634 }635 }636 }else if(player.getPlayerState() == myApp.videoState.Stopped){637 myApp.val.playingCount = 0;638 }639 if(myApp.val.status == myApp.state.ButtonCheck){640 if(myApp.val.cntIndex > 0 && myApp.val.loadAlertBool == false){641 myApp.val.loadErrorBool = true;642 myApp.val.loadAlertBool = true;643 player.pauseVideo();644 alert('ãã¼ã¸ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã');645 }646 }647 if(myApp.val.status == myApp.state.MyAnswer){648 /* reforcus when anscol is blank */649 // if(document.activeElement.id != "anscol" && myApp.elem.ansCol.value.valueOf() === ""){650 // myApp.elem.ansCol.focus();651 // }652 /* answer time managemant */653 if(document.activeElement.id == "anscol" || myApp.val.ansTime.elapsed != 0){654 myApp.val.ansTime.elapsed += interval;655 myApp.elem.text.innerHTML = "ã®ãã"+Math.floor((myApp.val.ansTime.limit-myApp.val.ansTime.elapsed)/1000+1)+"ç§";656 if(myApp.val.ansTime.elapsed >= myApp.val.ansTime.limit){657 checkAnswer();658 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){659 myApp.val.status = myApp.state.Talk;660 }else{661 myApp.val.status = myApp.state.Question;662 }663 player.playVideo();664 }665 }666 }else{667 if(myApp.val.os == 'other' && document.activeElement.id == "player"){668 /* preparation of js keydown event */669 instantFocusToElement(myApp.elem.pushBtn);670 }671 myApp.val.ansTime.elapsed = 0;672 }673 /* check results of importing material */674 materialCheckFunction();675 /* update push button area (mainly for when the window is zoomed in iOS)*/676 updatePushButtonArea();677 /* print parameters for debug */678 printParams();679 }680}681//682/* onclick event function of send answer button */683myApp.elem.ansBtn.onclick = myOnClickEvent;684function myOnClickEvent(){685 /* jump to init question */686 if(index == 0){687 let tmpTime = myApp.val.firstQuesStartTime-0.1;688 if(myApp.val.currTime.playing < tmpTime){689 myApp.elem.ansBtn.disabled = true;690 myApp.val.watchedTime = tmpTime;691 player.seekTo(tmpTime);692 }693 }694 /* send answer */695 if(myApp.val.status == myApp.state.MyAnswer){696 checkAnswer();697 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){698 myApp.val.status = myApp.state.Talk;699 }else{700 myApp.val.status = myApp.state.Question;701 }702 player.playVideo();703 }704}705//706/* onfocus event function of answer column */707myApp.elem.ansCol.onfocus = function(){ myApp.elem.ansCol.val = ""; }708//709/* FUNCTION */710function detectTouchPanel(){711 return window.ontouchstart === null;712}713//714function fetchOSType(){715 let osType = null;716 const ua = navigator.userAgent;717 if(ua.match(/Android/)){718 osType = "Android";719 return osType;720 }else if(ua.match(/iPhone/)) {721 osType = "iOS"; // iPhone OS722 return osType;723 }else if(ua.match(/iPad/)) {724 osType = "iOS"; // iPad OS725 return osType;726 }else if(ua.match(/Macintosh/) && detectTouchPanel() == true){727 osType = 'iOS'; // iPad OS with Safari728 return osType;729 }else{730 osType = "other";731 return osType;732 }733}734//735function fetchBrowserType(){736 let bwType = null;737 const ua = navigator.userAgent;738 if(ua.match(/Firefox/)){739 bwType = "Firefox";740 return bwType;741 }else if(ua.match(/EdgiOS/) || ua.match(/EdgA/)){742 bwType = "Edge";743 return bwType;744 }else if(ua.match(/OPR/)){745 bwType = "Opera";746 return bwType;747 }else if(ua.match(/OPT/)){748 bwType = "OperaTouch";749 return bwType;750 }else if(ua.match(/YJApp/)){751 bwType = "Yahoo";752 return bwType;753 }else if(ua.match(/Smooz/)){754 bwType = "Smooz";755 return bwType;756 }else if(ua.match(/CriOS/) || ua.match(/Chrome/)){757 //Chrome or Others ...758 bwType = "Chrome";759 return bwType;760 }else{761 //Safari, Firefox(iOS), Brave or Others ...762 bwType = "Other";763 return bwType;764 }765}766/**767 * @param {string} str768 * @returns {array} (rows: num of question, columns: num of patterns of answerï¼769 */770function CSVtoArray(str){771 const array = new Array();772 const tmp = str.split("\r\n");773 for(let i = 0; i < tmp.length; i++){774 array[i] = tmp[i].split(",");775 }776 return array;777}778//779function resizePlayer(){780 if(myApp.val.os != 'other'){781 if(Math.abs(window.orientation) != 90){782 // myApp.val.playerWidth = document.documentElement.clientWidth;783 if(myApp.val.os == 'Android'){ myApp.val.playerWidth = window.innerWidth; } // In Android, clientWidth doesn't include scrollbar.784 if(myApp.val.os == 'iOS'){ myApp.val.playerWidth = document.documentElement.clientWidth; } // In iOS, innerWidth isn't static (it changes with device orientation).785 myApp.val.playerHeight = myApp.val.playerWidth/16*9;786 }else{787 myApp.val.playerWidth = document.documentElement.clientWidth*2/3;788 myApp.val.playerHeight = myApp.val.playerWidth/16*9;789 }790 /* set special width of anscol to prevent the window is zoomed when the focus moveds to anscol */791 if(myApp.val.os == 'Android' && myApp.val.browser == "Firefox"){792 myApp.elem.ansCol.style.width = myApp.val.playerWidth*0.98+'px';793 }else{794 myApp.elem.ansCol.style.width = myApp.val.playerWidth*0.9+'px';795 }796 }else{797 const tmpPlayerHeight = document.documentElement.clientHeight/2;798 const tmpPlayerWidth = tmpPlayerHeight/9*16;799 if(tmpPlayerWidth < document.documentElement.clientWidth){800 myApp.val.playerHeight = tmpPlayerHeight;801 myApp.val.playerWidth = tmpPlayerWidth;802 }else{803 myApp.val.playerWidth = document.documentElement.clientWidth;804 myApp.val.playerHeight = myApp.val.playerWidth/16*9;805 }806 }807 if(myApp.val.initLoadBool == false || myApp.val.prevPlayerWidth != myApp.val.playerWidth){808 player.setSize(myApp.val.playerWidth, myApp.val.playerHeight);809 //810 myApp.val.prevPlayerWidth = myApp.val.playerWidth;811 myApp.val.prevPlayerHeight = myApp.val.playerHeight;812 }813}814//815function resizePushButton(){816 if(myApp.val.os != "other"){817 if(Math.abs(window.orientation) != 90){818 const tmpImgHeight = document.documentElement.clientHeight-myApp.val.playerHeight-myApp.val.elemHeight-20;819 const tmpImgWidth = myApp.elem.pushBtn.naturalWidth*tmpImgHeight/myApp.elem.pushBtn.naturalHeight;820 if(tmpImgWidth < document.documentElement.clientWidth){821 if(tmpImgHeight <= myApp.val.playerHeight){822 myApp.val.pushBtnWidth = tmpImgWidth;823 myApp.val.pushBtnHeight = tmpImgHeight;824 }else{825 myApp.val.pushBtnWidth = myApp.elem.pushBtn.naturalWidth*myApp.val.playerHeight*1.25/myApp.elem.pushBtn.naturalHeight;826 myApp.val.pushBtnHeight = myApp.val.playerHeight*1.25;827 }828 }else{829 myApp.val.pushBtnWidth = document.documentElement.clientWidth/5;830 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;831 }832 }else{833 myApp.val.pushBtnWidth = document.documentElement.clientWidth/5;834 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;835 }836 myApp.elem.pushBtn.style.margin = 'auto '+(document.documentElement.clientWidth-myApp.val.pushBtnWidth)/2+'px';837 }else{838 myApp.val.pushBtnWidth = myApp.val.divBtnWidth;839 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;840 } 841 if(myApp.val.initLoadBool == false || myApp.val.prevClientHeight != document.documentElement.clientHeight){842 myApp.elem.pushBtn.width = myApp.val.pushBtnWidth;843 myApp.elem.pushBtn.height = myApp.val.pushBtnHeight;844 updatePushButtonArea();845 //846 myApp.val.prevClientWidth = document.documentElement.clientWidth;847 myApp.val.prevClientHeight = document.documentElement.clientHeight;848 }849}850//851function updatePushButtonArea(){852 myApp.val.pushBtnArea.left = myApp.elem.pushBtn.getBoundingClientRect().left;853 myApp.val.pushBtnArea.right = myApp.elem.pushBtn.getBoundingClientRect().right;854 myApp.val.pushBtnArea.top = myApp.elem.pushBtn.getBoundingClientRect().top;855 myApp.val.pushBtnArea.bottom = myApp.elem.pushBtn.getBoundingClientRect().bottom;856 //857 /* In iOS, value of getBoundingClientRect is changed when the window is zoomed */858 if(myApp.val.os == 'iOS'){859 myApp.val.pushBtnArea.left += window.pageXOffset;860 myApp.val.pushBtnArea.right += window.pageXOffset;861 myApp.val.pushBtnArea.top += window.pageYOffset;862 myApp.val.pushBtnArea.bottom += window.pageYOffset;863 }864}865//866function instantFocusToElement(focusUsableElement){867 /* keydown event is ready during the focus is in a js element */868 focusUsableElement.disabled = false;869 focusUsableElement.focus();870 focusUsableElement.blur();871 focusUsableElement.disabled = true;872}873//874function updateWatchedTime(currentPlayingTime, watchedTime){875 if(0.0 < currentPlayingTime - watchedTime && currentPlayingTime - watchedTime < 1.0){876 watchedTime = currentPlayingTime;877 }878 return watchedTime;879}880//881function playSndPushBtn(){882 if(myApp.elem.sounds.currentTime != myApp.val.audioSpriteData.pushBtn.start){883 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;884 }885 myApp.elem.sounds.play();886}887//888function playSndO(){889 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.sndO.start;890 myApp.elem.sounds.play();891}892//893function playSndX(){894 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.sndX.start;895 myApp.elem.sounds.play();896}897//898function hidePlayer(){899 player.setSize(myApp.val.playerWidth, 0);900}901//902function opposePlayer(){903 player.setSize(myApp.val.playerWidth, myApp.val.playerHeight);904}905//906function buttonCheck(responseInterval){907 playSndPushBtn();908 if(myApp.val.os == 'iOS'){909 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;910 }else{911 myApp.elem.pushBtn.src = myApp.elem.imgBtn2.src;912 setTimeout(function(){ myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src; }, 100);913 }914 setTimeout(function(){915 playSndO();916 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;917 }, responseInterval);918}919//920function pushButton(){921 // hide player during answer.922 if(myApp.val.os != 'other'){923 if(myApp.val.hidePlayerBool.phone == true){924 hidePlayer();925 }926 }else{927 if(myApp.val.hidePlayerBool.other == true){928 hidePlayer();929 }930 }931 playSndPushBtn();932 if(myApp.val.os == 'iOS'){933 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;934 if(myApp.val.browser == 'Chrome' || myApp.val.browser == 'Edge' || myApp.val.browser == 'Smooz'){935 setTimeout(function(){ focusToAnsCol(); }, 500); // In above browsers, focus() doesn't work by the script below.936 }else{937 focusToAnsCol(); // In iOS, focus() doesn't work properly in setTimeout (keyboard doesn't appear).938 }939 }else{940 myApp.elem.pushBtn.src = myApp.elem.imgBtn2.src;941 setTimeout(function(){ myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src; }, 100); 942 setTimeout(function(){ focusToAnsCol(); }, 500);943 }944 myApp.val.cntPush = myApp.val.cntPush+1;945}946//947function focusToAnsCol(){948 myApp.elem.ansBtn.disabled = false;949 myApp.elem.ansCol.disabled = false;950 myApp.elem.ansCol.value = "";951 myApp.elem.ansCol.focus();952}953//954function checkAnswer(){955 myApp.val.correctBool = false;956 myApp.elem.ansCol.blur();957 myApp.elem.ansCol.disabled = true;958 myApp.elem.ansBtn.disabled = true;959 const answer = myApp.elem.ansCol.value;960 const length = myApp.val.ansArray[myApp.val.numQues-1].length;961 for(let i = 0; i < length; i++){962 if(answer.valueOf() === myApp.val.ansArray[myApp.val.numQues-1][i].valueOf()){963 myApp.val.correctBool = true;964 }965 }966 if(myApp.val.correctBool == true){967 playSndO();968 myApp.val.cntO += 1;969 myApp.elem.text.innerHTML = "æ£è§£ï¼";970 if(myApp.val.jumpToAnsBool){ jumpToAnswerIndex(myApp.val.ansIndex, myApp.val.ansIndexStartTime); }971 }else{972 playSndX();973 myApp.val.cntX += 1;974 myApp.elem.text.innerHTML = "ä¸æ£è§£ï¼"; //ãã¨"+(myApp.val.limPush-myApp.val.cntPush)+"å解çã§ãã¾ãã";975 if(myApp.val.jumpToAnsBool){ jumpToAnswerIndex(myApp.val.ansIndex, myApp.val.ansIndexStartTime); }976 }977 myApp.elem.numOX.innerHTML = "âï¸ï¼"+myApp.val.cntO+"ãâï¼"+myApp.val.cntX;978 if(window.orientation != 90){979 if(myApp.val.correctBool == false && myApp.val.limPush - myApp.val.cntPush == 0){980 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;981 }else{982 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;983 }984 }else{985 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;986 }987 // oppose player after answer.988 if(myApp.val.os != 'other'){989 if(myApp.val.hidePlayerBool.phone == true){990 opposePlayer();991 }992 }else{993 if(myApp.val.hidePlayerBool.other == true){994 opposePlayer();995 }996 }997}998//999function jumpToAnswerIndex(index, time){1000 myApp.val.cntIndex = index-1;1001 myApp.val.watchedTime = time-0.1;1002 player.seekTo(time-0.1);1003}1004//1005function printParams(){1006 // myApp.elem.paramText.innerHTML = "timePlay: " + myApp.val.currTime.playing.toFixed(3)+"<br>"+1007 // "timeStop: " +myApp.val.currTime.stopped.toFixed(3)+"<br>"+1008 // "WatchedTime: " + myApp.val.watchedTime.toFixed(3)+"<br>"+1009 // "diffTime: " + myApp.val.diffTime.toFixed(3);1010 // myApp.elem.paramText.innerHTML = myApp.val.browser;1011 // myApp.elem.paramText.innerHTML = myApp.val.os + ', ' + navigator.userAgent;1012 // myApp.elem.paramText.innerHTML = document.styleSheets.item(0).cssRules;1013 // myApp.elem.subText.innerHTML = "sounds.currentTime: " + Math.abs(Math.floor(myApp.elem.sounds.currentTime*1000)/1000);1014 // myApp.elem.subText.innerHTML = Math.floor(myApp.val.touchObject.pageX) +', '+ Math.floor(myApp.val.touchObject.pageY) +' '+1015 // '[' + Math.floor(myApp.val.pushBtnArea.left) +', '+ Math.floor(myApp.val.pushBtnArea.right) +'] '+1016 // '[' + Math.floor(myApp.val.pushBtnArea.top) +', '+ Math.floor(myApp.val.pushBtnArea.bottom)+'] '+1017 // '| '+ window.pageXOffset +', '+ window.pageYOffset;1018 // myApp.elem.subText.innerHTML = myApp.elem.numOX.getBoundingClientRect().top - myApp.elem.ansBtn.getBoundingClientRect().bottom;1019 // myApp.elem.subText.innerHTML = 'loadErrorBool: ' + myApp.val.loadErrorBool + ', initLoadBool: ' + myApp.val.initLoadBool + ', loadCount: ' + myApp.val.loadCount;1020 // myApp.elem.subText.innerHTML = 'playerWidth: ' + myApp.val.playerWidth + ', innerWidth: ' + window.innerWidth;1021 // myApp.elem.paramText.innerHTML = "<br>"+ 1022 // "device: " + myApp.val.os+"<br>"+1023 // "browser: " + myApp.val.browser+"<br>"+1024 // "activeElem: " + document.activeElement.id+"<br>"+ 1025 // "status: " + myApp.val.status+"<br>"+1026 // "timePlay: " + myApp.val.currTime.playing.toFixed(3)+"<br>"+1027 // "timeStop: " + myApp.val.currTime.stopped.toFixed(3)+"<br>"+1028 // "WatchedTime: " + myApp.val.watchedTime.toFixed(3)+"<br>"+1029 // "diffTime: " + myApp.val.diffTime.toFixed(3)+"<br>"+1030 // "limPush: " + myApp.val.limPush+"<br>"+ 1031 // "cntPush: " + myApp.val.cntPush+"<br>"+1032 // "remainingAnsTime: " + Math.floor((myApp.val.ansTime.limit-myApp.val.ansTime.elapsed)/1000)+"<br>"+1033 // "answer: " + myApp.val.ansArray[myApp.val.numQues-1][0].valueOf()+", "+1034 // myApp.val.ansArray[myApp.val.numQues-1][1].valueOf()+", "+1035 // myApp.val.ansArray[myApp.val.numQues-1][2].valueOf()+", "+1036 // myApp.val.ansArray[myApp.val.numQues-1][3].valueOf()+", "+1037 // myApp.val.ansArray[myApp.val.numQues-1][4].valueOf()+", "+1038 // myApp.val.ansArray[myApp.val.numQues-1][5].valueOf()+"<br>"+1039 // "numAnswer: " + myApp.val.ansArray.length+"<br>"+1040 // "answerLength: " + myApp.val.ansArray[myApp.val.numQues-1].length+"<br>"+1041 // "correctBool: " + myApp.val.correctBool+"<br>"+1042 // "composing: " + myApp.val.composingBool+"<br>"+1043 // "index: " + index+"<br>"+1044 // "cntIndex: " + myApp.val.cntIndex+"<br>"+1045 // "cssRules: " + document.styleSheets.item(0).cssRules.item(0).selectorText;1046}1047//1048//---------------------------------------------------------------------------------------------------------------1049/* set functions executed in each subtitle */1050myApp.val.jumpToAnsBool = true;1051myApp.val.disableSeekbarBool = false;1052myApp.val.hidePlayerBool.phone = true;1053myApp.val.hidePlayerBool.other = false;1054myApp.val.firstQuesStartTime = 16.24;1055myApp.val.srtFuncArray = [1056 function(){1057 myApp.val.viewFuncArray.shift()();1058 myApp.elem.ansBtn.innerHTML = "解çãéä¿¡";1059 /* 第1å */1060 myApp.val.ansIndex = 2;1061 myApp.val.ansIndexStartTime = 26.78;1062 //1063 myApp.val.status = myApp.state.Question;1064 myApp.val.numQues = 1;1065 myApp.val.cntPush = 0;1066 myApp.val.correctBool = false;1067 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1068 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1069 myApp.elem.ansCol.disabled = true;1070 myApp.elem.ansBtn.disabled = true;1071 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1072 },1073 function(){1074 myApp.val.status = myApp.state.Talk;1075 myApp.elem.ansCol.disabled = true;1076 myApp.elem.ansBtn.disabled = true;1077 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1078 },1079 function(){1080 /* 第2å */1081 myApp.val.ansIndex = 4;1082 myApp.val.ansIndexStartTime = 40.56;1083 //1084 myApp.val.status = myApp.state.Question;1085 myApp.val.numQues = 2;1086 myApp.val.cntPush = 0;1087 myApp.val.correctBool = false;1088 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1089 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1090 myApp.elem.ansCol.disabled = true;1091 myApp.elem.ansBtn.disabled = true;1092 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1093 },1094 function(){1095 myApp.val.status = myApp.state.Talk;1096 myApp.elem.ansCol.disabled = true;1097 myApp.elem.ansBtn.disabled = true;1098 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1099 },1100 function(){1101 /* 第3å */1102 myApp.val.ansIndex = 6;1103 myApp.val.ansIndexStartTime = 52.79;1104 //1105 myApp.val.status = myApp.state.Question;1106 myApp.val.numQues = 3;1107 myApp.val.cntPush = 0;1108 myApp.val.correctBool = false;1109 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1110 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1111 myApp.elem.ansCol.disabled = true;1112 myApp.elem.ansBtn.disabled = true;1113 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1114 },1115 function(){1116 myApp.val.status = myApp.state.Talk;1117 myApp.elem.ansCol.disabled = true;1118 myApp.elem.ansBtn.disabled = true;1119 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1120 },1121 function(){1122 /* 第4å */1123 myApp.val.ansIndex = 8;1124 myApp.val.ansIndexStartTime = 67.43;1125 //1126 myApp.val.status = myApp.state.Question;1127 myApp.val.numQues = 4;1128 myApp.val.cntPush = 0;1129 myApp.val.correctBool = false;1130 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1131 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1132 myApp.elem.ansCol.disabled = true;1133 myApp.elem.ansBtn.disabled = true;1134 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1135 },1136 function(){1137 myApp.val.status = myApp.state.Talk;1138 myApp.elem.ansCol.disabled = true;1139 myApp.elem.ansBtn.disabled = true;1140 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1141 },1142 function(){1143 /* 第5å */1144 myApp.val.ansIndex = 10;1145 myApp.val.ansIndexStartTime = 81.34;1146 //1147 myApp.val.status = myApp.state.Question;1148 myApp.val.numQues = 5;1149 myApp.val.cntPush = 0;1150 myApp.val.correctBool = false;1151 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1152 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1153 myApp.elem.ansCol.disabled = true;1154 myApp.elem.ansBtn.disabled = true;1155 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1156 },1157 function(){1158 myApp.val.status = myApp.state.Talk;1159 myApp.elem.ansCol.disabled = true;1160 myApp.elem.ansBtn.disabled = true;1161 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1162 },1163 function(){1164 /* 第6å */1165 myApp.val.ansIndex = 12;1166 myApp.val.ansIndexStartTime = 95.69;1167 //1168 myApp.val.status = myApp.state.Question;1169 myApp.val.numQues = 6;1170 myApp.val.cntPush = 0;1171 myApp.val.correctBool = false;1172 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1173 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1174 myApp.elem.ansCol.disabled = true;1175 myApp.elem.ansBtn.disabled = true;1176 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1177 },1178 function(){1179 myApp.val.status = myApp.state.Talk;1180 myApp.elem.ansCol.disabled = true;1181 myApp.elem.ansBtn.disabled = true;1182 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1183 },1184 function(){1185 /* 第7å */1186 myApp.val.ansIndex = 14;1187 myApp.val.ansIndexStartTime = 109.59;1188 //1189 myApp.val.status = myApp.state.Question;1190 myApp.val.numQues = 7;1191 myApp.val.cntPush = 0;1192 myApp.val.correctBool = false;1193 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1194 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1195 myApp.elem.ansCol.disabled = true;1196 myApp.elem.ansBtn.disabled = true;1197 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1198 },1199 function(){1200 myApp.val.status = myApp.state.Talk;1201 myApp.elem.ansCol.disabled = true;1202 myApp.elem.ansBtn.disabled = true;1203 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1204 },1205 function(){1206 /* 第8å */1207 myApp.val.ansIndex = 16;1208 myApp.val.ansIndexStartTime = 124.87;1209 //1210 myApp.val.status = myApp.state.Question;1211 myApp.val.numQues = 8;1212 myApp.val.cntPush = 0;1213 myApp.val.correctBool = false;1214 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1215 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1216 myApp.elem.ansCol.disabled = true;1217 myApp.elem.ansBtn.disabled = true;1218 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1219 },1220 function(){1221 myApp.val.status = myApp.state.Talk;1222 myApp.elem.ansCol.disabled = true;1223 myApp.elem.ansBtn.disabled = true;1224 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1225 },1226 function(){1227 /* 第9å */1228 myApp.val.ansIndex = 18;1229 myApp.val.ansIndexStartTime = 140.3;1230 //1231 myApp.val.status = myApp.state.Question;1232 myApp.val.numQues = 9;1233 myApp.val.cntPush = 0;1234 myApp.val.correctBool = false;1235 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1236 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1237 myApp.elem.ansCol.disabled = true;1238 myApp.elem.ansBtn.disabled = true;1239 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1240 },1241 function(){1242 myApp.val.status = myApp.state.Talk;1243 myApp.elem.ansCol.disabled = true;1244 myApp.elem.ansBtn.disabled = true;1245 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1246 },1247 function(){1248 /* 第10å */1249 myApp.val.ansIndex = 20;1250 myApp.val.ansIndexStartTime = 154.49;1251 //1252 myApp.val.status = myApp.state.Question;1253 myApp.val.numQues = 10;1254 myApp.val.cntPush = 0;1255 myApp.val.correctBool = false;1256 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1257 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1258 myApp.elem.ansCol.disabled = true;1259 myApp.elem.ansBtn.disabled = true;1260 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1261 },1262 function(){1263 myApp.val.status = myApp.state.Talk;1264 myApp.elem.ansCol.disabled = true;1265 myApp.elem.ansBtn.disabled = true;1266 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1267 },1268 function(){1269 /* 第11å */1270 myApp.val.ansIndex = 22;1271 myApp.val.ansIndexStartTime = 170.45;1272 //1273 myApp.val.status = myApp.state.Question;1274 myApp.val.numQues = 11;1275 myApp.val.cntPush = 0;1276 myApp.val.correctBool = false;1277 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1278 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1279 myApp.elem.ansCol.disabled = true;1280 myApp.elem.ansBtn.disabled = true;1281 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1282 },1283 function(){1284 myApp.val.status = myApp.state.Talk;1285 myApp.elem.ansCol.disabled = true;1286 myApp.elem.ansBtn.disabled = true;1287 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1288 },1289 function(){1290 /* 第12å */1291 myApp.val.ansIndex = 24;1292 myApp.val.ansIndexStartTime = 182.92;1293 //1294 myApp.val.status = myApp.state.Question;1295 myApp.val.numQues = 12;1296 myApp.val.cntPush = 0;1297 myApp.val.correctBool = false;1298 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1299 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1300 myApp.elem.ansCol.disabled = true;1301 myApp.elem.ansBtn.disabled = true;1302 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1303 },1304 function(){1305 myApp.val.status = myApp.state.Talk;1306 myApp.elem.ansCol.disabled = true;1307 myApp.elem.ansBtn.disabled = true;1308 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1309 },1310 function(){1311 /* 第13å */1312 myApp.val.ansIndex = 26;1313 myApp.val.ansIndexStartTime = 196.26;1314 //1315 myApp.val.status = myApp.state.Question;1316 myApp.val.numQues = 13;1317 myApp.val.cntPush = 0;1318 myApp.val.correctBool = false;1319 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1320 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1321 myApp.elem.ansCol.disabled = true;1322 myApp.elem.ansBtn.disabled = true;1323 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1324 },1325 function(){1326 myApp.val.status = myApp.state.Talk;1327 myApp.elem.ansCol.disabled = true;1328 myApp.elem.ansBtn.disabled = true;1329 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1330 },1331 function(){1332 /* 第14å */1333 myApp.val.ansIndex = 28;1334 myApp.val.ansIndexStartTime = 211.85;1335 //1336 myApp.val.status = myApp.state.Question;1337 myApp.val.numQues = 14;1338 myApp.val.cntPush = 0;1339 myApp.val.correctBool = false;1340 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1341 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1342 myApp.elem.ansCol.disabled = true;1343 myApp.elem.ansBtn.disabled = true;1344 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1345 },1346 function(){1347 myApp.val.status = myApp.state.Talk;1348 myApp.elem.ansCol.disabled = true;1349 myApp.elem.ansBtn.disabled = true;1350 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1351 },1352 function(){1353 /* 第15å */1354 myApp.val.ansIndex = 30;1355 myApp.val.ansIndexStartTime = 227.15;1356 //1357 myApp.val.status = myApp.state.Question;1358 myApp.val.numQues = 15;1359 myApp.val.cntPush = 0;1360 myApp.val.correctBool = false;1361 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1362 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1363 myApp.elem.ansCol.disabled = true;1364 myApp.elem.ansBtn.disabled = true;1365 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1366 },1367 function(){1368 myApp.val.status = myApp.state.Talk;1369 myApp.elem.ansCol.disabled = true;1370 myApp.elem.ansBtn.disabled = true;1371 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1372 },1373 function(){1374 /* 第16å */1375 myApp.val.ansIndex = 32;1376 myApp.val.ansIndexStartTime = 241.59;1377 //1378 myApp.val.status = myApp.state.Question;1379 myApp.val.numQues = 16;1380 myApp.val.cntPush = 0;1381 myApp.val.correctBool = false;1382 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1383 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1384 myApp.elem.ansCol.disabled = true;1385 myApp.elem.ansBtn.disabled = true;1386 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1387 },1388 function(){1389 myApp.val.status = myApp.state.Talk;1390 myApp.elem.ansCol.disabled = true;1391 myApp.elem.ansBtn.disabled = true;1392 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1393 },1394 function(){1395 /* 第17å */1396 myApp.val.ansIndex = 34;1397 myApp.val.ansIndexStartTime = 253.65;1398 //1399 myApp.val.status = myApp.state.Question;1400 myApp.val.numQues = 17;1401 myApp.val.cntPush = 0;1402 myApp.val.correctBool = false;1403 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1404 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1405 myApp.elem.ansCol.disabled = true;1406 myApp.elem.ansBtn.disabled = true;1407 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1408 },1409 function(){1410 myApp.val.status = myApp.state.Talk;1411 myApp.elem.ansCol.disabled = true;1412 myApp.elem.ansBtn.disabled = true;1413 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1414 },1415 function(){1416 /* 第18å */1417 myApp.val.ansIndex = 36;1418 myApp.val.ansIndexStartTime = 271.24;1419 //1420 myApp.val.status = myApp.state.Question;1421 myApp.val.numQues = 18;1422 myApp.val.cntPush = 0;1423 myApp.val.correctBool = false;1424 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1425 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1426 myApp.elem.ansCol.disabled = true;1427 myApp.elem.ansBtn.disabled = true;1428 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1429 },1430 function(){1431 myApp.val.status = myApp.state.Talk;1432 myApp.elem.ansCol.disabled = true;1433 myApp.elem.ansBtn.disabled = true;1434 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1435 },1436 function(){1437 /* 第19å */1438 myApp.val.ansIndex = 38;1439 myApp.val.ansIndexStartTime = 287.54;1440 //1441 myApp.val.status = myApp.state.Question;1442 myApp.val.numQues = 19;1443 myApp.val.cntPush = 0;1444 myApp.val.correctBool = false;1445 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1446 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1447 myApp.elem.ansCol.disabled = true;1448 myApp.elem.ansBtn.disabled = true;1449 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1450 },1451 function(){1452 myApp.val.status = myApp.state.Talk;1453 myApp.elem.ansCol.disabled = true;1454 myApp.elem.ansBtn.disabled = true;1455 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1456 },1457 function(){1458 /* 第20å */1459 myApp.val.ansIndex = 40;1460 myApp.val.ansIndexStartTime = 304.24;1461 //1462 myApp.val.status = myApp.state.Question;1463 myApp.val.numQues = 20;1464 myApp.val.cntPush = 0;1465 myApp.val.correctBool = false;1466 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1467 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1468 myApp.elem.ansCol.disabled = true;1469 myApp.elem.ansBtn.disabled = true;1470 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1471 },1472 function(){1473 myApp.val.status = myApp.state.Talk;1474 myApp.elem.ansCol.disabled = true;1475 myApp.elem.ansBtn.disabled = true;1476 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1477 },1478 function(){1479 /* 第21å */1480 myApp.val.ansIndex = 42;1481 myApp.val.ansIndexStartTime = 319.91;1482 //1483 myApp.val.status = myApp.state.Question;1484 myApp.val.numQues = 21;1485 myApp.val.cntPush = 0;1486 myApp.val.correctBool = false;1487 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1488 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1489 myApp.elem.ansCol.disabled = true;1490 myApp.elem.ansBtn.disabled = true;1491 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1492 },1493 function(){1494 myApp.val.status = myApp.state.Talk;1495 myApp.elem.ansCol.disabled = true;1496 myApp.elem.ansBtn.disabled = true;1497 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1498 },1499 function(){1500 /* 第22å */1501 myApp.val.ansIndex = 44;1502 myApp.val.ansIndexStartTime = 332.52;1503 //1504 myApp.val.status = myApp.state.Question;1505 myApp.val.numQues = 22;1506 myApp.val.cntPush = 0;1507 myApp.val.correctBool = false;1508 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1509 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1510 myApp.elem.ansCol.disabled = true;1511 myApp.elem.ansBtn.disabled = true;1512 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1513 },1514 function(){1515 myApp.val.status = myApp.state.Talk;1516 myApp.elem.ansCol.disabled = true;1517 myApp.elem.ansBtn.disabled = true;1518 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1519 },1520 function(){1521 /* 第23å */1522 myApp.val.ansIndex = 46;1523 myApp.val.ansIndexStartTime = 346.66;1524 //1525 myApp.val.status = myApp.state.Question;1526 myApp.val.numQues = 23;1527 myApp.val.cntPush = 0;1528 myApp.val.correctBool = false;1529 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1530 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1531 myApp.elem.ansCol.disabled = true;1532 myApp.elem.ansBtn.disabled = true;1533 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1534 },1535 function(){1536 myApp.val.status = myApp.state.Talk;1537 myApp.elem.ansCol.disabled = true;1538 myApp.elem.ansBtn.disabled = true;1539 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1540 },1541 function(){1542 /* 第24å */1543 myApp.val.ansIndex = 48;1544 myApp.val.ansIndexStartTime = 359.28;1545 //1546 myApp.val.status = myApp.state.Question;1547 myApp.val.numQues = 24;1548 myApp.val.cntPush = 0;1549 myApp.val.correctBool = false;1550 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1551 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1552 myApp.elem.ansCol.disabled = true;1553 myApp.elem.ansBtn.disabled = true;1554 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1555 },1556 function(){1557 myApp.val.status = myApp.state.Talk;1558 myApp.elem.ansCol.disabled = true;1559 myApp.elem.ansBtn.disabled = true;1560 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1561 },1562 function(){1563 /* 第25å */1564 myApp.val.ansIndex = 50;1565 myApp.val.ansIndexStartTime = 374.81;1566 //1567 myApp.val.status = myApp.state.Question;1568 myApp.val.numQues = 25;1569 myApp.val.cntPush = 0;1570 myApp.val.correctBool = false;1571 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1572 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1573 myApp.elem.ansCol.disabled = true;1574 myApp.elem.ansBtn.disabled = true;1575 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1576 },1577 function(){1578 myApp.val.status = myApp.state.Talk;1579 myApp.elem.ansCol.disabled = true;1580 myApp.elem.ansBtn.disabled = true;1581 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1582 },1583 function(){1584 /* 第26å */1585 myApp.val.ansIndex = 52;1586 myApp.val.ansIndexStartTime = 392.68;1587 //1588 myApp.val.status = myApp.state.Question;1589 myApp.val.numQues = 26;1590 myApp.val.cntPush = 0;1591 myApp.val.correctBool = false;1592 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1593 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1594 myApp.elem.ansCol.disabled = true;1595 myApp.elem.ansBtn.disabled = true;1596 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1597 },1598 function(){1599 myApp.val.status = myApp.state.Talk;1600 myApp.elem.ansCol.disabled = true;1601 myApp.elem.ansBtn.disabled = true;1602 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1603 },1604 function(){1605 /* 第27å */1606 myApp.val.ansIndex = 54;1607 myApp.val.ansIndexStartTime = 407.35;1608 //1609 myApp.val.status = myApp.state.Question;1610 myApp.val.numQues = 27;1611 myApp.val.cntPush = 0;1612 myApp.val.correctBool = false;1613 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1614 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1615 myApp.elem.ansCol.disabled = true;1616 myApp.elem.ansBtn.disabled = true;1617 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1618 },1619 function(){1620 myApp.val.status = myApp.state.Talk;1621 myApp.elem.ansCol.disabled = true;1622 myApp.elem.ansBtn.disabled = true;1623 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1624 },1625 function(){1626 /* 第28å */1627 myApp.val.ansIndex = 56;1628 myApp.val.ansIndexStartTime = 420.25;1629 //1630 myApp.val.status = myApp.state.Question;1631 myApp.val.numQues = 28;1632 myApp.val.cntPush = 0;1633 myApp.val.correctBool = false;1634 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1635 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1636 myApp.elem.ansCol.disabled = true;1637 myApp.elem.ansBtn.disabled = true;1638 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1639 },1640 function(){1641 myApp.val.status = myApp.state.Talk;1642 myApp.elem.ansCol.disabled = true;1643 myApp.elem.ansBtn.disabled = true;1644 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1645 },1646 function(){1647 /* 第29å */1648 myApp.val.ansIndex = 58;1649 myApp.val.ansIndexStartTime = 437.49;1650 //1651 myApp.val.status = myApp.state.Question;1652 myApp.val.numQues = 29;1653 myApp.val.cntPush = 0;1654 myApp.val.correctBool = false;1655 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1656 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1657 myApp.elem.ansCol.disabled = true;1658 myApp.elem.ansBtn.disabled = true;1659 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1660 },1661 function(){1662 myApp.val.status = myApp.state.Talk;1663 myApp.elem.ansCol.disabled = true;1664 myApp.elem.ansBtn.disabled = true;1665 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1666 },1667 function(){1668 /* 第30å */1669 myApp.val.ansIndex = 60;1670 myApp.val.ansIndexStartTime = 454.63;1671 //1672 myApp.val.status = myApp.state.Question;1673 myApp.val.numQues = 30;1674 myApp.val.cntPush = 0;1675 myApp.val.correctBool = false;1676 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1677 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1678 myApp.elem.ansCol.disabled = true;1679 myApp.elem.ansBtn.disabled = true;1680 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1681 },1682 function(){1683 myApp.val.status = myApp.state.Talk;1684 myApp.elem.ansCol.disabled = true;1685 myApp.elem.ansBtn.disabled = true;1686 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1687 },1688];16891169000:00:16,240 --> 00:00:26,78016912169200:00:26,780 --> 00:00:30,64016933169400:00:30,640 --> 00:00:40,56016954169600:00:40,560 --> 00:00:43,57016975169800:00:43,570 --> 00:00:52,79016996170000:00:52,790 --> 00:00:55,74017017170200:00:55,740 --> 00:01:07,43017038170400:01:07,430 --> 00:01:11,25017059170600:01:11,250 --> 00:01:21,340170710170800:01:21,340 --> 00:01:24,560170911171000:01:24,560 --> 00:01:35,690171112171200:01:35,690 --> 00:01:39,040171313171400:01:39,040 --> 00:01:49,590171514171600:01:49,590 --> 00:01:52,830171715171800:01:52,830 --> 00:02:04,870171916172000:02:04,870 --> 00:02:07,990172117172200:02:07,990 --> 00:02:20,300172318172400:02:20,300 --> 00:02:23,220172519172600:02:23,220 --> 00:02:34,490172720172800:02:34,490 --> 00:02:37,640172921173000:02:37,640 --> 00:02:50,450173122173200:02:50,450 --> 00:02:54,760173323173400:02:54,760 --> 00:03:02,920173524173600:03:02,920 --> 00:03:06,230173725173800:03:06,230 --> 00:03:16,260173926174000:03:16,260 --> 00:03:20,840174127174200:03:20,840 --> 00:03:31,850174328174400:03:31,850 --> 00:03:36,440174529174600:03:36,440 --> 00:03:47,150174730174800:03:47,150 --> 00:03:50,820174931175000:03:50,820 --> 00:04:01,590175132175200:04:01,590 --> 00:04:05,090175333175400:04:05,090 --> 00:04:13,650175534175600:04:13,650 --> 00:04:16,680175735175800:04:16,680 --> 00:04:31,240175936176000:04:31,240 --> 00:04:35,510176137176200:04:35,510 --> 00:04:47,540176338176400:04:47,540 --> 00:04:51,410176539176600:04:51,410 --> 00:05:04,240176740176800:05:04,240 --> 00:05:07,450176941177000:05:07,450 --> 00:05:19,910177142177200:05:19,910 --> 00:05:23,470177343177400:05:23,470 --> 00:05:32,520177544177600:05:32,520 --> 00:05:35,880177745177800:05:35,880 --> 00:05:46,660177946178000:05:46,660 --> 00:05:49,890178147178200:05:49,890 --> 00:05:59,280178348178400:05:59,280 --> 00:06:02,540178549178600:06:02,540 --> 00:06:14,810178750178800:06:14,810 --> 00:06:19,190178951179000:06:19,190 --> 00:06:32,680179152179200:06:32,680 --> 00:06:36,060179353179400:06:36,060 --> 00:06:47,350179554179600:06:47,350 --> 00:06:50,450179755179800:06:50,450 --> 00:07:00,250179956180000:07:00,250 --> 00:07:03,610180157180200:07:03,610 --> 00:07:17,490180358180400:07:17,490 --> 00:07:22,620180559180600:07:22,620 --> 00:07:34,630180760...
content-1.srt.js
Source:content-1.srt.js
100:00:00,000 --> 00:00:37,3402/* CAUTION : Each sections of subtitle has independent scope. */3/* Ver1.0 */4doOnce[index] = true;5player.pauseVideo();6//7const myApp = {8 path : {9 answer : "https://raw.githubusercontent.com/t-yokota/quizBattle/master/contents/lamy_abc_12th/answer-1.csv",10 sound : "https://raw.githubusercontent.com/t-yokota/quizBattle/master/sounds/sounds_3", //+ext;11 btn1 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_1.png",12 btn2 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_2.png",13 btn3 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_3.png",14 btn4 : "https://github.com/t-yokota/quizBattle/raw/master/images/button_4.png",15 },16 state : {17 ButtonCheck : 0, //ãã¿ã³ãã§ãã¯å¾
æ©18 Question : 1, //åãèªã¿ä¸ï¼æ©æ¼ãå¯è½ï¼19 MyAnswer : 2, //èªåã解ç権ãææï¼è§£çå
¥åã»éä¿¡å¯è½ï¼20 OthAnswer : 3, //ä»è
ã解ç権ãææï¼æ©æ¼ãä¸å¯è½ï¼21 Talk : 4, //ãã®ä»22 },23 videoState : {24 Playing : 1,25 Stopped : 2,26 },27 elem : {28 text : document.createElement("text"),29 subText : document.createElement("text"),30 ansCol : document.createElement("textarea"),31 ansBtn : document.createElement("button"),32 numOX : document.createElement("text"),33 pushBtn : document.createElement("img"),34 imgBtn1 : document.createElement("img"),35 imgBtn2 : document.createElement("img"),36 imgBtn3 : document.createElement("img"),37 imgBtn4 : document.createElement("img"),38 sounds : document.createElement("audio"),39 paramText : document.createElement("text"),40 //41 divUI : document.createElement('div'),42 divElem : document.createElement('div'),43 divBtn : document.createElement('div'),44 },45 val : {46 srtFuncArray : null, //array of functions that are executed in each subtitle47 viewFuncArray : null, //array of functions for setting view elements48 //49 os : null,50 browser : null,51 //52 touchObject : null,53 //54 audioExt : null,55 audioSpriteData : null,56 //57 loadCount : 0,58 initLoadBool : false,59 loadErrorBool : false,60 loadAlertBool : false,61 //62 initOrientation : null,63 orientationAlertBool : false,64 //65 playingCount : 0,66 pageHiddenBool : false,67 processDelayAlertBool : false,68 //69 composingBool : false,70 //71 disableSeekbarBool : false,72 //73 playerWidth : 0,74 playerHeight : 0,75 pushBtnWidth : 0,76 pushBtnHeight : 0,77 //78 prevPlayerWidth : 0,79 prevPlayerHeight : 0,80 prevClientWidth : 0,81 prevClientHeight : 0,82 //83 elemHeight : 0,84 //85 pushBtnArea : {86 left : 0,87 right : 0,88 top : 0,89 bottom : 0,90 },91 //92 divUIHeight : 0,93 divUIWidth : 0,94 divElemWidth : 0,95 divBtnWidth : 0,96 //97 hidePlayerBool : {98 phone : false,99 other : false,100 },101 //102 /* keycode (for keyboard) */103 space : 32, //push buttion104 enter : 13,105 //106 /* button check param */107 btnCheck : {108 sndInterval : 1500, //[ms]109 playInterval : 3000, //[ms]110 },111 //112 /* for question manegament */113 numQues : 1, //åé¡çªå·114 ansArray : [], //æ£çãªã¹ã115 cntO : 0, //æ£çæ°116 cntX : 0, //誤çæ°117 cntPush : 0, //1åãããã®è§£çåæ°118 limPush : 1, //1åãããã®ä¸é解çåæ°119 correctBool : false, //çãåããçµæ(çµæã«å¿ãã¦ç¶æ
é·ç§»)120 ansFile : new XMLHttpRequest(), //æ£çãã¡ã¤ã«.csv121 //122 /* for status management */123 status : null,124 cntIndex : 0, //(index value has current section of subtitle)125 //126 /* for time management */127 ansTime : {128 limit : 20000, //解çå¶éæé[ms]129 elapsed : 0, //解ççµéæé[ms]130 },131 currTime : {132 playing : 0, //be updated during the video is playing133 stopped : 0, //be updated when the video is stopped134 },135 watchedTime : 0, //136 diffTime : 0, //difference between watchedTime and currentTime (for preventing to jump playback position by seekbar)137 //138 ansIndex: 0,139 ansIndexStartTime : 0,140 jumpToAnsBool: false,141 //142 firstQuesStartTime : 0,143 },144};145//146/* get os type */147myApp.val.os = fetchOSType();148myApp.val.browser = fetchBrowserType();149//150/* set id to the elements */151myApp.elem.ansCol.id = 'anscol';152myApp.elem.ansBtn.id = 'ansbtn';153myApp.elem.pushBtn.id = 'pushbtn';154myApp.elem.divUI.id = 'divui';155myApp.elem.divElem.id = 'divelem';156myApp.elem.divBtn.id = 'divbtn';157//158/* set init value to the elements */159myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";160myApp.elem.ansBtn.innerHTML = "ï¼åç®ã¾ã§ç§»å";161myApp.elem.ansCol.disabled = true;162myApp.elem.ansBtn.disabled = true;163myApp.elem.numOX.innerHTML = "âï¸ï¼"+myApp.val.cntO+"ãâï¼"+myApp.val.cntX;164//165if(myApp.val.os != 'other'){166 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";167}else{168 myApp.elem.text.innerHTML = "QuizBattle on YouTube";169 /* set tabindex for adding focus */170 myApp.elem.pushBtn.tabIndex = 0;171}172//173/* set initial state (button check) */174myApp.val.status = myApp.state.ButtonCheck;175//176/* VIEW */177resizePlayer();178//179/* set style sheets */180document.styleSheets.item(0).insertRule('html { touch-action: manipulation; }'); //disable double tap gesture181document.styleSheets.item(0).insertRule('body { text-align: center; margin: auto; background: #EFEFEF; }');182document.styleSheets.item(0).insertRule('.blinkImg { animation: blinkImg 0.7s infinite alternate; }');183document.styleSheets.item(0).insertRule('@keyframes blinkImg{ 0% { opacity: 0.3; } 100% { opacity: 1; }}');184document.styleSheets.item(0).insertRule('.blinkText { animation: blinkText 0.7s infinite alternate; }');185document.styleSheets.item(0).insertRule('@keyframes blinkText{ 0% { opacity: 0; } 100% { opacity: 1; }}');186//187/* set elements */188if(myApp.val.os != 'other'){189 myApp.elem.text.style.fontSize = '42px';190 myApp.elem.text.style.lineHeight = '60px';191 myApp.elem.text.style.fontWeight = 'bold';192 myApp.elem.text.style.display = 'block';193 myApp.elem.text.style.marginTop = '32px';194 myApp.elem.text.style.marginBottom = '32px';195 myApp.elem.text.style.padding = '0px 10px';196 myApp.elem.subText.style.fontSize = '42px';197 myApp.elem.subText.style.lineHeight = '60px';198 myApp.elem.subText.style.display = 'block';199 myApp.elem.ansCol.style.fontSize = '50px';200 myApp.elem.ansCol.style.height = '100px';201 myApp.elem.ansCol.style.textAlign = 'center';202 myApp.elem.ansCol.style.marginBottom = '10px';203 myApp.elem.ansCol.style.marginLeft = 'auto';204 myApp.elem.ansCol.style.marginRight = 'auto';205 myApp.elem.ansCol.style.display = 'block'206 myApp.elem.ansBtn.style.fontSize = '42px';207 myApp.elem.ansBtn.style.width = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*10+'px';208 myApp.elem.ansBtn.style.height = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*2+'px';209 myApp.elem.ansBtn.style.marginBottom = '20px';210 myApp.elem.ansBtn.style.marginLeft = 'auto';211 myApp.elem.ansBtn.style.marginRight = 'auto';212 myApp.elem.ansBtn.style.display = 'block';213 myApp.elem.numOX.style.fontSize = '42px';214 myApp.elem.numOX.style.lineHeight = '80px';215 myApp.elem.numOX.style.fontWeight = 'bold';216 myApp.elem.numOX.style.display = 'block';217 //218 myApp.val.elemHeight = (function(e){219 let res = 0;220 res += parseInt(e.text.style.lineHeight, 10);221 res += parseInt(e.text.style.marginTop, 10);222 res += parseInt(e.text.style.marginBottom, 10);223 res += parseInt(e.ansCol.style.height, 10);224 res += parseInt(e.ansCol.style.marginBottom, 10);225 res += parseInt(e.ansBtn.style.height, 10);226 res += parseInt(e.ansBtn.style.marginBottom, 10);227 res += parseInt(e.numOX.style.lineHeight, 10);228 return res229 })(myApp.elem);230 //231 myApp.val.viewFuncArray = [232 function(){233 document.getElementsByTagName("body")[0].appendChild(myApp.elem.text);234 document.getElementsByTagName("body")[0].appendChild(myApp.elem.ansBtn);235 document.getElementsByTagName("body")[0].appendChild(myApp.elem.pushBtn);236 document.getElementsByTagName("body")[0].appendChild(myApp.elem.numOX);237 document.getElementsByTagName("body")[0].appendChild(myApp.elem.paramText);238 },239 function(){240 myApp.elem.text.style.marginTop = '40px';241 myApp.elem.text.style.marginBottom = '20px';242 myApp.elem.subText.style.marginBottom = '40px';243 myApp.elem.subText.style.padding = '0px 10px';244 document.getElementsByTagName("body")[0].insertBefore(myApp.elem.subText, myApp.elem.text.nextSibling);245 },246 function(){247 myApp.elem.text.style.marginTop = '32px';248 myApp.elem.text.style.marginBottom = '32px';249 myApp.elem.text.parentNode.removeChild(myApp.elem.subText);250 document.getElementsByTagName("body")[0].insertBefore(myApp.elem.ansCol, myApp.elem.text.nextSibling);251 },252 ];253 myApp.val.viewFuncArray.shift()();254}else{255 myApp.val.divUIHeight = myApp.val.playerHeight*0.9;256 myApp.val.divUIWidth = myApp.val.playerWidth;257 myApp.val.divElemWidth = myApp.val.playerWidth*2/3;258 myApp.val.divBtnWidth = myApp.val.playerWidth*1/3;259 document.styleSheets.item(0).insertRule('body { width:'+myApp.val.playerWidth+'px; }');260 document.styleSheets.item(0).insertRule('div#divui { width:'+myApp.val.divUIWidth +'px; height:'+myApp.val.divUIHeight+'px; }');261 document.styleSheets.item(0).insertRule('div#divelem { width:'+myApp.val.divElemWidth+'px; height:'+myApp.val.divUIHeight+'px; float: left; display: flex; align-items: center; justify-content: center; flex-direction: column; }');262 document.styleSheets.item(0).insertRule('div#divbtn { width:'+myApp.val.divBtnWidth +'px; height:'+myApp.val.divUIHeight+'px; float: left; display: flex; align-items: center; justify-content: center; }');263 document.getElementsByTagName("body")[0].appendChild(myApp.elem.divUI);264 myApp.elem.divUI.appendChild(myApp.elem.divElem); //divElem is assigned to ('div')[4]265 myApp.elem.divUI.appendChild(myApp.elem.divBtn); //divBtn is assigned to ('div')[5]266 //267 myApp.elem.text.style.fontSize = '25px';268 myApp.elem.text.style.lineHeight = '45px';269 myApp.elem.text.style.fontWeight = 'bold';270 myApp.elem.text.style.display = 'block';271 myApp.elem.subText.style.fontSize = '20px';272 myApp.elem.subText.style.lineHeight = '30px';273 myApp.elem.subText.style.display = 'block';274 myApp.elem.ansCol.style.fontSize = '23px';275 myApp.elem.ansCol.style.textAlign = 'center';276 myApp.elem.ansCol.style.width = myApp.val.divElemWidth*0.75+'px';277 myApp.elem.ansCol.style.margin = '0px ' +(myApp.val.divElemWidth-parseInt(myApp.elem.ansCol.style.width, 10))/2+'px 15px';278 myApp.elem.ansBtn.style.fontSize = '23px';279 myApp.elem.ansBtn.style.width = parseInt(myApp.elem.ansBtn.style.fontSize, 10)*8+'px';280 myApp.elem.ansBtn.style.margin = '0px '+(myApp.val.divElemWidth-parseInt(myApp.elem.ansBtn.style.width, 10))/2+'px 20px';281 myApp.elem.numOX.style.fontSize = '25px';282 myApp.elem.numOX.style.lineHeight = '45px';283 myApp.elem.numOX.style.fontWeight = 'bold';284 myApp.elem.numOX.style.display = 'block';285 //286 myApp.val.viewFuncArray = [287 function(){288 myApp.elem.text.style.margin = '0px auto';289 myApp.elem.text.style.padding = '0px 40px';290 document.getElementsByTagName("div")[4].appendChild(myApp.elem.text);291 document.getElementsByTagName("div")[4].appendChild(myApp.elem.paramText);292 },293 function(){294 myApp.elem.text.style.margin = '0px auto 30px';295 myApp.elem.subText.style.margin = '0px auto 50px';296 myApp.elem.subText.style.padding = '0px 40px';297 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.subText, myApp.elem.text.nextSibling);298 document.getElementsByTagName("div")[5].appendChild(myApp.elem.pushBtn);299 },300 function(){301 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.ansBtn, myApp.elem.subText.nextSibling);302 },303 function(){304 myApp.elem.text.style.margin = '0px auto 15px';305 myApp.elem.text.parentNode.removeChild(myApp.elem.subText);306 document.getElementsByTagName("div")[4].insertBefore(myApp.elem.ansCol, myApp.elem.text.nextSibling);307 document.getElementsByTagName("div")[4].appendChild(myApp.elem.numOX);308 },309 ];310 myApp.val.viewFuncArray.shift()();311}312//313const num_of_materials = 6;314myApp.elem.sounds.onloadedmetadata = function(){ myApp.val.loadCount += 1; };315myApp.elem.imgBtn1.onload = function(){ myApp.val.loadCount += 1; };316myApp.elem.imgBtn2.onload = function(){ myApp.val.loadCount += 1; };317myApp.elem.imgBtn3.onload = function(){ myApp.val.loadCount += 1; };318myApp.elem.imgBtn4.onload = function(){ myApp.val.loadCount += 1; };319myApp.val.ansFile.onload = function(){ myApp.val.loadCount += 1; myApp.val.ansArray = CSVtoArray(myApp.val.ansFile.responseText); };320//321myApp.elem.sounds.onerror = function(){ myApp.val.loadErrorBool = true; };322myApp.elem.imgBtn1.onerror = function(){ myApp.val.loadErrorBool = true; };323myApp.elem.imgBtn2.onerror = function(){ myApp.val.loadErrorBool = true; };324myApp.elem.imgBtn3.onerror = function(){ myApp.val.loadErrorBool = true; };325myApp.elem.imgBtn4.onerror = function(){ myApp.val.loadErrorBool = true; };326myApp.val.ansFile.onerror = function(){ myApp.val.loadErrorBool = true; };327//328/* load audio data */329if (myApp.elem.sounds.canPlayType('audio/mp3') == 'probably'){ myApp.val.audioExt = '.mp3'; }330else if(myApp.elem.sounds.canPlayType('audio/aac') == 'probably'){ myApp.val.audioExt = '.aac'; }331else if(myApp.elem.sounds.canPlayType('audio/wav') == 'probably'){ myApp.val.audioExt = '.wav'; }332else if(myApp.elem.sounds.canPlayType('audio/mp3') == 'maybe' ){ myApp.val.audioExt = '.mp3'; }333else if(myApp.elem.sounds.canPlayType('audio/aac') == 'maybe' ){ myApp.val.audioExt = '.aac'; }334else if(myApp.elem.sounds.canPlayType('audio/wav') == 'maybe' ){ myApp.val.audioExt = '.wav'; }335myApp.elem.sounds.src = myApp.path.sound+myApp.val.audioExt;336//337/* load push button image */338myApp.elem.imgBtn1.src = myApp.path.btn1;339myApp.elem.imgBtn2.src = myApp.path.btn2;340myApp.elem.imgBtn3.src = myApp.path.btn3;341myApp.elem.imgBtn4.src = myApp.path.btn4;342if(myApp.val.os != 'other'){343 myApp.elem.pushBtn.className = "blinkImg";344}345//346/* load answer file */347myApp.val.ansFile.open("get", myApp.path.answer, true);348myApp.val.ansFile.send(null);349//350/* set audio sprite */351myApp.val.audioSpriteData = {352 pushBtn : { start : 0.0, end : 2.0 }, //[sec]353 sndO : { start : 3.0, end : 5.0 }, 354 sndX : { start : 6.0, end : 8.0 },355};356myApp.elem.sounds.addEventListener('timeupdate', spriteHandler, false);357function spriteHandler(){358 if(Math.abs(myApp.val.audioSpriteData.pushBtn.end - this.currentTime) < 0.25){359 this.pause();360 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;361 }362 if(Math.abs(myApp.val.audioSpriteData.sndO.end - this.currentTime) < 0.25){363 this.pause();364 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;365 }366 if(Math.abs(myApp.val.audioSpriteData.sndX.end - this.currentTime) < 0.25){367 this.pause();368 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;369 }370};371//372/* set function executed after initial loading */373myApp.elem.pushBtn.onerror = function(){374 myApp.val.loadErrorBool = true;375 myApp.val.loadAlertBool = true;376 alert("ç»åã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã" );377};378myApp.elem.pushBtn.onload = function(){379 if(myApp.val.initLoadBool == false){380 /* change player and push button size after loading image */381 resizePlayer();382 resizePushButton();383 myApp.val.initLoadBool = true;384 if(myApp.val.os == 'other'){ myApp.val.viewFuncArray.shift()(); }385 }386};387function materialCheckFunction(){388 if(myApp.val.loadErrorBool == false){389 if(myApp.val.initLoadBool == false && myApp.val.loadCount == num_of_materials){390 myApp.val.loadCount = 0;391 /* assign push button image and main text */392 myApp.elem.pushBtn.width = document.documentElement.clientWidth/5; /* init size before loading */393 if(myApp.val.os != "other"){394 if(Math.abs(window.orientation) != 90){395 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;396 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";397 myApp.val.initOrientation = 'portrait';398 }else{399 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;400 myApp.elem.text.innerHTML = "端æ«ã縦åãã«ãã¦ã¯ã¤ãºãã¯ããã";401 myApp.val.initOrientation = 'landscape';402 alert("ãã®ãµã¤ãã¯ã¹ãã¼ããã©ã³/ã¿ãã¬ããã縦åãã«ãã¦ã楽ãã¿ãã ããã");403 }404 }else{405 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;406 if(detectTouchPanel() == true){407 myApp.elem.subText.innerHTML = "<span class='blinkText'>ã¹ãã¼ã¹ãã¼ãæ¼ãã¦åç»ãéå§ãã</span>";408 }else{409 myApp.elem.subText.innerHTML = "<span class='blinkText'>ã¹ãã¼ã¹ãã¼ãæ¼ãã¦åç»ãéå§ãã</span>";410 }411 }412 }else if(myApp.val.initLoadBool == true && myApp.val.loadAlertBool == false){413 if(myApp.val.os != 'other'){414 if(Math.abs(myApp.elem.numOX.getBoundingClientRect().top - myApp.elem.ansBtn.getBoundingClientRect().bottom) < 50){415 myApp.val.loadErrorBool = true;416 myApp.val.loadAlertBool = true;417 player.pauseVideo();418 alert("ç»åã®è¡¨ç¤ºã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã");419 }420 }421 }422 }else{423 if(myApp.val.loadAlertBool == false){424 myApp.val.loadAlertBool = true;425 alert("ãã¼ã¸ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã");426 }427 }428}429//430/* EVENT */431/* orientation change event function */432window.addEventListener('orientationchange', myOrientationChangeEvent);433function myOrientationChangeEvent(){434 setTimeout(function(){435 resizePlayer();436 resizePushButton();437 if(myApp.val.status == myApp.state.MyAnswer){438 if(myApp.val.hidePlayerBool.phone == true){439 hidePlayer();440 }441 }442 if(Math.abs(window.orientation) != 90){443 if(myApp.val.status == myApp.state.MyAnswer){444 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;445 }else{446 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;447 }448 if(myApp.val.status == myApp.state.ButtonCheck){449 myApp.elem.text.innerHTML = "æ©æ¼ããã¿ã³ãã¿ãããã¦åç»ãéå§ãã";450 }451 }else{452 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;453 if(myApp.val.status == myApp.state.ButtonCheck){454 myApp.elem.text.innerHTML = "端æ«ã縦åãã«ãã¦ã¯ã¤ãºãã¯ããã";455 }456 if(myApp.val.orientationAlertBool == false && myApp.val.initOrientation == 'portrait'){457 myApp.val.playingCount = -10;458 myApp.val.orientationAlertBool = true;459 alert("ãã®ãµã¤ãã¯ã¹ãã¼ããã©ã³/ã¿ãã¬ããã縦åãã«ãã¦ã楽ãã¿ãã ããã");460 }461 }462 }, 800);463}464//465/* page hidden check event function */466document.addEventListener('webkitvisibilitychange', myPageHiddenCheckEvent, false);467function myPageHiddenCheckEvent(){468 if(document.webkitHidden){469 myApp.val.pageHiddenBool = true;470 // console.log('Hidden.');471 }else{472 myApp.val.pageHiddenBool = false;473 myApp.val.currTime.playing = player.getCurrentTime();474 myApp.val.watchedTime = myApp.val.currTime.playing;475 myApp.val.playingCount = 0;476 // console.log('Opened.');477 }478}479//480/* keydown event function */481document.onkeydown = myKeyDownEvent;482//483document.addEventListener("compositionstart", function(){ myApp.val.composingBool = true; });484document.addEventListener('compositionend', function(){ myApp.val.composingBool = false; });485function myKeyDownEvent(){486 if(myApp.val.loadErrorBool == false && myApp.val.initLoadBool == true && Math.abs(window.orientation) != 90){487 if(event.keyCode == myApp.val.space){488 myButtonAction();489 }490 /* prevent to start new line in text area */491 if(event.keyCode == myApp.val.enter){492 if(myApp.val.composingBool == false){493 return false;494 }495 }496 }497}498//499/* touchstart event function (for smartphonea and tablet) */500document.addEventListener("touchstart", myTouchEvent);501function myTouchEvent(event){502 if(myApp.val.loadErrorBool == false && myApp.val.initLoadBool == true && Math.abs(window.orientation) != 90){503 myApp.val.touchObject = event.changedTouches[0];504 if(myApp.val.pushBtnArea.left < myApp.val.touchObject.pageX && myApp.val.touchObject.pageX < myApp.val.pushBtnArea.right){505 if(myApp.val.pushBtnArea.top < myApp.val.touchObject.pageY && myApp.val.touchObject.pageY < myApp.val.pushBtnArea.bottom){506 myButtonAction();507 }508 }509 }510}511//512/* common button action */513function myButtonAction(){514 if(myApp.val.status == myApp.state.ButtonCheck){515 myApp.val.status = myApp.state.Talk;516 myApp.elem.pushBtn.className = "";517 buttonCheck(myApp.val.btnCheck.sndInterval);518 setTimeout(function(){519 player.playVideo();520 myApp.elem.ansBtn.disabled = false;521 if(myApp.val.os != 'other'){522 myApp.val.viewFuncArray.shift()();523 myApp.elem.text.innerHTML = "ï¼ éã³æ¹ ï¼";524 myApp.elem.subText.innerHTML = "ç»é¢ä¸ã®æ©æ¼ããã¿ã³ã§<br>åç»å
ã®ã¯ã¤ãºã«åå ãããã¨ãã§ãã¾ã";525 }else{526 myApp.val.viewFuncArray.shift()();527 myApp.elem.text.innerHTML = "ï¼ éã³æ¹ ï¼"528 myApp.elem.subText.innerHTML = "ã¹ãã¼ã¹ãã¼ãæ©æ¼ããã¿ã³ã«ãã¦<br>åç»å
ã®ã¯ã¤ãºã«åå ãããã¨ãã§ãã¾ã";529 }530 }, myApp.val.btnCheck.playInterval);531 }532 if(myApp.val.status == myApp.state.Question){533 myApp.val.status = myApp.state.MyAnswer;534 player.pauseVideo();535 pushButton();536 }537}538//539/* player's state change event function */540player.addEventListener('onStateChange', myPlayerStateChangeEvent);541function myPlayerStateChangeEvent(){542 if(player.getPlayerState() == myApp.videoState.Playing){543 myApp.val.currTime.playing = player.getCurrentTime();544 myApp.val.watchedTime = updateWatchedTime(myApp.val.currTime.playing, myApp.val.watchedTime);545 /* check answer if the video is restarted manually without sending answer */546 if(myApp.val.status == myApp.state.MyAnswer){547 player.pauseVideo();548 checkAnswer();549 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){550 myApp.val.status = myApp.state.Talk;551 }else{552 myApp.val.status = myApp.state.Question;553 }554 player.playVideo();555 }556 if(myApp.val.disableSeekbarBool == true){557 /* prevent to jump playback position by seekbar */558 if(myApp.val.status == myApp.state.Question){559 myApp.val.diffTime = Math.abs(myApp.val.currTime.playing - myApp.val.watchedTime);560 if(myApp.val.diffTime > 1.0){561 player.seekTo(myApp.val.watchedTime);562 }563 }else{564 myApp.val.diffTime = Math.abs(myApp.val.currTime.playing - myApp.val.watchedTime);565 // myApp.val.diffTime = myApp.val.currTime.playing - myApp.val.watchedTime; /* allow to jump to previous positon on timeline */566 if(myApp.val.diffTime > 1.0){567 player.seekTo(myApp.val.watchedTime);568 }569 }570 }571 }572 if(player.getPlayerState() == myApp.videoState.Stopped){573 myApp.val.currTime.stopped = player.getCurrentTime();574 if(myApp.val.disableSeekbarBool == true){575 /* prevent to jump video playback position by seekbar */576 /* and prevent to pause video during each question */577 if(myApp.val.status == myApp.state.Question || myApp.val.status == myApp.state.OthAnswer){578 myApp.val.diffTime = Math.abs(myApp.val.currTime.stopped - myApp.val.watchedTime);579 if(myApp.val.diffTime > 1.0){580 player.seekTo(myApp.val.watchedTime);581 }582 player.playVideo();583 }else{584 myApp.val.diffTime = Math.abs(myApp.val.currTime.stopped - myApp.val.watchedTime);585 // myApp.val.diffTime = myApp.val.currTime.stopped - myApp.val.watchedTime; /* allow to jump to previous position on timeline */586 if(myApp.val.diffTime > 1.0){587 player.seekTo(myApp.val.watchedTime);588 player.playVideo(); /* allow to pause video except during the question status */589 }590 // player.playVideo();591 }592 }593 }594}595//596/* interval event function that are executed at a certain interval */597setInterval(myIntervalEvent, interval = 10);598function myIntervalEvent(){599 if(myApp.val.pageHiddenBool == false){600 if(player.getPlayerState() == myApp.videoState.Playing){601 myApp.val.currTime.playing = player.getCurrentTime();602 myApp.val.watchedTime = updateWatchedTime(myApp.val.currTime.playing, myApp.val.watchedTime);603 if(myApp.val.disableSeekbarBool == true){604 /* check delay of processing */605 if(myApp.val.playingCount < 0 ){ myApp.val.watchedTime = myApp.val.currTime.playing; } // fix delay of watchedTime caused by showing orientation alert.606 if(myApp.val.playingCount < 10){ myApp.val.playingCount += 1; }ã// allow initial delay of watchedTime just after playing video.607 if(myApp.val.currTime.playing - myApp.val.watchedTime > 1.0 && myApp.val.playingCount >= 10){608 if(myApp.val.processDelayAlertBool == false){609 myApp.val.processDelayAlertBool = true;610 alert('ãã¼ã¸å
ã®å¦çãé
ããªã£ã¦ãã¾ããæ©æ¼ãã®å¤å®ã«æ¯éãåºãå¯è½æ§ããããããä»ã®ããã»ã¹ãçµäºãã¦ããæ¹ãã¦ã¯ã¤ãºãã楽ãã¿ãã ããããã®ãããã¢ããã¯ä¸åº¦ã®ã¿è¡¨ç¤ºããã¾ãã');611 }612 myApp.val.watchedTime = myApp.val.currTime.playing;613 }614 }615 /* prevent to play video before button check */616 if(myApp.val.status == myApp.state.ButtonCheck){617 player.pauseVideo();618 }619 /* execute srt function in each sections of subtitle */620 if(myApp.val.status != myApp.state.MyAnswer){621 if(myApp.val.disableSeekbarBool == true){622 if(index - myApp.val.cntIndex == 1){623 myApp.val.srtFuncArray.shift()();624 myApp.val.cntIndex += 1;625 }626 }else{627 if(index - myApp.val.cntIndex >= 1){628 for(let i = 0; i < index-myApp.val.cntIndex; i++){629 myApp.val.srtFuncArray.shift()();630 }631 myApp.val.cntIndex = index;632 // console.log(myApp.val.cntIndex);633 }634 }635 }636 }else if(player.getPlayerState() == myApp.videoState.Stopped){637 myApp.val.playingCount = 0;638 }639 if(myApp.val.status == myApp.state.ButtonCheck){640 if(myApp.val.cntIndex > 0 && myApp.val.loadAlertBool == false){641 myApp.val.loadErrorBool = true;642 myApp.val.loadAlertBool = true;643 player.pauseVideo();644 alert('ãã¼ã¸ã®èªã¿è¾¼ã¿ã«å¤±æãã¾ããããã¼ã¸ãåèªã¿è¾¼ã¿ãã¦ãã ããã');645 }646 }647 if(myApp.val.status == myApp.state.MyAnswer){648 /* reforcus when anscol is blank */649 // if(document.activeElement.id != "anscol" && myApp.elem.ansCol.value.valueOf() === ""){650 // myApp.elem.ansCol.focus();651 // }652 /* answer time managemant */653 if(document.activeElement.id == "anscol" || myApp.val.ansTime.elapsed != 0){654 myApp.val.ansTime.elapsed += interval;655 myApp.elem.text.innerHTML = "ã®ãã"+Math.floor((myApp.val.ansTime.limit-myApp.val.ansTime.elapsed)/1000+1)+"ç§";656 if(myApp.val.ansTime.elapsed >= myApp.val.ansTime.limit){657 checkAnswer();658 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){659 myApp.val.status = myApp.state.Talk;660 }else{661 myApp.val.status = myApp.state.Question;662 }663 player.playVideo();664 }665 }666 }else{667 if(myApp.val.os == 'other' && document.activeElement.id == "player"){668 /* preparation of js keydown event */669 instantFocusToElement(myApp.elem.pushBtn);670 }671 myApp.val.ansTime.elapsed = 0;672 }673 /* check results of importing material */674 materialCheckFunction();675 /* update push button area (mainly for when the window is zoomed in iOS)*/676 updatePushButtonArea();677 /* print parameters for debug */678 printParams();679 }680}681//682/* onclick event function of send answer button */683myApp.elem.ansBtn.onclick = myOnClickEvent;684function myOnClickEvent(){685 /* jump to init question */686 if(index == 0){687 let tmpTime = myApp.val.firstQuesStartTime-0.1;688 if(myApp.val.currTime.playing < tmpTime){689 myApp.elem.ansBtn.disabled = true;690 myApp.val.watchedTime = tmpTime;691 player.seekTo(tmpTime);692 }693 }694 /* send answer */695 if(myApp.val.status == myApp.state.MyAnswer){696 checkAnswer();697 if(myApp.val.correctBool == true || myApp.val.limPush - myApp.val.cntPush == 0){698 myApp.val.status = myApp.state.Talk;699 }else{700 myApp.val.status = myApp.state.Question;701 }702 player.playVideo();703 }704}705//706/* onfocus event function of answer column */707myApp.elem.ansCol.onfocus = function(){ myApp.elem.ansCol.val = ""; }708//709/* FUNCTION */710function detectTouchPanel(){711 return window.ontouchstart === null;712}713//714function fetchOSType(){715 let osType = null;716 const ua = navigator.userAgent;717 if(ua.match(/Android/)){718 osType = "Android";719 return osType;720 }else if(ua.match(/iPhone/)) {721 osType = "iOS"; // iPhone OS722 return osType;723 }else if(ua.match(/iPad/)) {724 osType = "iOS"; // iPad OS725 return osType;726 }else if(ua.match(/Macintosh/) && detectTouchPanel() == true){727 osType = 'iOS'; // iPad OS with Safari728 return osType;729 }else{730 osType = "other";731 return osType;732 }733}734//735function fetchBrowserType(){736 let bwType = null;737 const ua = navigator.userAgent;738 if(ua.match(/Firefox/)){739 bwType = "Firefox";740 return bwType;741 }else if(ua.match(/EdgiOS/) || ua.match(/EdgA/)){742 bwType = "Edge";743 return bwType;744 }else if(ua.match(/OPR/)){745 bwType = "Opera";746 return bwType;747 }else if(ua.match(/OPT/)){748 bwType = "OperaTouch";749 return bwType;750 }else if(ua.match(/YJApp/)){751 bwType = "Yahoo";752 return bwType;753 }else if(ua.match(/Smooz/)){754 bwType = "Smooz";755 return bwType;756 }else if(ua.match(/CriOS/) || ua.match(/Chrome/)){757 //Chrome or Others ...758 bwType = "Chrome";759 return bwType;760 }else{761 //Safari, Firefox(iOS), Brave or Others ...762 bwType = "Other";763 return bwType;764 }765}766/**767 * @param {string} str768 * @returns {array} (rows: num of question, columns: num of patterns of answerï¼769 */770function CSVtoArray(str){771 const array = new Array();772 const tmp = str.split("\r\n");773 for(let i = 0; i < tmp.length; i++){774 array[i] = tmp[i].split(",");775 }776 return array;777}778//779function resizePlayer(){780 if(myApp.val.os != 'other'){781 if(Math.abs(window.orientation) != 90){782 // myApp.val.playerWidth = document.documentElement.clientWidth;783 if(myApp.val.os == 'Android'){ myApp.val.playerWidth = window.innerWidth; } // In Android, clientWidth doesn't include scrollbar.784 if(myApp.val.os == 'iOS'){ myApp.val.playerWidth = document.documentElement.clientWidth; } // In iOS, innerWidth isn't static (it changes with device orientation).785 myApp.val.playerHeight = myApp.val.playerWidth/16*9;786 }else{787 myApp.val.playerWidth = document.documentElement.clientWidth*2/3;788 myApp.val.playerHeight = myApp.val.playerWidth/16*9;789 }790 /* set special width of anscol to prevent the window is zoomed when the focus moveds to anscol */791 if(myApp.val.os == 'Android' && myApp.val.browser == "Firefox"){792 myApp.elem.ansCol.style.width = myApp.val.playerWidth*0.98+'px';793 }else{794 myApp.elem.ansCol.style.width = myApp.val.playerWidth*0.9+'px';795 }796 }else{797 const tmpPlayerHeight = document.documentElement.clientHeight/2;798 const tmpPlayerWidth = tmpPlayerHeight/9*16;799 if(tmpPlayerWidth < document.documentElement.clientWidth){800 myApp.val.playerHeight = tmpPlayerHeight;801 myApp.val.playerWidth = tmpPlayerWidth;802 }else{803 myApp.val.playerWidth = document.documentElement.clientWidth;804 myApp.val.playerHeight = myApp.val.playerWidth/16*9;805 }806 }807 if(myApp.val.initLoadBool == false || myApp.val.prevPlayerWidth != myApp.val.playerWidth){808 player.setSize(myApp.val.playerWidth, myApp.val.playerHeight);809 //810 myApp.val.prevPlayerWidth = myApp.val.playerWidth;811 myApp.val.prevPlayerHeight = myApp.val.playerHeight;812 }813}814//815function resizePushButton(){816 if(myApp.val.os != "other"){817 if(Math.abs(window.orientation) != 90){818 const tmpImgHeight = document.documentElement.clientHeight-myApp.val.playerHeight-myApp.val.elemHeight-20;819 const tmpImgWidth = myApp.elem.pushBtn.naturalWidth*tmpImgHeight/myApp.elem.pushBtn.naturalHeight;820 if(tmpImgWidth < document.documentElement.clientWidth){821 if(tmpImgHeight <= myApp.val.playerHeight){822 myApp.val.pushBtnWidth = tmpImgWidth;823 myApp.val.pushBtnHeight = tmpImgHeight;824 }else{825 myApp.val.pushBtnWidth = myApp.elem.pushBtn.naturalWidth*myApp.val.playerHeight*1.25/myApp.elem.pushBtn.naturalHeight;826 myApp.val.pushBtnHeight = myApp.val.playerHeight*1.25;827 }828 }else{829 myApp.val.pushBtnWidth = document.documentElement.clientWidth/5;830 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;831 }832 }else{833 myApp.val.pushBtnWidth = document.documentElement.clientWidth/5;834 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;835 }836 myApp.elem.pushBtn.style.margin = 'auto '+(document.documentElement.clientWidth-myApp.val.pushBtnWidth)/2+'px';837 }else{838 myApp.val.pushBtnWidth = myApp.val.divBtnWidth;839 myApp.val.pushBtnHeight = myApp.elem.pushBtn.naturalHeight*myApp.val.pushBtnWidth/myApp.elem.pushBtn.naturalWidth;840 } 841 if(myApp.val.initLoadBool == false || myApp.val.prevClientHeight != document.documentElement.clientHeight){842 myApp.elem.pushBtn.width = myApp.val.pushBtnWidth;843 myApp.elem.pushBtn.height = myApp.val.pushBtnHeight;844 updatePushButtonArea();845 //846 myApp.val.prevClientWidth = document.documentElement.clientWidth;847 myApp.val.prevClientHeight = document.documentElement.clientHeight;848 }849}850//851function updatePushButtonArea(){852 myApp.val.pushBtnArea.left = myApp.elem.pushBtn.getBoundingClientRect().left;853 myApp.val.pushBtnArea.right = myApp.elem.pushBtn.getBoundingClientRect().right;854 myApp.val.pushBtnArea.top = myApp.elem.pushBtn.getBoundingClientRect().top;855 myApp.val.pushBtnArea.bottom = myApp.elem.pushBtn.getBoundingClientRect().bottom;856 //857 /* In iOS, value of getBoundingClientRect is changed when the window is zoomed */858 if(myApp.val.os == 'iOS'){859 myApp.val.pushBtnArea.left += window.pageXOffset;860 myApp.val.pushBtnArea.right += window.pageXOffset;861 myApp.val.pushBtnArea.top += window.pageYOffset;862 myApp.val.pushBtnArea.bottom += window.pageYOffset;863 }864}865//866function instantFocusToElement(focusUsableElement){867 /* keydown event is ready during the focus is in a js element */868 focusUsableElement.disabled = false;869 focusUsableElement.focus();870 focusUsableElement.blur();871 focusUsableElement.disabled = true;872}873//874function updateWatchedTime(currentPlayingTime, watchedTime){875 if(0.0 < currentPlayingTime - watchedTime && currentPlayingTime - watchedTime < 1.0){876 watchedTime = currentPlayingTime;877 }878 return watchedTime;879}880//881function playSndPushBtn(){882 if(myApp.elem.sounds.currentTime != myApp.val.audioSpriteData.pushBtn.start){883 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.pushBtn.start;884 }885 myApp.elem.sounds.play();886}887//888function playSndO(){889 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.sndO.start;890 myApp.elem.sounds.play();891}892//893function playSndX(){894 myApp.elem.sounds.currentTime = myApp.val.audioSpriteData.sndX.start;895 myApp.elem.sounds.play();896}897//898function hidePlayer(){899 player.setSize(myApp.val.playerWidth, 0);900}901//902function opposePlayer(){903 player.setSize(myApp.val.playerWidth, myApp.val.playerHeight);904}905//906function buttonCheck(responseInterval){907 playSndPushBtn();908 if(myApp.val.os == 'iOS'){909 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;910 }else{911 myApp.elem.pushBtn.src = myApp.elem.imgBtn2.src;912 setTimeout(function(){ myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src; }, 100);913 }914 setTimeout(function(){915 playSndO();916 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;917 }, responseInterval);918}919//920function pushButton(){921 // hide player during answer.922 if(myApp.val.os != 'other'){923 if(myApp.val.hidePlayerBool.phone == true){924 hidePlayer();925 }926 }else{927 if(myApp.val.hidePlayerBool.other == true){928 hidePlayer();929 }930 }931 playSndPushBtn();932 if(myApp.val.os == 'iOS'){933 myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src;934 if(myApp.val.browser == 'Chrome' || myApp.val.browser == 'Edge' || myApp.val.browser == 'Smooz'){935 setTimeout(function(){ focusToAnsCol(); }, 500); // In above browsers, focus() doesn't work by the script below.936 }else{937 focusToAnsCol(); // In iOS, focus() doesn't work properly in setTimeout (keyboard doesn't appear).938 }939 }else{940 myApp.elem.pushBtn.src = myApp.elem.imgBtn2.src;941 setTimeout(function(){ myApp.elem.pushBtn.src = myApp.elem.imgBtn3.src; }, 100); 942 setTimeout(function(){ focusToAnsCol(); }, 500);943 }944 myApp.val.cntPush = myApp.val.cntPush+1;945}946//947function focusToAnsCol(){948 myApp.elem.ansBtn.disabled = false;949 myApp.elem.ansCol.disabled = false;950 myApp.elem.ansCol.value = "";951 myApp.elem.ansCol.focus();952}953//954function checkAnswer(){955 myApp.val.correctBool = false;956 myApp.elem.ansCol.blur();957 myApp.elem.ansCol.disabled = true;958 myApp.elem.ansBtn.disabled = true;959 const answer = myApp.elem.ansCol.value;960 const length = myApp.val.ansArray[myApp.val.numQues-1].length;961 for(let i = 0; i < length; i++){962 if(answer.valueOf() === myApp.val.ansArray[myApp.val.numQues-1][i].valueOf()){963 myApp.val.correctBool = true;964 }965 }966 if(myApp.val.correctBool == true){967 playSndO();968 myApp.val.cntO += 1;969 myApp.elem.text.innerHTML = "æ£è§£ï¼";970 if(myApp.val.jumpToAnsBool){ jumpToAnswerIndex(myApp.val.ansIndex, myApp.val.ansIndexStartTime); }971 }else{972 playSndX();973 myApp.val.cntX += 1;974 myApp.elem.text.innerHTML = "ä¸æ£è§£ï¼"; //ãã¨"+(myApp.val.limPush-myApp.val.cntPush)+"å解çã§ãã¾ãã";975 if(myApp.val.jumpToAnsBool){ jumpToAnswerIndex(myApp.val.ansIndex, myApp.val.ansIndexStartTime); }976 }977 myApp.elem.numOX.innerHTML = "âï¸ï¼"+myApp.val.cntO+"ãâï¼"+myApp.val.cntX;978 if(window.orientation != 90){979 if(myApp.val.correctBool == false && myApp.val.limPush - myApp.val.cntPush == 0){980 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;981 }else{982 myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src;983 }984 }else{985 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;986 }987 // oppose player after answer.988 if(myApp.val.os != 'other'){989 if(myApp.val.hidePlayerBool.phone == true){990 opposePlayer();991 }992 }else{993 if(myApp.val.hidePlayerBool.other == true){994 opposePlayer();995 }996 }997}998//999function jumpToAnswerIndex(index, time){1000 myApp.val.cntIndex = index-1;1001 myApp.val.watchedTime = time-0.1;1002 player.seekTo(time-0.1);1003}1004//1005function printParams(){1006 // myApp.elem.paramText.innerHTML = "timePlay: " + myApp.val.currTime.playing.toFixed(3)+"<br>"+1007 // "timeStop: " +myApp.val.currTime.stopped.toFixed(3)+"<br>"+1008 // "WatchedTime: " + myApp.val.watchedTime.toFixed(3)+"<br>"+1009 // "diffTime: " + myApp.val.diffTime.toFixed(3);1010 // myApp.elem.paramText.innerHTML = myApp.val.browser;1011 // myApp.elem.paramText.innerHTML = myApp.val.os + ', ' + navigator.userAgent;1012 // myApp.elem.paramText.innerHTML = document.styleSheets.item(0).cssRules;1013 // myApp.elem.subText.innerHTML = "sounds.currentTime: " + Math.abs(Math.floor(myApp.elem.sounds.currentTime*1000)/1000);1014 // myApp.elem.subText.innerHTML = Math.floor(myApp.val.touchObject.pageX) +', '+ Math.floor(myApp.val.touchObject.pageY) +' '+1015 // '[' + Math.floor(myApp.val.pushBtnArea.left) +', '+ Math.floor(myApp.val.pushBtnArea.right) +'] '+1016 // '[' + Math.floor(myApp.val.pushBtnArea.top) +', '+ Math.floor(myApp.val.pushBtnArea.bottom)+'] '+1017 // '| '+ window.pageXOffset +', '+ window.pageYOffset;1018 // myApp.elem.subText.innerHTML = myApp.elem.numOX.getBoundingClientRect().top - myApp.elem.ansBtn.getBoundingClientRect().bottom;1019 // myApp.elem.subText.innerHTML = 'loadErrorBool: ' + myApp.val.loadErrorBool + ', initLoadBool: ' + myApp.val.initLoadBool + ', loadCount: ' + myApp.val.loadCount;1020 // myApp.elem.subText.innerHTML = 'playerWidth: ' + myApp.val.playerWidth + ', innerWidth: ' + window.innerWidth;1021 // myApp.elem.paramText.innerHTML = "<br>"+ 1022 // "device: " + myApp.val.os+"<br>"+1023 // "browser: " + myApp.val.browser+"<br>"+1024 // "activeElem: " + document.activeElement.id+"<br>"+ 1025 // "status: " + myApp.val.status+"<br>"+1026 // "timePlay: " + myApp.val.currTime.playing.toFixed(3)+"<br>"+1027 // "timeStop: " + myApp.val.currTime.stopped.toFixed(3)+"<br>"+1028 // "WatchedTime: " + myApp.val.watchedTime.toFixed(3)+"<br>"+1029 // "diffTime: " + myApp.val.diffTime.toFixed(3)+"<br>"+1030 // "limPush: " + myApp.val.limPush+"<br>"+ 1031 // "cntPush: " + myApp.val.cntPush+"<br>"+1032 // "remainingAnsTime: " + Math.floor((myApp.val.ansTime.limit-myApp.val.ansTime.elapsed)/1000)+"<br>"+1033 // "answer: " + myApp.val.ansArray[myApp.val.numQues-1][0].valueOf()+", "+1034 // myApp.val.ansArray[myApp.val.numQues-1][1].valueOf()+", "+1035 // myApp.val.ansArray[myApp.val.numQues-1][2].valueOf()+", "+1036 // myApp.val.ansArray[myApp.val.numQues-1][3].valueOf()+", "+1037 // myApp.val.ansArray[myApp.val.numQues-1][4].valueOf()+", "+1038 // myApp.val.ansArray[myApp.val.numQues-1][5].valueOf()+"<br>"+1039 // "numAnswer: " + myApp.val.ansArray.length+"<br>"+1040 // "answerLength: " + myApp.val.ansArray[myApp.val.numQues-1].length+"<br>"+1041 // "correctBool: " + myApp.val.correctBool+"<br>"+1042 // "composing: " + myApp.val.composingBool+"<br>"+1043 // "index: " + index+"<br>"+1044 // "cntIndex: " + myApp.val.cntIndex+"<br>"+1045 // "cssRules: " + document.styleSheets.item(0).cssRules.item(0).selectorText;1046}1047//1048//---------------------------------------------------------------------------------------------------------------1049/* set functions executed in each subtitle */1050myApp.val.jumpToAnsBool = true;1051myApp.val.disableSeekbarBool = false;1052myApp.val.hidePlayerBool.phone = true;1053myApp.val.hidePlayerBool.other = false;1054myApp.val.firstQuesStartTime = 36;1055myApp.val.srtFuncArray = [1056 function(){1057 myApp.val.viewFuncArray.shift()();1058 myApp.elem.ansBtn.innerHTML = "解çãéä¿¡";1059 /* 第1å */1060 myApp.val.ansIndex = 2;1061 myApp.val.ansIndexStartTime = 47.86;1062 //1063 myApp.val.status = myApp.state.Question;1064 myApp.val.numQues = 1;1065 myApp.val.cntPush = 0;1066 myApp.val.correctBool = false;1067 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1068 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1069 myApp.elem.ansCol.disabled = true;1070 myApp.elem.ansBtn.disabled = true;1071 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1072 },1073 function(){1074 myApp.val.status = myApp.state.Talk;1075 myApp.elem.ansCol.disabled = true;1076 myApp.elem.ansBtn.disabled = true;1077 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1078 },1079 function(){1080 /* 第2å */1081 myApp.val.ansIndex = 4;1082 myApp.val.ansIndexStartTime = 59.07;1083 //1084 myApp.val.status = myApp.state.Question;1085 myApp.val.numQues = 2;1086 myApp.val.cntPush = 0;1087 myApp.val.correctBool = false;1088 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1089 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1090 myApp.elem.ansCol.disabled = true;1091 myApp.elem.ansBtn.disabled = true;1092 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1093 },1094 function(){1095 myApp.val.status = myApp.state.Talk;1096 myApp.elem.ansCol.disabled = true;1097 myApp.elem.ansBtn.disabled = true;1098 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1099 },1100 function(){1101 /* 第3å */1102 myApp.val.ansIndex = 6;1103 myApp.val.ansIndexStartTime = 71.78;1104 //1105 myApp.val.status = myApp.state.Question;1106 myApp.val.numQues = 3;1107 myApp.val.cntPush = 0;1108 myApp.val.correctBool = false;1109 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1110 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1111 myApp.elem.ansCol.disabled = true;1112 myApp.elem.ansBtn.disabled = true;1113 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1114 },1115 function(){1116 myApp.val.status = myApp.state.Talk;1117 myApp.elem.ansCol.disabled = true;1118 myApp.elem.ansBtn.disabled = true;1119 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1120 },1121 function(){1122 /* 第4å */1123 myApp.val.ansIndex = 8;1124 myApp.val.ansIndexStartTime = 89.22;1125 //1126 myApp.val.status = myApp.state.Question;1127 myApp.val.numQues = 4;1128 myApp.val.cntPush = 0;1129 myApp.val.correctBool = false;1130 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1131 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1132 myApp.elem.ansCol.disabled = true;1133 myApp.elem.ansBtn.disabled = true;1134 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1135 },1136 function(){1137 myApp.val.status = myApp.state.Talk;1138 myApp.elem.ansCol.disabled = true;1139 myApp.elem.ansBtn.disabled = true;1140 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1141 },1142 function(){1143 /* 第5å */1144 myApp.val.ansIndex = 10;1145 myApp.val.ansIndexStartTime = 106.27;1146 //1147 myApp.val.status = myApp.state.Question;1148 myApp.val.numQues = 5;1149 myApp.val.cntPush = 0;1150 myApp.val.correctBool = false;1151 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1152 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1153 myApp.elem.ansCol.disabled = true;1154 myApp.elem.ansBtn.disabled = true;1155 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1156 },1157 function(){1158 myApp.val.status = myApp.state.Talk;1159 myApp.elem.ansCol.disabled = true;1160 myApp.elem.ansBtn.disabled = true;1161 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1162 },1163 function(){1164 /* 第6å */1165 myApp.val.ansIndex = 12;1166 myApp.val.ansIndexStartTime = 119.96;1167 //1168 myApp.val.status = myApp.state.Question;1169 myApp.val.numQues = 6;1170 myApp.val.cntPush = 0;1171 myApp.val.correctBool = false;1172 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1173 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1174 myApp.elem.ansCol.disabled = true;1175 myApp.elem.ansBtn.disabled = true;1176 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1177 },1178 function(){1179 myApp.val.status = myApp.state.Talk;1180 myApp.elem.ansCol.disabled = true;1181 myApp.elem.ansBtn.disabled = true;1182 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1183 },1184 function(){1185 /* 第7å */1186 myApp.val.ansIndex = 14;1187 myApp.val.ansIndexStartTime = 136.63;1188 //1189 myApp.val.status = myApp.state.Question;1190 myApp.val.numQues = 7;1191 myApp.val.cntPush = 0;1192 myApp.val.correctBool = false;1193 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1194 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1195 myApp.elem.ansCol.disabled = true;1196 myApp.elem.ansBtn.disabled = true;1197 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1198 },1199 function(){1200 myApp.val.status = myApp.state.Talk;1201 myApp.elem.ansCol.disabled = true;1202 myApp.elem.ansBtn.disabled = true;1203 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1204 },1205 function(){1206 /* 第8å */1207 myApp.val.ansIndex = 16;1208 myApp.val.ansIndexStartTime = 148.56;1209 //1210 myApp.val.status = myApp.state.Question;1211 myApp.val.numQues = 8;1212 myApp.val.cntPush = 0;1213 myApp.val.correctBool = false;1214 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1215 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1216 myApp.elem.ansCol.disabled = true;1217 myApp.elem.ansBtn.disabled = true;1218 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1219 },1220 function(){1221 myApp.val.status = myApp.state.Talk;1222 myApp.elem.ansCol.disabled = true;1223 myApp.elem.ansBtn.disabled = true;1224 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1225 },1226 function(){1227 /* 第9å */1228 myApp.val.ansIndex = 18;1229 myApp.val.ansIndexStartTime = 161.48;1230 //1231 myApp.val.status = myApp.state.Question;1232 myApp.val.numQues = 9;1233 myApp.val.cntPush = 0;1234 myApp.val.correctBool = false;1235 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1236 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1237 myApp.elem.ansCol.disabled = true;1238 myApp.elem.ansBtn.disabled = true;1239 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1240 },1241 function(){1242 myApp.val.status = myApp.state.Talk;1243 myApp.elem.ansCol.disabled = true;1244 myApp.elem.ansBtn.disabled = true;1245 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1246 },1247 function(){1248 /* 第10å */1249 myApp.val.ansIndex = 20;1250 myApp.val.ansIndexStartTime = 177.07;1251 //1252 myApp.val.status = myApp.state.Question;1253 myApp.val.numQues = 10;1254 myApp.val.cntPush = 0;1255 myApp.val.correctBool = false;1256 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1257 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1258 myApp.elem.ansCol.disabled = true;1259 myApp.elem.ansBtn.disabled = true;1260 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1261 },1262 function(){1263 myApp.val.status = myApp.state.Talk;1264 myApp.elem.ansCol.disabled = true;1265 myApp.elem.ansBtn.disabled = true;1266 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1267 },1268 function(){1269 /* 第11å */1270 myApp.val.ansIndex = 22;1271 myApp.val.ansIndexStartTime = 195.32;1272 //1273 myApp.val.status = myApp.state.Question;1274 myApp.val.numQues = 11;1275 myApp.val.cntPush = 0;1276 myApp.val.correctBool = false;1277 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1278 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1279 myApp.elem.ansCol.disabled = true;1280 myApp.elem.ansBtn.disabled = true;1281 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1282 },1283 function(){1284 myApp.val.status = myApp.state.Talk;1285 myApp.elem.ansCol.disabled = true;1286 myApp.elem.ansBtn.disabled = true;1287 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1288 },1289 function(){1290 /* 第12å */1291 myApp.val.ansIndex = 24;1292 myApp.val.ansIndexStartTime = 212.39;1293 //1294 myApp.val.status = myApp.state.Question;1295 myApp.val.numQues = 12;1296 myApp.val.cntPush = 0;1297 myApp.val.correctBool = false;1298 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1299 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1300 myApp.elem.ansCol.disabled = true;1301 myApp.elem.ansBtn.disabled = true;1302 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1303 },1304 function(){1305 myApp.val.status = myApp.state.Talk;1306 myApp.elem.ansCol.disabled = true;1307 myApp.elem.ansBtn.disabled = true;1308 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1309 },1310 function(){1311 /* 第13å */1312 myApp.val.ansIndex = 26;1313 myApp.val.ansIndexStartTime = 229.08;1314 //1315 myApp.val.status = myApp.state.Question;1316 myApp.val.numQues = 13;1317 myApp.val.cntPush = 0;1318 myApp.val.correctBool = false;1319 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1320 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1321 myApp.elem.ansCol.disabled = true;1322 myApp.elem.ansBtn.disabled = true;1323 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1324 },1325 function(){1326 myApp.val.status = myApp.state.Talk;1327 myApp.elem.ansCol.disabled = true;1328 myApp.elem.ansBtn.disabled = true;1329 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1330 },1331 function(){1332 /* 第14å */1333 myApp.val.ansIndex = 28;1334 myApp.val.ansIndexStartTime = 243.28;1335 //1336 myApp.val.status = myApp.state.Question;1337 myApp.val.numQues = 14;1338 myApp.val.cntPush = 0;1339 myApp.val.correctBool = false;1340 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1341 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1342 myApp.elem.ansCol.disabled = true;1343 myApp.elem.ansBtn.disabled = true;1344 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1345 },1346 function(){1347 myApp.val.status = myApp.state.Talk;1348 myApp.elem.ansCol.disabled = true;1349 myApp.elem.ansBtn.disabled = true;1350 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1351 },1352 function(){1353 /* 第15å */1354 myApp.val.ansIndex = 30;1355 myApp.val.ansIndexStartTime = 260.15;1356 //1357 myApp.val.status = myApp.state.Question;1358 myApp.val.numQues = 15;1359 myApp.val.cntPush = 0;1360 myApp.val.correctBool = false;1361 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1362 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1363 myApp.elem.ansCol.disabled = true;1364 myApp.elem.ansBtn.disabled = true;1365 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1366 },1367 function(){1368 myApp.val.status = myApp.state.Talk;1369 myApp.elem.ansCol.disabled = true;1370 myApp.elem.ansBtn.disabled = true;1371 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1372 },1373 function(){1374 /* 第16å */1375 myApp.val.ansIndex = 32;1376 myApp.val.ansIndexStartTime = 275.11;1377 //1378 myApp.val.status = myApp.state.Question;1379 myApp.val.numQues = 16;1380 myApp.val.cntPush = 0;1381 myApp.val.correctBool = false;1382 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1383 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1384 myApp.elem.ansCol.disabled = true;1385 myApp.elem.ansBtn.disabled = true;1386 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1387 },1388 function(){1389 myApp.val.status = myApp.state.Talk;1390 myApp.elem.ansCol.disabled = true;1391 myApp.elem.ansBtn.disabled = true;1392 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1393 },1394 function(){1395 /* 第17å */1396 myApp.val.ansIndex = 34;1397 myApp.val.ansIndexStartTime = 292.73;1398 //1399 myApp.val.status = myApp.state.Question;1400 myApp.val.numQues = 17;1401 myApp.val.cntPush = 0;1402 myApp.val.correctBool = false;1403 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1404 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1405 myApp.elem.ansCol.disabled = true;1406 myApp.elem.ansBtn.disabled = true;1407 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1408 },1409 function(){1410 myApp.val.status = myApp.state.Talk;1411 myApp.elem.ansCol.disabled = true;1412 myApp.elem.ansBtn.disabled = true;1413 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1414 },1415 function(){1416 /* 第18å */1417 myApp.val.ansIndex = 36;1418 myApp.val.ansIndexStartTime = 306.66;1419 //1420 myApp.val.status = myApp.state.Question;1421 myApp.val.numQues = 18;1422 myApp.val.cntPush = 0;1423 myApp.val.correctBool = false;1424 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1425 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1426 myApp.elem.ansCol.disabled = true;1427 myApp.elem.ansBtn.disabled = true;1428 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1429 },1430 function(){1431 myApp.val.status = myApp.state.Talk;1432 myApp.elem.ansCol.disabled = true;1433 myApp.elem.ansBtn.disabled = true;1434 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1435 },1436 function(){1437 /* 第19å */1438 myApp.val.ansIndex = 38;1439 myApp.val.ansIndexStartTime = 322.47;1440 //1441 myApp.val.status = myApp.state.Question;1442 myApp.val.numQues = 19;1443 myApp.val.cntPush = 0;1444 myApp.val.correctBool = false;1445 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1446 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1447 myApp.elem.ansCol.disabled = true;1448 myApp.elem.ansBtn.disabled = true;1449 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1450 },1451 function(){1452 myApp.val.status = myApp.state.Talk;1453 myApp.elem.ansCol.disabled = true;1454 myApp.elem.ansBtn.disabled = true;1455 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1456 },1457 function(){1458 /* 第20å */1459 myApp.val.ansIndex = 40;1460 myApp.val.ansIndexStartTime = 338.12;1461 //1462 myApp.val.status = myApp.state.Question;1463 myApp.val.numQues = 20;1464 myApp.val.cntPush = 0;1465 myApp.val.correctBool = false;1466 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1467 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1468 myApp.elem.ansCol.disabled = true;1469 myApp.elem.ansBtn.disabled = true;1470 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1471 },1472 function(){1473 myApp.val.status = myApp.state.Talk;1474 myApp.elem.ansCol.disabled = true;1475 myApp.elem.ansBtn.disabled = true;1476 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1477 },1478 function(){1479 /* 第21å */1480 myApp.val.ansIndex = 42;1481 myApp.val.ansIndexStartTime = 353.49;1482 //1483 myApp.val.status = myApp.state.Question;1484 myApp.val.numQues = 21;1485 myApp.val.cntPush = 0;1486 myApp.val.correctBool = false;1487 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1488 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1489 myApp.elem.ansCol.disabled = true;1490 myApp.elem.ansBtn.disabled = true;1491 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1492 },1493 function(){1494 myApp.val.status = myApp.state.Talk;1495 myApp.elem.ansCol.disabled = true;1496 myApp.elem.ansBtn.disabled = true;1497 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1498 },1499 function(){1500 /* 第22å */1501 myApp.val.ansIndex = 44;1502 myApp.val.ansIndexStartTime = 371.45;1503 //1504 myApp.val.status = myApp.state.Question;1505 myApp.val.numQues = 22;1506 myApp.val.cntPush = 0;1507 myApp.val.correctBool = false;1508 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1509 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1510 myApp.elem.ansCol.disabled = true;1511 myApp.elem.ansBtn.disabled = true;1512 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1513 },1514 function(){1515 myApp.val.status = myApp.state.Talk;1516 myApp.elem.ansCol.disabled = true;1517 myApp.elem.ansBtn.disabled = true;1518 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1519 },1520 function(){1521 /* 第23å */1522 myApp.val.ansIndex = 46;1523 myApp.val.ansIndexStartTime = 387.09;1524 //1525 myApp.val.status = myApp.state.Question;1526 myApp.val.numQues = 23;1527 myApp.val.cntPush = 0;1528 myApp.val.correctBool = false;1529 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1530 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1531 myApp.elem.ansCol.disabled = true;1532 myApp.elem.ansBtn.disabled = true;1533 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1534 },1535 function(){1536 myApp.val.status = myApp.state.Talk;1537 myApp.elem.ansCol.disabled = true;1538 myApp.elem.ansBtn.disabled = true;1539 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1540 },1541 function(){1542 /* 第24å */1543 myApp.val.ansIndex = 48;1544 myApp.val.ansIndexStartTime = 401.47;1545 //1546 myApp.val.status = myApp.state.Question;1547 myApp.val.numQues = 24;1548 myApp.val.cntPush = 0;1549 myApp.val.correctBool = false;1550 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1551 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1552 myApp.elem.ansCol.disabled = true;1553 myApp.elem.ansBtn.disabled = true;1554 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1555 },1556 function(){1557 myApp.val.status = myApp.state.Talk;1558 myApp.elem.ansCol.disabled = true;1559 myApp.elem.ansBtn.disabled = true;1560 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1561 },1562 function(){1563 /* 第25å */1564 myApp.val.ansIndex = 50;1565 myApp.val.ansIndexStartTime = 415.59;1566 //1567 myApp.val.status = myApp.state.Question;1568 myApp.val.numQues = 25;1569 myApp.val.cntPush = 0;1570 myApp.val.correctBool = false;1571 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1572 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1573 myApp.elem.ansCol.disabled = true;1574 myApp.elem.ansBtn.disabled = true;1575 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1576 },1577 function(){1578 myApp.val.status = myApp.state.Talk;1579 myApp.elem.ansCol.disabled = true;1580 myApp.elem.ansBtn.disabled = true;1581 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1582 },1583 function(){1584 /* 第26å */1585 myApp.val.ansIndex = 52;1586 myApp.val.ansIndexStartTime = 431.52;1587 //1588 myApp.val.status = myApp.state.Question;1589 myApp.val.numQues = 26;1590 myApp.val.cntPush = 0;1591 myApp.val.correctBool = false;1592 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1593 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1594 myApp.elem.ansCol.disabled = true;1595 myApp.elem.ansBtn.disabled = true;1596 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1597 },1598 function(){1599 myApp.val.status = myApp.state.Talk;1600 myApp.elem.ansCol.disabled = true;1601 myApp.elem.ansBtn.disabled = true;1602 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1603 },1604 function(){1605 /* 第27å */1606 myApp.val.ansIndex = 54;1607 myApp.val.ansIndexStartTime = 448.93;1608 //1609 myApp.val.status = myApp.state.Question;1610 myApp.val.numQues = 27;1611 myApp.val.cntPush = 0;1612 myApp.val.correctBool = false;1613 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1614 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1615 myApp.elem.ansCol.disabled = true;1616 myApp.elem.ansBtn.disabled = true;1617 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1618 },1619 function(){1620 myApp.val.status = myApp.state.Talk;1621 myApp.elem.ansCol.disabled = true;1622 myApp.elem.ansBtn.disabled = true;1623 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1624 },1625 function(){1626 /* 第28å */1627 myApp.val.ansIndex = 56;1628 myApp.val.ansIndexStartTime = 462.8;1629 //1630 myApp.val.status = myApp.state.Question;1631 myApp.val.numQues = 28;1632 myApp.val.cntPush = 0;1633 myApp.val.correctBool = false;1634 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1635 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1636 myApp.elem.ansCol.disabled = true;1637 myApp.elem.ansBtn.disabled = true;1638 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1639 },1640 function(){1641 myApp.val.status = myApp.state.Talk;1642 myApp.elem.ansCol.disabled = true;1643 myApp.elem.ansBtn.disabled = true;1644 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1645 },1646 function(){1647 /* 第29å */1648 myApp.val.ansIndex = 58;1649 myApp.val.ansIndexStartTime = 477.05;1650 //1651 myApp.val.status = myApp.state.Question;1652 myApp.val.numQues = 29;1653 myApp.val.cntPush = 0;1654 myApp.val.correctBool = false;1655 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1656 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1657 myApp.elem.ansCol.disabled = true;1658 myApp.elem.ansBtn.disabled = true;1659 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1660 },1661 function(){1662 myApp.val.status = myApp.state.Talk;1663 myApp.elem.ansCol.disabled = true;1664 myApp.elem.ansBtn.disabled = true;1665 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1666 },1667 function(){1668 /* 第30å */1669 myApp.val.ansIndex = 60;1670 myApp.val.ansIndexStartTime = 491.25;1671 //1672 myApp.val.status = myApp.state.Question;1673 myApp.val.numQues = 30;1674 myApp.val.cntPush = 0;1675 myApp.val.correctBool = false;1676 myApp.elem.text.innerHTML = "第"+myApp.val.numQues+"å";1677 myApp.elem.ansCol.value = "ããã«è§£çãå
¥å";1678 myApp.elem.ansCol.disabled = true;1679 myApp.elem.ansBtn.disabled = true;1680 if(Math.abs(window.orientation) != 90){ myApp.elem.pushBtn.src = myApp.elem.imgBtn1.src; }1681 },1682 function(){1683 myApp.val.status = myApp.state.Talk;1684 myApp.elem.ansCol.disabled = true;1685 myApp.elem.ansBtn.disabled = true;1686 myApp.elem.pushBtn.src = myApp.elem.imgBtn4.src;1687 },1688];16891169000:00:37,340 --> 00:00:47,86016912169200:00:47,860 --> 00:00:51,13016933169400:00:51,130 --> 00:00:59,07016954169600:00:59,070 --> 00:01:01,99016975169800:01:01,990 --> 00:01:11,78016996170000:01:11,780 --> 00:01:16,03017017170200:01:16,030 --> 00:01:29,22017038170400:01:29,220 --> 00:01:32,84017059170600:01:32,840 --> 00:01:46,270170710170800:01:46,270 --> 00:01:49,270170911171000:01:49,270 --> 00:01:59,960171112171200:01:59,960 --> 00:02:04,540171313171400:02:04,540 --> 00:02:16,630171514171600:02:16,630 --> 00:02:19,960171715171800:02:19,960 --> 00:02:28,560171916172000:02:28,560 --> 00:02:32,190172117172200:02:32,190 --> 00:02:41,480172318172400:02:41,480 --> 00:02:45,310172519172600:02:45,310 --> 00:02:57,070172720172800:02:57,070 --> 00:03:00,940172921173000:03:00,940 --> 00:03:15,320173122173200:03:15,320 --> 00:03:22,180173323173400:03:22,180 --> 00:03:32,390173524173600:03:32,390 --> 00:03:35,830173725173800:03:35,830 --> 00:03:49,080173926174000:03:49,080 --> 00:03:52,680174127174200:03:52,680 --> 00:04:03,280174328174400:04:03,280 --> 00:04:07,340174529174600:04:07,340 --> 00:04:20,150174730174800:04:20,150 --> 00:04:23,330174931175000:04:23,330 --> 00:04:35,110175132175200:04:35,110 --> 00:04:40,010175333175400:04:40,010 --> 00:04:52,730175534175600:04:52,730 --> 00:04:56,650175735175800:04:56,650 --> 00:05:06,660175936176000:05:06,660 --> 00:05:10,650176137176200:05:10,650 --> 00:05:22,470176338176400:05:22,470 --> 00:05:26,190176539176600:05:26,190 --> 00:05:38,120176740176800:05:38,120 --> 00:05:42,790176941177000:05:42,790 --> 00:05:53,490177142177200:05:53,490 --> 00:05:57,690177343177400:05:57,690 --> 00:06:11,450177544177600:06:11,450 --> 00:06:15,950177745177800:06:15,950 --> 00:06:27,090177946178000:06:27,090 --> 00:06:30,900178147178200:06:30,900 --> 00:06:41,470178348178400:06:41,470 --> 00:06:44,970178549178600:06:44,970 --> 00:06:55,590178750178800:06:55,590 --> 00:07:00,480178951179000:07:00,480 --> 00:07:11,520179152179200:07:11,520 --> 00:07:15,110179353179400:07:15,110 --> 00:07:28,930179554179600:07:28,930 --> 00:07:33,210179755179800:07:33,210 --> 00:07:42,800179956180000:07:42,800 --> 00:07:46,280180157180200:07:46,280 --> 00:07:57,050180358180400:07:57,050 --> 00:08:00,590180559180600:08:00,590 --> 00:08:11,250180760...
pushRelationships.js
Source:pushRelationships.js
1/*globals MyApp module test ok equals same stop start */2module("Propogating relationships with Store#pushRetrieve and Store#pushDestroy", {3 setup: function () {4 var MyApp = window.MyApp = SC.Object.create({5 store: SC.Store.create(SC.RelationshipSupport)6 });7 }8});9// ..........................................................10// pushRetrieve BEHAVIOR11//12/**13 [master] --> [slave]14 precond - master has a slave15 test - slave has a master16 */17test("Master updates a slave [one(master) to one(slave)].", function () {18 MyApp.Master = SC.Record.extend({19 slave: SC.Record.toOne('MyApp.Slave', {20 inverse: 'master',21 isMaster: YES22 })23 });24 MyApp.Slave = SC.Record.extend({25 master: SC.Record.toOne('MyApp.Master', {26 inverse: 'slave',27 isMaster: NO28 })29 });30 SC.RunLoop.begin();31 MyApp.store.loadRecords(MyApp.Slave, [32 { guid: 's1' }33 ]);34 MyApp.store.loadRecords(MyApp.Master, [35 { guid: 'm1', slave: 's1' }36 ]);37 SC.RunLoop.end();38 var s1 = MyApp.store.find(MyApp.Slave, 's1'),39 m1 = MyApp.store.find(MyApp.Master, 'm1');40 equals(m1.get('slave'), s1, 'precond - m1 should have a slave');41 equals(s1.get('master'), m1, 's1 should have a master');42});43/**44 [master]45 v46 |47 +--> [slave1]48 |49 ...50 |51 +--> [slaveN]52 precond - master has slaves53 test - slaves have a master54 */55test("A master updates many slave [one(master) to many(slave)].", function () {56 MyApp.Slave = SC.Record.extend({57 master: SC.Record.toOne('MyApp.Master', {58 inverse: 'slaves',59 isMaster: NO60 })61 });62 MyApp.Master = SC.Record.extend({63 slaves: SC.Record.toMany('MyApp.Slave', {64 inverse: 'master',65 isMaster: YES66 })67 });68 SC.RunLoop.begin();69 MyApp.store.loadRecords(MyApp.Slave, [70 { guid: 's1' },71 { guid: 's2' }72 ]);73 MyApp.store.loadRecords(MyApp.Master, [74 { guid: 'm1', slaves: ['s1', 's2'] }75 ]);76 SC.RunLoop.end();77 var s1 = MyApp.store.find(MyApp.Slave, 's1'),78 s2 = MyApp.store.find(MyApp.Slave, 's2'),79 m1 = MyApp.store.find(MyApp.Master, 'm1');80 equals(m1.get('slaves').length(), 2, 'precond - m1 has 2 slaves');81 equals(s1.get('master'), m1, 's1 should have master m1');82 equals(s2.get('master'), m1, 's2 should have master m1');83});84/**85 [slave]86 ^87 |88 +--< [master1]89 |90 ...91 |92 +--< [masterN]93 precond - master has a slave94 test - slave has many masters95 */96test("Many parent master updates a slave [many(master) to one(slave)]", function () {97 MyApp.Slave = SC.Record.extend({98 masters: SC.Record.toMany('MyApp.Master', {99 inverse: 'slave',100 isMaster: NO101 })102 });103 MyApp.Master = SC.Record.extend({104 slave: SC.Record.toOne('MyApp.Slave', {105 inverse: 'masters',106 isMaster: YES107 })108 });109 SC.RunLoop.begin();110 MyApp.store.loadRecords(MyApp.Slave, [111 { guid: 's1' }112 ]);113 MyApp.store.loadRecords(MyApp.Master, [114 { guid: 'm1', slave: 's1' },115 { guid: 'm2', slave: 's1' }116 ]);117 SC.RunLoop.end();118 var m1 = MyApp.store.find(MyApp.Master, 'm1'),119 m2 = MyApp.store.find(MyApp.Master, 'm2'),120 s1 = MyApp.store.find(MyApp.Slave, 's1');121 equals(m1.get('slave'), s1, 'precond - m1 should have slave s1');122 equals(m2.get('slave'), s1, 'precond - m2 should have slave s1');123 equals(s1.get('masters').length(), 2, 'slave has 2 masters');124 ok(s1.get('masters').indexOf(m1) !== -1, 'slave has master m1');125 ok(s1.get('masters').indexOf(m2) !== -1, 'slave has master m2');126});127/**128 [master1] ... [masterN]129 v v130 | |131 >------- ... -> [slave1]132 | |133 ... ...134 | |135 >------- ... -> [slaveN]136 precond - masters have many slaves137 test - slaves have many masters138 */139test("Many masters update many slaves [many(master) to many(slave)]", function () {140 MyApp.Master = SC.Record.extend({141 slaves: SC.Record.toMany('MyApp.Slave', {142 inverse: 'masters',143 isMaster: YES144 })145 });146 MyApp.Slave = SC.Record.extend({147 masters: SC.Record.toMany('MyApp.Master', {148 inverse: 'slaves',149 isMaster: NO150 })151 });152 SC.RunLoop.begin();153 MyApp.store.loadRecords(MyApp.Slave, [154 { guid: 's1' },155 { guid: 's2' }156 ]);157 MyApp.store.loadRecords(MyApp.Master, [158 { guid: 'm1', slaves: ['s1', 's2'] },159 { guid: 'm2', slaves: ['s1', 's2'] }160 ]);161 SC.RunLoop.end();162 var m1 = MyApp.store.find(MyApp.Master, 'm1'),163 m2 = MyApp.store.find(MyApp.Master, 'm2'),164 s1 = MyApp.store.find(MyApp.Slave, 's1'),165 s2 = MyApp.store.find(MyApp.Slave, 's2');166 equals(m1.get('slaves').length(), 2, 'precond - m1 should have 2 slaves');167 equals(m2.get('slaves').length(), 2, 'precond - m2 should have 2 slaves');168 equals(s1.get('masters').length(), 2, 's1 should have 2 masters');169 ok(s1.get('masters').indexOf(m1) !== -1, 's1 should have m1 as a master');170 ok(s1.get('masters').indexOf(m2) !== -1, 's1 should have m2 as a master');171 equals(s2.get('masters').length(), 2, 's2 should have 2 masters');172 ok(s2.get('masters').indexOf(m1) !== -1, 's2 should have m1 as a master');173 ok(s2.get('masters').indexOf(m2) !== -1, 's2 should have m2 as a master');174});175/**176 [slave] >--- X ---> [*]177 precond - * is related to slave178 test - after update to slave, * is related to slave179 */180test("A slave does NOT update a relationship [one(slave) to *]", function () {181 MyApp.Slave = SC.Record.extend({182 relative: SC.Record.toOne('MyApp.Relative', {183 inverse: 'slave',184 isMaster: NO185 })186 });187 MyApp.Relative = SC.Record.extend({188 slave: SC.Record.toOne('MyApp.Slave', {189 inverse: 'relative',190 isMaster: YES191 })192 });193 // case create slave WITHOUT relationship194 SC.RunLoop.begin();195 MyApp.store.loadRecords(MyApp.Slave, [196 { guid: 's1' }197 ]);198 MyApp.store.loadRecords(MyApp.Relative, [199 { guid: 'r1', slave: 's1' }200 ]);201 SC.RunLoop.end();202 var s1 = MyApp.store.find(MyApp.Slave, 's1'),203 r1 = MyApp.store.find(MyApp.Relative, 'r1');204 equals(s1.get('relative'), r1, 'precond1 - s1 has relative r1');205 SC.RunLoop.begin();206 MyApp.store.loadRecords(MyApp.Slave, [207 { guid: 's1' }208 ]);209 SC.RunLoop.end();210 ok(SC.none(s1.get('relative')), 'precond2 - s1 has no relative');211 equals(r1.get('slave'), s1, 'test1- r1 is related to s1');212 // case - create slave WITH relationship213 SC.RunLoop.begin();214 MyApp.store.loadRecords(MyApp.Relative, [215 { guid: 'r2'}216 ]);217 MyApp.store.loadRecords(MyApp.Slave, [218 { guid: 's2', relative: 'r2' }219 ]);220 SC.RunLoop.end();221 var s2 = MyApp.store.find(MyApp.Slave, 's2'),222 r2 = MyApp.store.find(MyApp.Relative, 'r2');223 equals(s2.get('relative'), r2, 'precond3 - s2 is related to r2');224 ok(SC.none(r2.get('slave')), 'test2 - r2 should NOT have a slave');225});226/**227 [master1] <----> [master2]228 precond - master1 has master2229 test - master2 has master1230 */231test("A master will mutually update a master [one(master) to one(master)].", function () {232 MyApp.Master = SC.Record.extend({233 relative: SC.Record.toOne('MyApp.Master', {234 inverse: 'relative',235 isMaster: YES236 })237 });238 SC.RunLoop.begin();239 MyApp.store.loadRecords(MyApp.Master, [240 { guid: 'm1' }241 ]);242 MyApp.store.loadRecords(MyApp.Master, [243 { guid: 'm2', relative: 'm1' }244 ]);245 SC.RunLoop.end();246 var m1 = MyApp.store.find(MyApp.Master, 'm1'),247 m2 = MyApp.store.find(MyApp.Master, 'm2');248 equals(m1.get('relative'), m2, 'precond - m1 should have a relative "m2"');249 equals(m2.get('relative'), m1, 'm2 should have a relative "m1"');250});251// ..........................................................252// REPLACING RELATIONSHIPS253//254/**255 [master1] <--> [slave]256 precond - master1 has slave257 precond - slave has master1258 ...relate master2 to slave...259 [master1] --> [slave]260 ^261 |262 [master2] <----+263 precond - master2 has slave264 precond - slave has master2265 test - master1 has slave266 */267test("Stealing relationship does NOT propagate to other masters [one(master) to one(slave)]", function () {268 MyApp.Slave = SC.Record.extend({269 master: SC.Record.toOne('MyApp.Master', {270 inverse: 'slave',271 isMaster: NO272 })273 });274 MyApp.Master = SC.Record.extend({275 slave: SC.Record.toOne('MyApp.Slave', {276 inverse: 'master',277 isMaster: YES278 })279 });280 SC.RunLoop.begin();281 MyApp.store.loadRecords(MyApp.Slave, [282 { guid: 's1' }283 ]);284 MyApp.store.loadRecords(MyApp.Master, [285 { guid: 'm1', slave: 's1' }286 ]);287 SC.RunLoop.end();288 var s1 = MyApp.store.find(MyApp.Slave, 's1'),289 m1 = MyApp.store.find(MyApp.Master, 'm1');290 equals(m1.get('slave'), s1, 'precond - m1 should have s1');291 equals(s1.get('master'), m1, 'precond - s1 should relate to m1');292 SC.RunLoop.begin();293 MyApp.store.loadRecords(MyApp.Master, [294 { guid: 'm2', slave: 's1' }295 ]);296 SC.RunLoop.end();297 var m2 = MyApp.store.find(MyApp.Master, 'm2');298 equals(m2.get('slave'), s1, 'precond - m2 should have s1');299 equals(s1.get('master'), m2, 'precond - s1 should relate to m2');300 equals(m1.get('slave'), s1, 'm1 should have child s1');301});302// ..........................................................303// RELINQUISHING RELATIONSHIPS304//305/**306 [master] <----> [slave1]307 precond - master has slave1308 precond - slave1 has master309 [master] <----> [slave2]310 X--- [slave1]311 precond - master has slave2312 precond - slave2 has master313 test - slave1 does NOT have master314 */315test("Relinquishing relationship on master<->* does propagate [one(master) to one(*)]", function () {316 MyApp.Slave = SC.Record.extend({317 master: SC.Record.toOne('MyApp.Master', {318 inverse: 'slave',319 isMaster: NO320 })321 });322 MyApp.Master = SC.Record.extend({323 slave: SC.Record.toOne('MyApp.Slave', {324 inverse: 'master',325 isMaster: YES326 })327 });328 SC.RunLoop.begin();329 MyApp.store.loadRecords(MyApp.Slave, [330 { guid: 's1' },331 { guid: 's2' }332 ]);333 MyApp.store.loadRecords(MyApp.Master, [334 { guid: 'm1', slave: 's1' }335 ]);336 SC.RunLoop.end();337 var s1 = MyApp.store.find(MyApp.Slave, 's1'),338 s2 = MyApp.store.find(MyApp.Slave, 's2'),339 m1 = MyApp.store.find(MyApp.Master, 'm1');340 equals(m1.get('slave'), s1, 'precond - m1 should have s1');341 equals(s1.get('master'), m1, 'precond - s1 should relate to m1');342 ok(SC.none(s2.get('master')), 'precond - s2 has NO master');343 SC.RunLoop.begin();344 MyApp.store.loadRecords(MyApp.Master, [345 { guid: 'm1', slave: 's2' }346 ]);347 SC.RunLoop.end();348 equals(m1.get('slave'), s2, 'precond - m1 should have s2');349 equals(s2.get('master'), m1, 'precond - s2 should relate to m1');350 ok(SC.none(s1.get('master')), 'test1 - s1 should have NO master');351});352/**353 [master] <----> [slave1, ..., slaveN]354 precond - master has slaves355 precond - slaves have master356 [master] ---X [slave1]357 precond - master does NOT have slave1358 test - slave1 does NOT have master359 */360test("Relinquishing a toMany relationship does propagate from master [one(master) to many(*)]", function () {361 MyApp.Slave = SC.Record.extend({362 master: SC.Record.toOne('MyApp.Master', {363 inverse: 'slaves',364 isMaster: NO365 })366 });367 MyApp.Master = SC.Record.extend({368 slaves: SC.Record.toMany('MyApp.Slave', {369 inverse: 'master',370 isMaster: YES371 })372 });373 SC.RunLoop.begin();374 MyApp.store.loadRecords(MyApp.Slave, [375 { guid: 's1' },376 { guid: 's2' }377 ]);378 MyApp.store.loadRecords(MyApp.Master, [379 { guid: 'm1', slaves: ['s1', 's2'] }380 ]);381 SC.RunLoop.end();382 var s1 = MyApp.store.find(MyApp.Slave, 's1'),383 s2 = MyApp.store.find(MyApp.Slave, 's2'),384 m1 = MyApp.store.find(MyApp.Master, 'm1');385 equals(m1.get('slaves').length(), 2, 'precond1 - m1 should have 2 slaves');386 equals(s1.get('master'), m1, 'precond2 - s1 should relate to m1');387 equals(s2.get('master'), m1, 'precond3 - s2 should relate to m1');388 SC.RunLoop.begin();389 MyApp.store.loadRecords(MyApp.Master, [390 { guid: 'm1', slaves: ['s1'] }391 ]);392 SC.RunLoop.end();393 equals(m1.get('slaves').length(), 1, 'precond4 - m1 should have 1 slave');394 equals(m1.get('slaves').objectAt(0), s1, 'precond5 - m1 should have slave s1');395 equals(s1.get('master'), m1, 'precond6 - s1 should relate to m1');396 ok(SC.none(s2.get('master')), 's2 should NOT have master');397});398/**399 [slave]400 ^401 |402 +--< [master1]403 |404 ...405 |406 +--< [masterN]407 precond - master1 has relationship to slave408 precond - slave has relationship many masters409 precond - slave has relationship to master1410 ...master1 relinquishes relationship to slave...411 [slave]412 ^413 |414 ...415 |416 +--< [masterN]417 precond - master1 has no slave418 test - slave has many masters, none of which is master1419 */420test("Relinquish propagates from many master to one slave [many(master) to one(slave)]", function () {421 MyApp.Master = SC.Record.extend({422 slave: SC.Record.toOne('MyApp.Slave', {423 inverse: 'masters',424 isMaster: YES425 })426 });427 MyApp.Slave = SC.Record.extend({428 masters: SC.Record.toMany('MyApp.Master', {429 inverse: 'slave',430 isMaster: NO431 })432 });433 SC.RunLoop.begin();434 MyApp.store.loadRecords(MyApp.Slave, [435 { guid: 's1' }436 ]);437 MyApp.store.loadRecords(MyApp.Master, [438 { guid: 'm1', slave: 's1' },439 { guid: 'm2', slave: 's1' }440 ]);441 SC.RunLoop.end();442 var m1 = MyApp.store.find(MyApp.Master, 'm1'),443 m2 = MyApp.store.find(MyApp.Master, 'm2'),444 s1 = MyApp.store.find(MyApp.Slave, 's1');445 equals(s1.get('masters').length(), 2, 'precond - s1 should have 2 masters');446 equals(m1.get('slave'), s1, 'precond - m1 should have slave s1');447 equals(m2.get('slave'), s1, 'precond - m2 should have slave s1');448 SC.RunLoop.begin();449 MyApp.store.loadRecords(MyApp.Master, [450 { guid: 'm1' }451 ]);452 SC.RunLoop.end();453 ok(SC.none(m1.get('slave')), 'precond - m1 should NOT have relationship with s1');454 equals(s1.get('masters').length(), 1, 's1 should have 1 master');455 equals(s1.get('masters').indexOf(m1), -1, 'm1 should NOT be that master');456});457/**458 [master1] ... [masterN]459 v v460 | |461 >------- ... -> [slave1]462 | |463 ... ...464 | |465 >------- ... -> [slaveN]466 precond - masters have many slaves467 precond - slaves have many masters468 ... master1 relinquishes relationship to slave1 ...469 [master1] ... [masterN]470 v v471 | |472 >-- X > [slave1]473 | |474 ... ...475 | |476 >------- ... -> [slaveM]477 precond - master1 has M-1 slaves (& not slave 1)478 test - slave1 has N-1 masters479 test - slave does NOT have relationship to master1480 */481test("Removing a relationship propagates from many master to many slave [many(master) to many(slave)]", function () {482 MyApp.Master = SC.Record.extend({483 slaves: SC.Record.toMany('MyApp.Slave', {484 inverse: 'masters',485 isMaster: YES486 })487 });488 MyApp.Slave = SC.Record.extend({489 masters: SC.Record.toMany('MyApp.Master', {490 inverse: 'slaves',491 isMaster: NO492 })493 });494 SC.RunLoop.begin();495 MyApp.store.loadRecords(MyApp.Slave, [496 { guid: 's1' },497 { guid: 's2' }498 ]);499 MyApp.store.loadRecords(MyApp.Master, [500 { guid: 'm1', slaves: ['s1', 's2'] },501 { guid: 'm2', slaves: ['s1', 's2'] }502 ]);503 SC.RunLoop.end();504 var m1 = MyApp.store.find(MyApp.Master, 'm1'),505 m2 = MyApp.store.find(MyApp.Master, 'm2'),506 s1 = MyApp.store.find(MyApp.Slave, 's1'),507 s2 = MyApp.store.find(MyApp.Slave, 's2');508 equals(m1.get('slaves').length(), 2, 'precond - m1 should have 2 slaves');509 equals(m2.get('slaves').length(), 2, 'precond - m2 should have 2 slaves');510 ok(s1.get('masters').indexOf(m1) !== -1, 'precond - s1 should have m1 as a master');511 ok(s1.get('masters').indexOf(m2) !== -1, 'precond - s1 should have m2 as a master');512 ok(s2.get('masters').indexOf(m1) !== -1, 'precond - s2 should have m1 as a master');513 ok(s2.get('masters').indexOf(m2) !== -1, 'precond - s2 should have m2 as a master');514 SC.RunLoop.begin();515 MyApp.store.loadRecords(MyApp.Master, [516 { guid: 'm1', slaves: ['s2'] }517 ]);518 SC.RunLoop.end();519 equals(m1.get('slaves').length(), 1, 'precond - m1 should have 1 slave');520 equals(m1.get('slaves').objectAt(0), s2, 'precond - m1 should have relationship to s2');521 ok(s1.get('masters').indexOf(m1) === -1, 's1 should NOT have m1 as a master');522 ok(s1.get('masters').indexOf(m2) !== -1, 's1 should have m2 as a master');523});524// ..........................................................525// pushDestroy BEHAVIOR526//527/**528 [master] --> [slave]529 precond - master has slave530 precond - slave has master531 ... pushDestroy master ...532 test - slave has NO master533 */534test("pushDestroy record propagates from master to slave [*(master) to one(slave)]", function () {535 MyApp.Master = SC.Record.extend({536 slave: SC.Record.toOne('MyApp.Slave', {537 inverse: 'master',538 isMaster: YES539 })540 });541 MyApp.Slave = SC.Record.extend({542 master: SC.Record.toOne('MyApp.Master', {543 inverse: 'slave',544 isMaster: NO545 })546 });547 SC.RunLoop.begin();548 MyApp.store.loadRecords(MyApp.Slave, [549 { guid: 's1' }550 ]);551 MyApp.store.loadRecords(MyApp.Master, [552 { guid: 'm1', slave: 's1' }553 ]);554 SC.RunLoop.end();555 var m1 = MyApp.store.find(MyApp.Master, 'm1'),556 s1 = MyApp.store.find(MyApp.Slave, 's1');557 equals(m1.get('slave'), s1, 'precond - m1 should have s1 as slave');558 equals(s1.get('master'), m1, 'precond - s1 should have m1 as slave');559 SC.RunLoop.begin();560 MyApp.store.pushDestroy(MyApp.Master, 'm1');561 SC.RunLoop.end();562 equals(m1.get('status'), SC.Record.DESTROYED_CLEAN, 'precond - m1 was destroyed');563 ok(SC.none(s1.get('master')), 's1 should NOT have a master');564});565/**566 [master] --> [slave]567 precond - master has slave568 precond - slave has master569 ... pushDestroy master ...570 test - slave has NO master571 */572test("pushDestroy record propagates from master to many slaves [*(master) to many(slave)]", function () {573 MyApp.Master = SC.Record.extend({574 slaves: SC.Record.toMany('MyApp.Slave', {575 inverse: 'masters',576 isMaster: YES577 })578 });579 MyApp.Slave = SC.Record.extend({580 masters: SC.Record.toMany('MyApp.Master', {581 inverse: 'slaves',582 isMaster: NO583 })584 });585 SC.RunLoop.begin();586 MyApp.store.loadRecords(MyApp.Slave, [587 { guid: 's1' },588 { guid: 's2' }589 ]);590 MyApp.store.loadRecords(MyApp.Master, [591 { guid: 'm1', slaves: ['s1', 's2'] }592 ]);593 SC.RunLoop.end();594 var m1 = MyApp.store.find(MyApp.Master, 'm1'),595 s1 = MyApp.store.find(MyApp.Slave, 's1'),596 s2 = MyApp.store.find(MyApp.Slave, 's2');597 equals(m1.get('slaves').length(), 2, 'precond - m1 should have 2 slaves');598 ok(s1.get('masters').indexOf(m1) !== -1, 'precond - s1 should have m1 as a master');599 ok(s2.get('masters').indexOf(m1) !== -1, 'precond - s2 should have m1 as a master');600 SC.RunLoop.begin();601 MyApp.store.pushDestroy(MyApp.Master, 'm1');602 SC.RunLoop.end();603 equals(m1.get('status'), SC.Record.DESTROYED_CLEAN, 'precond - m1 was destroyed');604 equals(s1.get('masters').length(), 0, 's1 should NOT have a master');605 equals(s2.get('masters').length(), 0, 's2 should NOT have a master');606});607/**608 [master] --> [slave]609 precond - slave has a master610 precond - master has a slave611 slave.destroy();612 precond - slave is destroyed613 ... pushDestroy master ...614 test - slave does NOT exist615 test - master does NOT exist616 */617test("pushDestroy record doesn't create a slave when it's been destroyed [*(master) to one(slave)]", function () {618 MyApp.Master = SC.Record.extend({619 slave: SC.Record.toOne('MyApp.Slave', {620 inverse: 'master',621 isMaster: YES622 })623 });624 MyApp.Slave = SC.Record.extend({625 master: SC.Record.toOne('MyApp.Master', {626 inverse: 'slave',627 isMaster: NO628 })629 });630 SC.RunLoop.begin();631 MyApp.store.loadRecords(MyApp.Slave, [632 { guid: 's1' }633 ]);634 MyApp.store.loadRecords(MyApp.Master, [635 { guid: 'm1', slave: 's1' }636 ]);637 SC.RunLoop.end();638 var m1 = MyApp.store.find(MyApp.Master, 'm1'),639 s1 = MyApp.store.find(MyApp.Slave, 's1');640 equals(m1.get('slave'), s1, 'precond - m1 should have 2 slaves');641 equals(s1.get('master'), m1, 'precond - s1 should have m1 as a master');642 SC.RunLoop.begin();643 s1.destroy();644 MyApp.store.commitRecords();645 MyApp.store.dataSourceDidDestroy(s1.storeKey);646 SC.RunLoop.end();647 ok(s1.isDestroyed(), 'precond - s1 should be destroyed');648 SC.RunLoop.begin();649 MyApp.store.pushDestroy(MyApp.Master, 'm1');650 SC.RunLoop.end();651 ok(s1.isDestroyed(), 'test - s1 should be destroyed');652 ok(m1.isDestroyed(), 'test - m1 should be destroyed');653});654/**655 Standard Sproutcore Behaviors656 This is data showing up from the server- after pushing in changes,657 all records should have status READY_CLEAN.658 */659test("Record status for master and slave should be READY_CLEAN", function () {660 MyApp.Master = SC.Record.extend({661 master: SC.Record.toOne('MyApp.Slave', {662 inverse: 'slave',663 isMaster: YES664 })665 });666 MyApp.Slave = SC.Record.extend({667 slave: SC.Record.toOne('MyApp.Master', {668 inverse: 'master',669 isMaster: NO670 })671 });672 // link one -> one673 SC.RunLoop.begin();674 MyApp.store.loadRecords(MyApp.Slave, [675 { guid: 's1' }676 ]);677 SC.RunLoop.end();678 var s1 = MyApp.store.find(MyApp.Slave, 's1');679 ok(s1.get('status') & SC.Record.READY_CLEAN, 'precond - s1 should be ready clean');680 SC.RunLoop.begin();681 MyApp.store.loadRecords(MyApp.Master, [682 { guid: 'm1', slave: 's1' }683 ]);684 SC.RunLoop.end();685 var m1 = MyApp.store.find(MyApp.Master, 'm1');686 ok(m1.get('status') & SC.Record.READY_CLEAN, 'm1 should be ready clean after linkage');687 ok(s1.get('status') & SC.Record.READY_CLEAN, 's1 should be ready clean after linkage');688 // unlink689 SC.RunLoop.begin();690 MyApp.store.loadRecords(MyApp.Master, [691 { guid: 'm1' }692 ]);693 SC.RunLoop.end();694 ok(m1.get('status') & SC.Record.READY_CLEAN, 'm1 should be ready clean after unlink');695 ok(s1.get('status') & SC.Record.READY_CLEAN, 's1 should be ready clean after unlink');696});697test("Record relationships are NOT propagated if related store item does NOT exist at load time", function () {698 MyApp.Generic = SC.Record.extend({699 relative: SC.Record.toOne('MyApp.Generic', {700 inverse: 'relative',701 isMaster: YES702 })703 });704 SC.RunLoop.begin();705 MyApp.store.loadRecords(MyApp.Generic, [706 { guid: 'g2', relative: 'g1' },707 { guid: 'g1' }708 ]);709 SC.RunLoop.end();710 var g1 = MyApp.store.find(MyApp.Generic, 'g1'),711 g2 = MyApp.store.find(MyApp.Generic, 'g2');712 equals(g2.get('relative'), g1, 'precond - g2 should be relative of g1');713 ok(SC.none(g1.get('relative')), 'g1 should not be related to g2');714});715test("Record Attribute can reference renamed attribute key", function () {716 MyApp.Master = SC.Record.extend({717 slave: SC.Record.toOne('MyApp.Slave', {718 inverse: 'master',719 isMaster: YES,720 key: 'alice'721 })722 });723 MyApp.Slave = SC.Record.extend({724 master: SC.Record.toOne('MyApp.Master', {725 inverse: 'slave',726 isMaster: NO727 })728 });729 // link one -> one730 SC.RunLoop.begin();731 MyApp.store.loadRecords(MyApp.Slave, [732 { guid: 's1' }733 ]);734 SC.RunLoop.end();735 var s1 = MyApp.store.find(MyApp.Slave, 's1');736 ok(s1.get('status') & SC.Record.READY_CLEAN, 'precond - s1 should be ready clean');737 SC.RunLoop.begin();738 MyApp.store.loadRecords(MyApp.Master, [739 { guid: 'm1', alice: 's1' }740 ]);741 SC.RunLoop.end();742 var m1 = MyApp.store.find(MyApp.Master, 'm1');743 equals(m1.get('slave'), s1, 'm1 should be master of s1');744 equals(s1.get('master'), m1, 's1 should have master of m1');745});746test("Record Attribute can reference renamed attribute key (1 to many)", function () {747 MyApp.Master = SC.Record.extend({748 slave: SC.Record.toOne('MyApp.Slave', {749 inverse: 'masters',750 isMaster: YES751 })752 });753 MyApp.Slave = SC.Record.extend({754 masters: SC.Record.toMany('MyApp.Master', {755 inverse: 'slave',756 isMaster: NO,757 key: 'master_ids'758 })759 });760 SC.RunLoop.begin();761 MyApp.store.loadRecords(MyApp.Slave, [762 { guid: 's1' }763 ]);764 SC.RunLoop.end();765 var s1 = MyApp.store.find(MyApp.Slave, 's1');766 ok(s1.get('status') & SC.Record.READY_CLEAN, 'precond - s1 should be ready clean');767 SC.RunLoop.begin();768 MyApp.store.loadRecords(MyApp.Master, [769 { guid: 'm1', slave: 's1' }770 ]);771 SC.RunLoop.end();772 var m1 = MyApp.store.find(MyApp.Master, 'm1');773 equals(m1.get('slave'), s1, 'm1 should be master of s1');774 same(s1.get('masters').toArray(), [m1], 's1 should have m1 in masters');775 same(s1.get('attributes').master_ids, [m1.get('id')], 's1.attributes should have master_ids key');776});777test("Record Attribute can reference renamed attribute key (on remote side)", function () {778 MyApp.Master = SC.Record.extend({779 slave: SC.Record.toOne('MyApp.Slave', {780 inverse: 'master',781 isMaster: YES782 })783 });784 MyApp.Slave = SC.Record.extend({785 master: SC.Record.toOne('MyApp.Master', {786 inverse: 'slave',787 isMaster: NO,788 key: 'bob'789 })790 });791 // link one -> one792 SC.RunLoop.begin();793 MyApp.store.loadRecords(MyApp.Slave, [794 { guid: 's1' }795 ]);796 SC.RunLoop.end();797 var s1 = MyApp.store.find(MyApp.Slave, 's1');798 ok(s1.get('status') & SC.Record.READY_CLEAN, 'precond - s1 should be ready clean');799 SC.RunLoop.begin();800 MyApp.store.loadRecords(MyApp.Master, [801 { guid: 'm1', slave: 's1' }802 ]);803 SC.RunLoop.end();804 var m1 = MyApp.store.find(MyApp.Master, 'm1');805 equals(m1.get('slave'), s1, 'm1 should be master of s1');806 equals(s1.get('master'), m1, 's1 should have master of m1');807});808test("Record property does change on linkage", function () {809 MyApp.Generic = SC.Record.extend({810 relative: SC.Record.toOne('MyApp.Generic', {811 inverse: 'relative',812 isMaster: YES813 }),814 callCount: 0,815 _relativeObserver: function () {816 this.incrementProperty('callCount');817 }.observes('relative')818 });819 SC.RunLoop.begin();820 MyApp.store.loadRecords(MyApp.Generic, [821 { guid: 'g1' },822 { guid: 'g2' }823 ]);824 SC.RunLoop.end();825 var g1 = MyApp.store.find(MyApp.Generic, 'g1'),826 g2 = MyApp.store.find(MyApp.Generic, 'g2');827 equals(g1.get('callCount'), 0, 'precond - g1._relativeObserver should NOT have fired yet');828 equals(g2.get('callCount'), 0, 'precond - g2._relativeObserver should NOT have fired yet');829 SC.RunLoop.begin();830 MyApp.store.loadRecords(MyApp.Generic, [831 { guid: 'g2', relative: 'g1' }832 ]);833 SC.RunLoop.end();834 equals(g1.get('relative'), g2, 'precond - g1 should be relative of g2');835 equals(g2.get('relative'), g1, 'precond - g2 should be relative of g1');836 equals(g1.get('callCount'), 1, 'g1._relativeObserver should fire once');837 equals(g2.get('callCount'), 1, 'g2._relativeObserver should fire once');838});839// ..........................................................840// RECORD ATTRIBUTE841//842/**843 lazilyInstantiate RecordAttribute flag tests.844 */845test("RecordAttribute flag 'lazilyInstantiate' tests", function () {846 MyApp.Master = SC.Record.extend({847 slave: SC.Record.toOne('MyApp.Slave', {848 inverse: 'master',849 isMaster: YES,850 lazilyInstantiate: YES851 })852 });853 MyApp.Slave = SC.Record.extend({854 master: SC.Record.toOne('MyApp.Master', {855 inverse: 'slave',856 isMaster: NO,857 lazilyInstantiate: YES // should be a noop858 })859 });860 SC.RunLoop.begin();861 MyApp.store.loadRecords(MyApp.Master, [862 { guid: 'm1', slave: 's1' }863 ]);864 MyApp.store.loadRecords(MyApp.Slave, [865 { guid: 's2', master: 'm2' }866 ]);867 SC.RunLoop.end();868 var m1 = MyApp.store.find(MyApp.Master, 'm1'),869 m2 = MyApp.store.find(MyApp.Master, 'm2'),870 s1 = MyApp.store.find(MyApp.Slave, 's1'),871 s2 = MyApp.store.find(MyApp.Slave, 's2');872 // test lazy creation on isMaster => YES873 ok(s1, 's1 should be created lazily');874 equals(m1.get('slave'), s1, 'm1 should be master of s1');875 // test lazy creation fails on isMaster => NO876 ok(SC.none(m2), 'm2 should NOT have been created');877 ok(!s2.get('master') ||878 s2.get('master').get('status') & SC.Record.ERROR, 's2 should have no master record');879});880/**881 lazilyInstantiate RecordAttribute flag can be a function.882 */883test("RecordAttribute flag 'lazilyInstantiate' can be a function", function () {884 MyApp.Master = SC.Record.extend({885 slave: SC.Record.toOne('MyApp.Slave', {886 inverse: 'master',887 isMaster: YES,888 lazilyInstantiate: function () {889 return NO;890 }891 })892 });893 MyApp.Slave = SC.Record.extend({894 master: SC.Record.toOne('MyApp.Master', {895 inverse: 'slave',896 isMaster: NO,897 lazilyInstantiate: YES // should be a noop898 })899 });900 SC.RunLoop.begin();901 MyApp.store.loadRecords(MyApp.Master, [902 { guid: 'm1', slave: 's1' }903 ]);904 MyApp.store.loadRecords(MyApp.Slave, [905 { guid: 's2', master: 'm2' }906 ]);907 SC.RunLoop.end();908 var m1 = MyApp.store.find(MyApp.Master, 'm1'),909 m2 = MyApp.store.find(MyApp.Master, 'm2'),910 s1 = MyApp.store.find(MyApp.Slave, 's1'),911 s2 = MyApp.store.find(MyApp.Slave, 's2');912 // test lazy creation on isMaster => NO913 ok(!s1, 's1 should NOT be created lazily');914 // test lazy creation fails on isMaster => NO915 ok(SC.none(m2), 'm2 should NOT have been created');916 ok(!s2.get('master') ||917 s2.get('master').get('status') & SC.Record.ERROR, 's2 should have no master record');918});919/**920 lazilyInstantiate should ride the chain all the way to the top.921 That is, if a record's primaryKey is a record that has the922 flag 'lazilyInstantiate' on it, it should lazily create that one,923 and so on.924 */925test("RecordAttribute flag 'lazilyInstantiate' will create chains of records properly", function () {926 MyApp.SuperMaster = SC.Record.extend({927 master: SC.Record.toOne('MyApp.Master', {928 inverse: 'superMaster',929 isMaster: YES,930 lazilyInstantiate: YES931 })932 });933 MyApp.Master = SC.Record.extend({934 primaryKey: 'slave',935 superMaster: SC.Record.toOne('MyApp.SuperMaster', {936 inverse: 'master',937 isMaster: NO938 }),939 slave: SC.Record.toOne('MyApp.Slave', {940 inverse: 'master',941 isMaster: YES,942 lazilyInstantiate: YES943 })944 });945 MyApp.Slave = SC.Record.extend({946 primaryKey: 'subSlave',947 master: SC.Record.toOne('MyApp.Master', {948 inverse: 'slave',949 isMaster: NO950 }),951 subSlave: SC.Record.toOne('MyApp.SubSlave', {952 inverse: 'slave',953 isMaster: YES,954 lazilyInstantiate: YES955 })956 });957 MyApp.SubSlave = SC.Record.extend({958 slave: SC.Record.toOne('MyApp.Slave', {959 inverse: 'subSlave',960 isMaster: NO961 })962 });963 SC.RunLoop.begin();964 MyApp.store.loadRecords(MyApp.SuperMaster, [965 { guid: 'sm', master: 's' }966 ]);967 SC.RunLoop.end();968 var sm = MyApp.store.find(MyApp.SuperMaster, 'sm'),969 m = MyApp.store.find(MyApp.Master, 's'),970 s = MyApp.store.find(MyApp.Slave, 's'),971 ss = MyApp.store.find(MyApp.SubSlave, 's');972 ok(m, 'm should be created lazily');973 equals(m.get('superMaster'), sm, 'sm should be master of m');974 ok(s, 's should be created lazily');975 equals(s.get('master'), m, 'm should be master of s');976 ok(ss, 'ss should be created lazily');977 equals(ss.get('slave'), s, 's should be master of ss');...
index.js
Source:index.js
1/* 2using timeouts with loops3http://stackoverflow.com/questions/25311892/cleartimeout-for-settimeout-in-for-loop4*/5var MYAPP = MYAPP || {6 gameInPlay: false,7 winCombos: [8 [1, 2, 3],9 [4, 5, 6],10 [7, 8, 9],11 [1, 4, 7],12 [2, 5, 8],13 [3, 6, 9],14 [1, 5, 9],15 [7, 5, 3]16 ],17 playerOneScore: 0,18 playerTwoScore: 0,19 timeOuts: [],20 initializeVars: function() {21 this.numFilledIn = 0;22 this.currentBoard = {23 1: '',24 2: '',25 3: '',26 4: '',27 5: '',28 6: '',29 7: '',30 8: '',31 9: ''32 };33 },34 initializeGame: function() {35 MYAPP.initializeVars();36 MYAPP.display.drawBoard();37 $('.game-choice button').click(function() {38 MYAPP.secondPlayer = MYAPP.game.gameSelection(this);39 MYAPP.display.hideGameChoice();40 MYAPP.display.showGameStarter(MYAPP.secondPlayer);41 $('.game-starter .choose-x, .game-starter .choose-o').off().click(MYAPP.game.firstGame);42 $('.back-button').on('click', function() {43 MYAPP.display.hideGameStarter();44 MYAPP.display.showGameChoice();45 });46 });47 $('.hard-reset').on('click', MYAPP.game.resetGame);48 }49};50 /*=========================51 Display functions52==========================*/53MYAPP.display = { 54 hideGameStarter: function() {55 $('.game-starter').fadeOut();56},57 showGameStarter: function(isTwoPlayer) {58 var message;59 if (isTwoPlayer) {60 message = "ÐгÑок 1 : ÐÑбеÑиÑе меÑкÑ"61 }62 else {63 message = "ÐÑбеÑиÑе меÑкÑ";64 }65 MYAPP.timeOuts.push(66 setTimeout(function() {67 $('.game-starter').fadeIn(500).children('p').text(message);68 }, 700));69},70 showGameChoice: function() {71 $('.game-choice').fadeIn(600);72},73 hideGameChoice: function() {74 $('.game-choice').fadeOut(600);75},76 showPlayerOnePrompt: function() {77 if (MYAPP.secondPlayer) {78 $('.player-one-turn p').text('1 игÑок');79 }80 else {81 $('.player-one-turn p').text('ÐÐ°Ñ Ñ
од');82 }83 $('.player-one-turn').animate({'top': '-50px'}, 500);84},85 hidePlayerOnePrompt: function() {86 $('.player-one-turn').animate({'top': '0'}, 500);87},88 showPlayerTwoPrompt: function() {89 if (MYAPP.secondPlayer) {90 $('.player-two-turn p').text('2 игÑок');91 }92 else {93 $('.player-two-turn p').text('ÐомпÑÑÑеÑ');94 }95 $('.player-two-turn').animate({'top': '-50px'}, 500);96},97 hidePlayerTwoPrompt: function() {98 $('.player-two-turn').animate({'top': '0'}, 500);99},100 showDrawMessage: function() {101 MYAPP.timeOuts.push(102 setTimeout(function() {103 $('.draw-message').fadeIn(500);104 }, 1500));105},106 hideDrawMessage: function() {107 $('.draw-message').fadeOut(1000);108},109 showLoseMessage: function() {110 MYAPP.timeOuts.push(111 setTimeout(function() {112 $('.lose-message').fadeIn(500);113}, 1500)114 );115},116 hideLoseMessage: function() {117 $('.lose-message').fadeOut(1000);118},119 showWinMessage: function() {120 MYAPP.timeOuts.push(121 setTimeout(function() {122 $('.win-message').fadeIn(500).children('p').text("ÐгÑок " + MYAPP.turn + " вÑигÑал ")123}, 1500));124},125 hideWinMessage: function() {126 $('.win-message').fadeOut(1000);127},128 drawBoard: function() {129 MYAPP.timeOuts.push(setTimeout(function() {130 var c = document.getElementById("myCanvas");131 var canvas = c.getContext("2d");132 canvas.lineWidth = 10;133 canvas.strokeStyle = "#fff";134 //vertical lines135 canvas.beginPath();136 canvas.moveTo(100, 0);137 canvas.lineTo(100, 146.5);138 canvas.closePath();139 canvas.stroke();140 canvas.beginPath();141 canvas.moveTo(200, 0);142 canvas.lineTo(200, 146.5);143 canvas.closePath();144 canvas.stroke();145 // horizontal lines146 canvas.lineWidth = 5;147 canvas.beginPath();148 canvas.moveTo(4, 48.5);149 canvas.lineTo(296, 48.5);150 canvas.closePath();151 canvas.stroke();152 153 canvas.beginPath();154 canvas.moveTo(4, 98.5);155 canvas.lineTo(296, 98.5);156 canvas.closePath();157 canvas.stroke(); 158 }, 1500));159},160 resetSquares: function() {161 $('.boxes').html('');162 for (var i = 1; i <= 9; i++) {163 var box = '<li class="' + i + '"><i class="letter"><span></span></i></li>';164 $(box).appendTo($('.boxes'));165 }166},167 168 showScore: function() {169 if (MYAPP.secondPlayer) {170 $('.score-1').children('.name').text('1 игÑок'); 171 $('.score-2').children('.name').text('2 игÑок'); 172 }173 else {174 $('.score-1').children('.name').text('ÐÑ'); 175 $('.score-2').children('.name').text('ÐомпÑÑÑеÑ'); 176 }177 $('.score-1, .score-2').children('.points').text('0');178 $('.score-1,.score-2, .points-divider').fadeIn();179 },180 updateScore: function(turn) {181 var currentScore = turn === 1 ? MYAPP.playerOneScore : MYAPP.playerTwoScore;182 $('.score-' + turn).children('.points').text(currentScore);183 }184};185/*=========================186 Game Logic187==========================*/188MYAPP.game = {189 whoStarts: function() {190 var random = Math.floor(Math.random() * 2 + 1);191 return random;192 },193 gameSelection: function(item) {194 if ($(item).text() === '1') {195 // returns what secondPlayer value to set196 return false;197 }198 else {199 return true;200 } 201 },202 firstGame: function() {203 MYAPP.playerOneSymbol = $(this).text();204 MYAPP.playerTwoSymbol = MYAPP.playerOneSymbol == 'X' ? 'O' : 'X'; 205 MYAPP.turn = MYAPP.game.whoStarts();206 MYAPP.display.hideGameStarter();207 $('#myCanvas').animate({'opacity': '1'}, 1200);208 $('.hard-reset').fadeIn(600);209 MYAPP.display.showScore();210 MYAPP.display.resetSquares();211 MYAPP.game.play();212 },213 play: function() {214 215 MYAPP.gameInPlay = true;216 $('.boxes li').on('click', function() {217 MYAPP.game.playerTurn(this);218 }); 219 220 MYAPP.timeOuts.push(221 setTimeout(function(){222 if (MYAPP.turn === 1) {223 MYAPP.display.showPlayerOnePrompt();224 }225 else if (MYAPP.turn === 2) {226 MYAPP.display.showPlayerTwoPrompt();227 }228 }, 1500),229 setTimeout(function() {230 if (MYAPP.turn === 2 && !MYAPP.secondPlayer) {231 MYAPP.game.computerPlay();232 }233 }, 1200));234 },235 playerTurn: function(square) {236 var symbol = MYAPP.turn === 1 ? MYAPP.playerOneSymbol : MYAPP.playerTwoSymbol;237 var box = $(square).children('i').children('span');238 if (box.text() === '' && MYAPP.gameInPlay && (MYAPP.turn === 1 || (MYAPP.turn === 2 && MYAPP.secondPlayer))) {239 box.text(symbol);240 var number = $(square).attr('class');241 MYAPP.game.updateSquare(number, symbol);242 MYAPP.game.endTurn(symbol);243 }244 },245 computerPlay: function() {246 var computer = MYAPP.computer;247 //test computer move suggestion248 var boxNumber;249 if (computer.computerWhichMove(MYAPP.game) && MYAPP.turn === 2) {250 boxNumber = computer.computerWhichMove(MYAPP.game);251 var currentBox = $('.' + boxNumber).children('i');252 253 var symbol = MYAPP.playerTwoSymbol;254 MYAPP.timeOuts.push(255 setTimeout(function() {256 currentBox.children('span').text(symbol);257 MYAPP.game.updateSquare(boxNumber, MYAPP.playerTwoSymbol);258 MYAPP.game.endTurn(symbol);259 }, 1000));260 } 261 },262 endTurn: function(symbol) {263 MYAPP.numFilledIn = MYAPP.numFilledIn + 1;264 if (MYAPP.gameInPlay) {265 if (MYAPP.game.checkWin(symbol)[0]) {266 MYAPP.game.updateScore(MYAPP.turn);267 if (MYAPP.secondPlayer) {268 MYAPP.display.showWinMessage();269 }270 else {271 MYAPP.turn === 1 ? MYAPP.display.showWinMessage() : MYAPP.display.showLoseMessage();272 }273 MYAPP.gameInPlay = false;274 MYAPP.game.showWinningCombination();275 MYAPP.display.hidePlayerOnePrompt();276 MYAPP.display.hidePlayerTwoPrompt();277 MYAPP.game.reset();278 }279 // stop if it is a draw280 else if (MYAPP.numFilledIn >= 9) {281 MYAPP.gameInPlay = false;282 MYAPP.display.hidePlayerOnePrompt();283 MYAPP.display.hidePlayerTwoPrompt();284 MYAPP.display.showDrawMessage();285 MYAPP.turn = MYAPP.game.whoStarts();286 MYAPP.game.reset();287 } else {288 if (MYAPP.turn === 1) {289 MYAPP.display.hidePlayerOnePrompt();290 MYAPP.display.showPlayerTwoPrompt();291 MYAPP.turn = 2;292 // call computer turn if no second player293 if (!MYAPP.secondPlayer) {294 MYAPP.game.computerPlay();295 }296 } else if (MYAPP.turn === 2) {297 MYAPP.display.showPlayerOnePrompt();298 MYAPP.display.hidePlayerTwoPrompt();299 MYAPP.turn = 1;300 }301 }302 }303 },304 updateSquare: function(number, symbol) {305 MYAPP.currentBoard[number] = symbol;306 },307 checkWin: function(symbol) {308 var currentBoard = MYAPP.currentBoard;309 var wins = MYAPP.winCombos;310 var winningCombo = [];311 var winner = wins.some(function(combination) {312 var winning = true;313 for (var i = 0; i < combination.length; i++) {314 if (currentBoard[combination[i]] !== symbol) {315 winning = false;316 }317 }318 if (winning) {319 winningCombo = combination;320 }321 return winning;322 });323 return [winner, winningCombo];324 },325 showWinningCombination: function() {326 var symbol = MYAPP.turn === 1 ? MYAPP.playerOneSymbol : MYAPP.playerTwoSymbol;327 var combo = MYAPP.game.checkWin(symbol)[1];328 for (var i = 0; i < combo.length; i++) {329 var currentBox = '.' + combo[i]; 330 // Black box and rotating test for winning combo 331 $(currentBox).children('i').addClass('win').children('span').addClass('rotate');332 }333 },334 updateScore: function(turn) {335 turn === 1 ? MYAPP.playerOneScore += 1 : MYAPP.playerTwoScore += 1; 336 337 MYAPP.display.updateScore(turn);338 339 },340 reset: function() {341 MYAPP.initializeVars();342 343 MYAPP.timeOuts.push(344 setTimeout(function() {345 MYAPP.display.hideDrawMessage();346 MYAPP.display.hideLoseMessage();347 MYAPP.display.hideWinMessage();348 $('.boxes li').fadeOut();349 }, 5000),350 setTimeout(function(){351 MYAPP.display.resetSquares();352 $('.boxes li').fadeIn();353 MYAPP.numFilledIn = 0;354 }, 6000),355 //Make sure time for next timeout is long enough356 //to not cause problems after first game357 setTimeout(function() {358 MYAPP.gameInPlay = true;359 MYAPP.game.play();360 }, 6000)361 );362 },363 resetGame: function() {364 $('#myCanvas').css('opacity', '0');365 $('.hard-reset').fadeOut();366 $('.points-divider, .score-1, .score-2').fadeOut();367 MYAPP.playerOneScore = 0;368 MYAPP.playerTwoScore = 0;369 MYAPP.display.resetSquares();370 MYAPP.initializeVars();371 MYAPP.gameInPlay = false;372 MYAPP.playerOneSymbol = null;373 MYAPP.playerTwoSymbol = null;374 MYAPP.timeOuts.forEach(function(timer) {375 clearTimeout(timer);376 });377 $('.draw-message, .win-message, .lose-message').hide();378 MYAPP.display.hidePlayerOnePrompt();379 MYAPP.display.hidePlayerTwoPrompt();380 MYAPP.display.showGameChoice();381 }382};383/* End Game Logic */384 385/*================================386 Computer Move Decisions387=================================*/ 388MYAPP.computer = {389 computerWhichMove: function () {390 var move = this.winOrBlockChoice('win')[0];391 if (!move) {392 move = this.winOrBlockChoice('block')[0];393 console.log(this.winOrBlockChoice('block'));394 }395 if (!move) {396 move = this.doubleThreatChoice('win');397 }398 if (!move) {399 move = this.doubleThreatChoice('block');400 }401 if (!move) {402 move = this.firstPlay();403 }404 if (!move) {405 move = this.playCenter();406 }407 if (!move) {408 move = this.emptyCorner();409 }410 if (!move) {411 move = this.emptySide();412 }413 move = (move && MYAPP.currentBoard[move]) === '' ? move : false;414 return move;415 },416 winOrBlockChoice: function(choiceType, board) {417 var board = board || MYAPP.currentBoard;418 if (choiceType === 'win') {419 var currentSymbol = MYAPP.playerTwoSymbol;420 var opponentSymbol = MYAPP.playerOneSymbol;421 } else if (choiceType === 'block') {422 var currentSymbol = MYAPP.playerOneSymbol;423 var opponentSymbol = MYAPP.playerTwoSymbol;424 } else {425 return;426 }427 var moves = [];428 MYAPP.winCombos.forEach(function(combo) {429 var notFound = [];430 var notPlayer = true;431 for (var i = 0; i < combo.length; i++) {432 if (board[combo[i]] !== currentSymbol) {433 if (board[combo[i]] === opponentSymbol) {434 notPlayer = false;435 } else {436 notFound.push(combo[i]);437 }438 }439 }440 if (notFound.length === 1 && notPlayer) {441 var move = notFound[0];442 moves.push(move);443 }444 });445 return moves;446},447 doubleThreatChoice: function(choiceType) {448 // use winChoice function to test a spot for double threat449 var board = MYAPP.currentBoard;450 var move;451 if (choiceType === 'win') {452 var currentSymbol = MYAPP.playerTwoSymbol;453 var opponentSymbol = MYAPP.playerOneSymbol;454 } else if (choiceType === 'block') {455 var currentSymbol = MYAPP.playerOneSymbol;456 var opponentSymbol = MYAPP.playerTwoSymbol;457 }458 // forced diagonal win on 4th move prevention459 if (board[5] === currentSymbol && MYAPP.numFilledIn === 3) {460 if ((board[1] === opponentSymbol && board[9] === opponentSymbol) || (board[3] === opponentSymbol && board[7] === opponentSymbol)) {461 // Play an edge to block double threat462 move = this.emptySide();463 }464 }465 466 if (!move && board[5] === opponentSymbol && MYAPP.numFilledIn === 2) {467 move = this.diagonalSecondAttack();468 }469 if (!move) {470 // clone current board;471 var testBoard = $.extend({}, board);472 for (var i = 1; i <= 9; i++) {473 testBoard = $.extend({}, board);474 if (testBoard[i] === '') {475 testBoard[i] = currentSymbol;476 if (this.winOrBlockChoice(choiceType, testBoard).length >= 2) {477 move = i;478 }479 }480 }481 }482 return move || false;483},484 diagonalSecondAttack: function() {485 var board = MYAPP.currentBoard;486 var comp = MYAPP.playerTwoSymbol;487 var corners = [1,3,7,9];488 for (var i = 0; i < corners.length; i++) {489 if (board[corners[i]] === comp) {490 return 10 - corners[i];491 }492 }493},494 firstPlay: function() {495 var board = MYAPP.currentBoard;496 var corners = [1, 3, 7, 9];497 var move;498 if (MYAPP.numFilledIn === 1) {499 // player plays center500 if (board[5] === MYAPP.playerOneSymbol) {501 var cornerNum = Math.floor(Math.random() * 4 + 1);502 move = [1, 3, 7, 9][cornerNum];503 }504 //player plays corner, play opposite corner505 else {506 for (var i = 0; i < corners.length; i++) {507 if (MYAPP.currentBoard[corners[i]] === MYAPP.playerOneSymbol) {508 move = 5;509 }510 }511 }512 } else if (MYAPP.numFilledIn === 0) {513 var cornerNum = Math.floor(Math.random() * corners.length + 1);514 move = corners[cornerNum];515 }516 return move ? move : false;517},518 519 playCenter: function() {520 if (MYAPP.currentBoard[5] === '') {521 return 5;522 }523 },524 emptyCorner: function() {525 var board = MYAPP.currentBoard;526 var corners = [1, 3, 7, 9];527 var move;528 for (var i = 0; i < corners.length; i++) {529 if (board[corners[i]] === '') {530 move = corners[i];531 }532 }533 return move || false;534},535 emptySide: function() {536 var sides = [2, 4, 6, 8];537 for (var i = 0; i < sides.length; i++) {538 if (MYAPP.currentBoard[sides[i]] === '') {539 return sides[i];540 }541 }542 return false;543}544}545/* End Computer Move Decisions */ 546$(document).ready(function() { 547 MYAPP.initializeGame();548});...
app.colors.js
Source:app.colors.js
1var color = {2 primary: {3 _50: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-50").css("color")) || "#ccbfdf",4 _100: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-100").css("color")) || "#beaed7",5 _200: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-200").css("color")) || "#b19dce",6 _300: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-300").css("color")) || "#a38cc6",7 _400: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-400").css("color")) || "#967bbd",8 _500: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-500").css("color")) || "#886ab5",9 _600: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-600").css("color")) || "#7a59ad",10 _700: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-700").css("color")) || "#6e4e9e",11 _800: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-800").css("color")) || "#62468d",12 _900: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-primary-900").css("color")) || "#563d7c"13 },14 success: {15 _50: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-50").css("color")) || "#7aece0",16 _100: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-100").css("color")) || "#63e9db",17 _200: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-200").css("color")) || "#4de5d5",18 _300: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-300").css("color")) || "#37e2d0",19 _400: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-400").css("color")) || "#21dfcb",20 _500: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-500").css("color")) || "#1dc9b7",21 _600: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-600").css("color")) || "#1ab3a3",22 _700: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-700").css("color")) || "#179c8e",23 _800: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-800").css("color")) || "#13867a",24 _900: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-success-900").css("color")) || "#107066"25 },26 info: {27 _50: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-50").css("color")) || "#9acffa",28 _100: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-100").css("color")) || "#82c4f8",29 _200: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-200").css("color")) || "#6ab8f7",30 _300: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-300").css("color")) || "#51adf6",31 _400: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-400").css("color")) || "#39a1f4",32 _500: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-500").css("color")) || "#2196F3",33 _600: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-600").css("color")) || "#0d8aee",34 _700: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-700").css("color")) || "#0c7cd5",35 _800: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-800").css("color")) || "#0a6ebd",36 _900: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-info-900").css("color")) || "#0960a5"37 },38 warning: {39 _50: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-50").css("color")) || "#ffebc1",40 _100: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-100").css("color")) || "#ffe3a7",41 _200: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-200").css("color")) || "#ffdb8e",42 _300: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-300").css("color")) || "#ffd274",43 _400: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-400").css("color")) || "#ffca5b",44 _500: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-500").css("color")) || "#ffc241",45 _600: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-600").css("color")) || "#ffba28",46 _700: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-700").css("color")) || "#ffb20e",47 _800: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-800").css("color")) || "#f4a500",48 _900: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-warning-900").css("color")) || "#da9400"49 },50 danger: {51 _50: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-50").css("color")) || "#feb7d9",52 _100: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-100").css("color")) || "#fe9ecb",53 _200: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-200").css("color")) || "#fe85be",54 _300: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-300").css("color")) || "#fe6bb0",55 _400: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-400").css("color")) || "#fd52a3",56 _500: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-500").css("color")) || "#fd3995",57 _600: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-600").css("color")) || "#fd2087",58 _700: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-700").css("color")) || "#fc077a",59 _800: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-800").css("color")) || "#e7026e",60 _900: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-danger-900").css("color")) || "#ce0262"61 },62 fusion: {63 _50: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-50").css("color")) || "#909090",64 _100: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-100").css("color")) || "#838383",65 _200: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-200").css("color")) || "#767676",66 _300: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-300").css("color")) || "#696969",67 _400: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-400").css("color")) || "#5d5d5d",68 _500: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-500").css("color")) || "#505050",69 _600: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-600").css("color")) || "#434343",70 _700: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-700").css("color")) || "#363636",71 _800: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-800").css("color")) || "#2a2a2a",72 _900: rgb2hex(myapp_config.mythemeColorProfileID.find(".color-fusion-900").css("color")) || "#1d1d1d"73 }...
data_source.js
Source:data_source.js
1// ==========================================================================2// Project: SC.DataSource Unit Test3// Copyright: ©2011 Junction Networks and contributors.4// License: Licensed under MIT license (see license.js)5// ==========================================================================6/*globals JN module test ok equals same stop start */7var MyApp, wasCalled, resetWasCalled;8module("SC.DataSource", {9 setup: function () {10 MyApp = window.MyApp = {};11 MyApp.store = SC.Store.create();12 MyApp.Foo = SC.Record.extend();13 MyApp.DataSource = SC.DataSource.extend({14 fetch: function (store, query) {15 wasCalled = true;16 equals(arguments.length, 2);17 return YES;18 },19 createRecord: function (store, storeKey, params) {20 wasCalled = true;21 equals(arguments.length, 3);22 return YES;23 },24 updateRecord: function (store, storeKey, params) {25 wasCalled = true;26 equals(arguments.length, 3);27 return YES;28 },29 retrieveRecord: function (store, storeKey, params) {30 wasCalled = true;31 equals(arguments.length, 3);32 return YES;33 },34 destroyRecord: function (store, storeKey, params) {35 wasCalled = true;36 equals(arguments.length, 3);37 return YES;38 },39 reset: function() {40 resetWasCalled = true;41 return this;42 }43 });44 SC.RunLoop.begin();45 },46 teardown: function () {47 SC.RunLoop.end();48 }49});50test("The dataSource will forward calls to the appropriate methods", function () {51 var ds = MyApp.DataSource.create();52 MyApp.store.set('dataSource', ds);53 ok(MyApp.store.find(SC.Query.remote(MyApp.Foo)),54 "the fetch should return a record array");55 ok(wasCalled, "`fetch` should have been called");56 wasCalled = NO;57 ok(MyApp.store.find(MyApp.Foo, "testing retrieve"),58 "retrieve should return a new record (because the dataSource handled the request YES)");59 ok(wasCalled, "`retrieve` should have been called");60 wasCalled = NO;61 var rec = MyApp.store.createRecord(MyApp.Foo, {});62 equals(MyApp.store.commitRecord(MyApp.Foo, 'foo', rec.get('storeKey')), YES,63 "commiting a new record should return YES");64 ok(wasCalled, "`createRecord` should have been called");65 wasCalled = NO;66 MyApp.store.writeStatus(rec.get('storeKey'), SC.Record.READY_CLEAN);67 rec.set('zero', 0);68 equals(MyApp.store.commitRecord(MyApp.Foo, 'foo', rec.get('storeKey')), YES,69 "updating a record should return YES");70 ok(wasCalled, "`updateRecord` should have been called");71 wasCalled = NO;72 MyApp.store.writeStatus(rec.get('storeKey'), SC.Record.READY_CLEAN);73 rec.destroy();74 // broken in SC.Store75 equals(MyApp.store.commitRecord(MyApp.Foo, 'foo', rec.get('storeKey')), YES,76 "destroying the record should return YES");77 ok(wasCalled, "`destroyRecord` should have been called");78});79test("The dataSource will return YES when all records committed return YES", function () {80 var ds = MyApp.DataSource.create({81 createRecord: function () { return YES; },82 updateRecord: function () { return YES; },83 destroyRecord: function () { return YES; }84 });85 MyApp.store.set('dataSource', ds);86 var rec1 = MyApp.store.createRecord(MyApp.Foo, {}),87 rec2, rec3;88 equals(MyApp.store.commitRecords(), YES,89 "commiting a single new record should return YES");90 MyApp.store.writeStatus(rec1.get('storeKey'), SC.Record.READY_CLEAN);91 rec1.set('zero', 0);92 rec2 = MyApp.store.createRecord(MyApp.Foo, {});93 equals(MyApp.store.commitRecords(), YES,94 "commiting records for an 'update' and 'create' should return YES");95 MyApp.store.writeStatus(rec1.get('storeKey'), SC.Record.READY_CLEAN);96 MyApp.store.writeStatus(rec2.get('storeKey'), SC.Record.READY_CLEAN);97 rec1.destroy();98 rec2.set('one', 1);99 rec3 = MyApp.store.createRecord(MyApp.Foo, {});100 equals(MyApp.store.commitRecords(), YES,101 "commiting records for an 'update', 'create', and 'destroy' should return YES");102});103test("The dataSource will return SC.MIXED_STATE when all records committed return YES and NO", function () {104 var ds = MyApp.DataSource.create({105 createRecord: function () { return NO; },106 updateRecord: function () { return YES; },107 destroyRecord: function () { return NO; }108 });109 MyApp.store.set('dataSource', ds);110 var rec1 = MyApp.store.createRecord(MyApp.Foo, {}),111 rec2, rec3;112 equals(MyApp.store.commitRecords(), NO,113 "commiting a single new record should return NO");114 MyApp.store.writeStatus(rec1.get('storeKey'), SC.Record.READY_CLEAN);115 rec1.set('zero', 0);116 rec2 = MyApp.store.createRecord(MyApp.Foo, {});117 equals(MyApp.store.commitRecords(), SC.MIXED_STATE,118 "commiting records for an 'update' and 'create' should return %@".fmt(SC.MIXED_STATE));119 MyApp.store.writeStatus(rec1.get('storeKey'), SC.Record.READY_CLEAN);120 MyApp.store.writeStatus(rec2.get('storeKey'), SC.Record.READY_CLEAN);121 rec1.destroy();122 rec2.set('one', 1);123 rec3 = MyApp.store.createRecord(MyApp.Foo, {});124 equals(MyApp.store.commitRecords(), SC.MIXED_STATE,125 "commiting records for an 'update', 'create', and 'destroy' should return %@".fmt(SC.MIXED_STATE));126});127test("The dataSource will return NO when all records committed return NO", function () {128 var ds = MyApp.DataSource.create({129 createRecord: function () { return NO; },130 updateRecord: function () { return NO; },131 destroyRecord: function () { return NO; }132 });133 MyApp.store.set('dataSource', ds);134 var rec1 = MyApp.store.createRecord(MyApp.Foo, {}),135 rec2, rec3;136 equals(MyApp.store.commitRecords(), NO,137 "commiting a single new record should return NO");138 MyApp.store.writeStatus(rec1.get('storeKey'), SC.Record.READY_CLEAN);139 rec1.set('zero', 0);140 rec2 = MyApp.store.createRecord(MyApp.Foo, {});141 equals(MyApp.store.commitRecords(), NO,142 "commiting records for an 'update' and 'create' should return NO");143 MyApp.store.writeStatus(rec1.get('storeKey'), SC.Record.READY_CLEAN);144 MyApp.store.writeStatus(rec2.get('storeKey'), SC.Record.READY_CLEAN);145 rec1.destroy();146 rec2.set('one', 1);147 rec3 = MyApp.store.createRecord(MyApp.Foo, {});148 equals(MyApp.store.commitRecords(), NO,149 "commiting records for an 'update', 'create', and 'destroy' should return NO");150});151test("The store calls reset on the dataSource when reset", function(){152 MyApp.store.set('dataSource', MyApp.DataSource.create());153 resetWasCalled = NO; // Just to be sure154 MyApp.store.reset();155 ok(resetWasCalled, "should have called reset");...
standard_setup.js
Source:standard_setup.js
1// ==========================================================================2// Project: SproutCore - JavaScript Application Framework3// Copyright: ©2006-2011 Apple Inc. and contributors.4// License: Licensed under MIT license (see license.js)5// ==========================================================================6/*globals module ok equals same test json0_9 json10_19 json20_29 json30_39 json40_49 */7var MyApp;8/* Define a standard test setup for use in most integration and unit tests. */9var StandardTestSetup = {10 setup: function() {11 // define namespace12 MyApp = SC.Object.create({13 store: SC.Store.create()14 });15 // define basic record16 MyApp.Author = SC.Record.extend({17 isCylon: function() {18 switch(this.get('fullName')) {19 case "Saul Tigh":20 case "Galen Tyrol":21 return YES;22 default: 23 return NO;24 }25 }.property('fullName').cacheable()26 });27 // define fixture server.28 // MyApp.fixtureServer = SC.FixtureServer.create({29 // simulateResponseFromServer: function(guid, storeKey) {30 // var json = [];31 // if(guid === '123') {32 // json = [ {"type": "Author", "guid": "123","fullName": "Galen Tyrol", "bookTitle": "The Fear of the Spiders", "address":" London University, 142 Castro St, London, UK"}];33 // }34 // if(guid === 'john locke') {35 // this.get('childStore').didCreateRecords([storeKey], ['abcdefg'], [{guid: 'abcdefg', fullName: "John Locke", bookTitle: "A Letter Concerning Toleration"}]);36 // 37 // return;38 // }39 // if(guid === 'jim locke') {40 // console.log('LOADING JIM LOCKE %@'.fmt(storeKey));41 // this.get('childStore').didCreateRecords([storeKey], ['abc'], [{guid: 'abc', fullName: "Jim Locke", bookTitle: "A Letter Concerning Toleration Part Deux"}]);42 // 43 // return;44 // }45 // 46 // this.get('childStore').loadRecords(json, MyApp.Author);47 // 48 // }49 // });50 // 51 // MyApp.fixtureServer.addStore(MyApp.store); 52 53 54 // verify initial state55 // ok(MyApp, "MyApp is defined") ;56 // ok(MyApp.store, "MyApp.store is defined") ;57 // ok(MyApp.fixtureServer, "MyApp.fixtureServer is defined") ;58 // ok(MyApp.Author, "MyApp.Author is defined") ;59 // ok(json0_9, "json0_9 is defined") ;60 // ok(json10_19, "json10_19 is defined") ;61 // ok(json20_29, "json20_29 is defined") ;62 // ok(json30_39, "json30_39 is defined") ;63 // ok(json40_49, "json40_49 is defined") ;64 65 return this ;66 },67 68 loadRecords: function() {69 70 // load in some records -- dup json first so that edits to the data will71 // not impact other tests72 function dup(array) {73 var ret = [], len = array.length, idx;74 for(idx=0;idx<len;idx++) ret[idx] = SC.clone(array[idx]);75 return ret ;76 }77 78 MyApp.store.loadRecords(dup(json0_9), MyApp.Author);79 MyApp.store.loadRecords(dup(json10_19), MyApp.Author, 'guid');80 81 var recordTypes = [MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author];82 MyApp.store.loadRecords(dup(json20_29), recordTypes);83 recordTypes = [MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author, MyApp.Author];84 MyApp.store.loadRecords(dup(json30_39), recordTypes, 'guid');85 MyApp.store.loadRecords(dup(json40_49));86 return this ;87 }88};...
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.MyApp();4 })5})6Cypress.Commands.add('MyApp', () => {7 cy.visit('www.myapp.com')8})9{10}
Using AI Code Generation
1import {MyApp} from 'cypress-myapp';2Cypress.Commands.add('myapp', MyApp);3import {MyOtherApp} from 'cypress-myapp';4Cypress.Commands.add('myotherapp', MyOtherApp);5describe('MyApp', () => {6 it('should work', () => {7 cy.myapp();8 });9});10describe('MyOtherApp', () => {11 it('should work', () => {12 cy.myotherapp();13 });14});15In this article, we have learned how to run Cypress in the CI. We have also learned how to resolve the module not found error when we try to import a custom command in the Cypress. We
Using AI Code Generation
1import './commands'2Cypress.Commands.add('MyApp', () => {3})4describe('My first test', () => {5 it('Visits the app root url', () => {6 cy.MyApp()7 })8})9Cypress.Commands.add('MyApp', () => {10})11describe('My first test', () => {12 it('Visits the app root url', () => {13 cy.MyApp()14 })15})16Cypress.Commands.add('MyApp', () => {17})18describe('My first test', () => {19 it('Visits the app root url', () => {20 cy.MyApp()21 })22})23Cypress.Commands.add('MyApp', () => {24})25describe('My first test', () => {26 it('Visits the app root url', () => {27 cy.MyApp()28 })29})30Cypress.Commands.add('MyApp', () => {31})32describe('My first test', () => {33 it('Visits the app root url', () => {
Using AI Code Generation
1import {MyApp} from './MyApp.js';2Cypress.Commands.add('MyApp', MyApp);3describe('My Test', function() {4 it('My Test', function() {5 cy.MyApp();6 });7});8export function MyApp() {9 console.log('Hello World');10}11import {MyApp} from './MyApp.js';12Cypress.Commands.add('MyApp', MyApp);13export function MyApp() {14 console.log('Hello World');15}16import {MyApp} from './MyApp.js';17Cypress.Commands.add('MyApp', MyApp);18export function MyApp() {19 console.log('Hello World');20}21import {MyApp} from '../MyApp.js';22Cypress.Commands.add('MyApp', MyApp);
Using AI Code Generation
1import {MyApp} from 'cypress/support/MyApp.js'2MyApp.loginAs('admin')3import {MyApp} from 'cypress/support/MyApp.js'4MyApp.loginAs('admin')5import {MyApp} from 'cypress/support/MyApp.js'6MyApp.loginAs('admin')7import {MyApp} from 'cypress/support/MyApp.js'8MyApp.loginAs('admin')9import {MyApp} from 'cypress/support/MyApp.js'10MyApp.loginAs('admin')
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!