html - Unexpected end of input JavaScript -


can please tell me wrong javascript in code? said "unexpected end of input", not see errors. statements seem ended @ point, , every syntax checker says no errors detected.

<!doctype html> <html>  <head>   <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>     <title>slide editor</title>     <style>       @font-face {         font-family: segoeuilight;         src: url(segoe_ui_light.ttf);       }        * {         font-family: segoeuilight;       }     </style>     <script src="slide/revealjs/lib/js/html5shiv.js"></script>     <script src="slide/revealjs/lib/js/head.min.js"></script>   </head>    <body onload="editslideshow()">     <div id="sl">       <span id="sls"></span>     </div>     <span id="slt"></span>     <div id="editor">     </div>     <script>       function geturlparameters(paramname) {         var surl = window.document.url.tostring();         if (surl.indexof("?") > 0) {           var arrparams = surl.split("?");           var arrurlparams = arrparams[1].split("&");           var arrparamnames = new array(arrurlparams.length);           var arrparamvalues = new array(arrurlparams.length);            var = 0;           (i = 0; < arrurlparams.length; i++) {             var sparam = arrurlparams[i].split("=");             arrparamnames[i] = sparam[0];             if (sparam[1] != "")               arrparamvalues[i] = unescape(sparam[1]);             else               arrparamvalues[i] = "no value";           }            (i = 0; < arrurlparams.length; i++) {             if (arrparamnames[i] == paramname) {               //alert("parameter:" + arrparamvalues[i]);               return arrparamvalues[i];             }           }           return "no parameters found";         }       }        var name = geturlparameters("show");       var slidecount = 1;        function editslideshow() {         if (localstorage.getitem("app_slide_doc_" + name) == null) {           $("#sls").append('<button onclick = "loadslide\'1\')" id = "slide_1">slide 1</button>');           $("#sl").append('button onclick = "newslide()">new slide</button>');           slidecount = 1;         } else {           var textarray = json.parse(localstorage.getitem("app_slide_doc_" + name));           slidecount = textarray.length;           var slidecnt = textarray.length - 1;           (var = 0; <= slidecnt; i++) {             $("#sls").append('<button onclick = "loadslide\'' + (i + 1) + '\')" id = "slide_' + (i + 1) + '">slide ' + (i + 1) + '</button>');           };           $("sl").append('<button onclick = "newslide()">new slide</button>');         };       };        function loadslide(num) {         var array = json.parse(localstorage.getitem("app_slide_doc_" + name));         if (array == null) {           document.getelementbyid("editor").innerhtml = "<p><textarea rows = '15' cols = '100' id = 'edittxt'></textarea></p>";           document.getelementbyid("slt").innerhtml = "slide " + num;           $("#editor").append("<p><button onclick = 'saveslide(\"" + num + "\")'>save slide</button><button onclick = 'deleteslide(\"" + num + "\")'>delete slide</button></p>");         } else if (array[num - 1] == null) {           document.getelementbyid("editor").innerhtml = "<p><textarea rows = '15' cols = '100' id = 'edittxt'></textarea></p>";           document.getelementbyid("slt").innerhtml = "slide " + num;           $("#editor").append("<p><button onclick = 'saveslide(\"" + num + "\")'>save slide</button><button onclick = 'deleteslide(\"" + num + "\")'>delete slide</button></p>");         } else {           var slidearray = json.parse(localstorage.getitem("app_slide_doc_" + name));           var text = slidearray[num - 1];           document.getelementbyid("editor").innerhtml = "<p><textarea rows = '15' cols = '100' id = 'edittxt'></textarea></p>";           document.getelementbyid("edittxt").value = text;           document.getelementbyid("slt").innerhtml = "slide " + num;           $("#editor").append("<p><button onclick = 'saveslide(\"" + num + "\")'>save slide</button><button onclick = 'deleteslide(\"" + num + "\")'>delete slide</button></p>");         };       };        function saveslide(num) {         if (localstorage.getitem("app_slide_doc_" + name) == null) {           var text = document.getelementbyid("edittxt").value;           var textarray = new array();           textarray[num - 1] = text;           localstorage.setitem("app_slide_doc_" + name, json.stringify(textarray));         } else {           var textarray = json.parse(localstorage.getitem("app_slide_doc_" + name));           var text = document.getelementbyid("edittxt").value;           textarray[num - 1] = text;           localstorage.setitem("app_slide_doc_" + name, json.stringify(textarray));         };       };        function newslide() {         var nextslide = slidecount + 1;         $("#sls").append('<button onclick = "loadslide(\'' + nextslide + '\')" id = "slide_' + nextslide.tostring() + '">slide ' + nextslide.tostring() + '</button>');         slidecount = nextslide;       };        function deleteslide(num) {         if (localstorage.getitem("app_slide_doc_" + name) == null) {           if (num !== "1") {             $("#slide_" + num).remove();             document.getelementbyid("editor").innerhtml = "";             document.getelementbyid("slt").innerhtml = "";             slidecount = slidecount - 1;             location.reload();           } else {             alert("the first slide cannot deleted.");           };         } else {           var textarray = json.parse(localstorage.getitem("app_slide_doc_" + name));           if (num !== "1") {             $("#slide_" + num).remove();             document.getelementbyid("editor").innerhtml = "";             document.getelementbyid("slt").innerhtml = "";             slidecount = slidecount - 1;             textarray.splice((num - 1), 1);             localstorage.setitem("app_slide_doc_" + name, json.stringify(textarray));             location.reload();           } else {             alert("the first slide cannot deleted.");           };         };       };     </script>   </body> </html> 

you've gotten punctuation wrong in more 1 of onclick attributes, instance here:

$("#sls").append('<button onclick = "loadslide\'1\')" id = "slide_1">slide 1</button>'); 

it's missing opening parenthesis. reason syntax checks don't catch because you're putting code inside string. should not do.

since you're using jquery, how using .click(function() { ... }) instead of inline attributes? careful captured variables correct.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -