Some performance fixes (lol)

This commit is contained in:
Norbi Peti 2018-12-09 23:44:57 +01:00
parent 684fa5dbc1
commit 94a7ea581c
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56

View file

@ -37,6 +37,10 @@
var data=[]; var data=[];
var good=-1; var good=-1;
var loaded=false; //For some reason previously loaded videos are kept so loading takes some time
function doLoad() {
if(loaded) return;
loaded=true;
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function(progressEvent){ reader.onload = function(progressEvent){
// By lines // By lines
@ -49,6 +53,9 @@
getPhrase(); getPhrase();
}; };
getFile(reader); getFile(reader);
}
window.onload = ()=>doLoad();
doLoad(); //So let's try loading ASAP, and if that fails then wait for the load event
function checkResp() { function checkResp() {
var val=document.getElementById("response").value; var val=document.getElementById("response").value;
@ -114,7 +121,7 @@
<p>So you know those "info sections" in most of Tiffany's videos? Here you can see a word, phrase or sometimes a <p>So you know those "info sections" in most of Tiffany's videos? Here you can see a word, phrase or sometimes a
sentence to comment on one of the videos. Can you guess which video it belongs to?</p> sentence to comment on one of the videos. Can you guess which video it belongs to?</p>
<h4>Score: <span id="score">20</span></h4> <h4>Score: <span id="score">20</span></h4>
<h3 id="phrase">Please enable JavaScript :P</h3> <h3 id="phrase">Please enable JavaScript or wait :P</h3>
<select id="response" style="max-width: 500px"> <select id="response" style="max-width: 500px">
<option value="-1" default>-- Choose a video --</option> <option value="-1" default>-- Choose a video --</option>
</select> </select>
@ -125,13 +132,13 @@
<h3 id="resultH"></h3> <h3 id="resultH"></h3>
<p id="resultP"></p> <p id="resultP"></p>
<p>Your response:</p> <p>Your response:</p>
<iframe id="respyt" width="496" height="279" src="https://www.youtube.com/embed/" frameborder="0" <iframe id="respyt" width="496" height="279" src="about:blank" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe> allowfullscreen></iframe>
</div> </div>
<div id="goodBlock" style="display: none"> <div id="goodBlock" style="display: none">
<p>Correct video:</p> <p>Correct video:</p>
<iframe id="goodyt" width="496" height="279" src="https://www.youtube.com/embed/" frameborder="0" <iframe id="goodyt" width="496" height="279" src="about:blank" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe> allowfullscreen></iframe>
</div> </div>