From 21c1043d8e7275c151a6bb5d742987a3844b5f2e Mon Sep 17 00:00:00 2001 From: Astha Upadhyay <01astha@gmail.com> Date: Fri, 2 Oct 2020 05:24:09 +0530 Subject: [PATCH] Replacing Jquery with Fetch in main.js(#114) --- public/scripts/main.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/public/scripts/main.js b/public/scripts/main.js index 59cfacf..53a5312 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -41,17 +41,18 @@ let questionStartMS = 0; $(document).ready(function() { //$("#retryButton").toggleClass("on"); //alert($('li[data-keycode="test"]').attr('id')); - $.getJSON( "scripts/shortcuts.json", function( data ) { - allData = data; - if(localStorage.getItem("questionNo")==null){ + fetch('scripts/shortcuts.json') + .then(response => response.json()) + .then(data => { + allData=data + if(localStorage.getItem("questionNo")==null) + { localStorage.setItem("questionNo", "1"); localStorage.setItem("totalCount", Object.keys(allData).length); } - // Call readText() - readText() - - updateTimingDisplay(); - }) + readText() + updateTimingDisplay() + }); $('.container').css('height', $(window).height()); $(window).on('resize', function() {