]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Added error dialog on JSON fail.
authorWill Budicm <redacted>
Sat, 26 Dec 2020 03:24:09 +0000 (14:24 +1100)
committerWill Budicm <redacted>
Sat, 26 Dec 2020 03:24:09 +0000 (14:24 +1100)
htdocs/cgi-bin/wsrc/main.js

index 8ca89fce448c3fb786042c6313893e776d2bb537..b717c9ec469c51147feaf58d346240954082604d 100644 (file)
@@ -702,17 +702,6 @@ function toggleDoc(whole) {
         setInterval(function() {
             if (CHANGE.length() > 0) {
                 console.log('Saving changes', CHANGE);
-                /*
-                Send partial changes
-                $.post('/your-endpoint', {
-                  partial: JSON.stringify(change)
-                });
-
-                Send entire document
-                $.post('/your-endpoint', {
-                  doc: JSON.stringify(QUILL.getContents())
-                });
-                */
                 CHANGE = new Delta();
             }
         }, 10 * 1000);
@@ -1026,7 +1015,8 @@ function saveRTF(id, action) {
     }
     RTF_SUBMIT = true;
     var bg = $("#fldBG").val();
-    $.post('json.cgi', {action:'store', id:id, bg:bg, doc: JSON.stringify(QUILL.getContents())}, saveRTFResult);
+    $.post('json.cgi', {action:'store', id:id, bg:bg, doc: JSON.stringify(QUILL.getContents())},saveRTFResult).fail(
+        function(response) {dialogModal("Server Error: "+response.status,response.responseText);});
     if(is_submit){
         //we must wait before submitting actual form!
         $("#idx_cat").value = "SAVING DOCUMENT...";
@@ -1036,16 +1026,7 @@ function saveRTF(id, action) {
     return false;
 }
 
-function delayedSubmit(){
-    if(RTF_SUBMIT){
-        setTimeout(delayedSubmit, 200);
-        return;
-    }
-    $("#frm_entry").submit();
-}
-
-function saveRTFResult(result) {
-    //alert("Result->" + result);
+function saveRTFResult(result) {    
     console.log("Result->" + result);
     var obj = JSON.parse(result);
     //alert(obj.response);
@@ -1060,6 +1041,15 @@ function saveRTFResult(result) {
     RTF_SUBMIT = false;
 }
 
+function delayedSubmit(){
+    if(RTF_SUBMIT){
+        setTimeout(delayedSubmit, 200);
+        return;
+    }
+    $("#frm_entry").submit();
+}
+
+
 function loadRTF(under, id){
 
     //show under log entry the document
@@ -1093,8 +1083,11 @@ function loadRTF(under, id){
     }
 
     //var json = "[{'insert': 'Loading Document...', 'attributes': { 'bold': true }}, {'insert': '\n'}]";
-    QUILL.setText('Loading Document...\n');
-    $.post('json.cgi', {action:'load', id:id}, loadRTFResult);
+    QUILL.setText('Loading Document...\n');    
+    $.post('json.cgi', {action:'load', id:id}, loadRTFResult).fail(
+           function(response) {dialogModal("Server Error: "+response.status,response.responseText);}
+    );
+
     $("#rtf_doc").show();
     $('#tbl_doc').show();
     $('#toolbar-container').show();
@@ -1251,7 +1244,7 @@ function setPageSessionTimer(expires) {
         modal: true,
         title: title,
         width: "40%",
-        show: { effect: "clip", duration: 800 },
+        show: { effect: "clip", duration: 400 },
         open: function() {
           $(this).html(message);
         },