Subversion Repositories logviewer

Rev

Rev 2 | View as "text/javascript" | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*
  2.  * ViaThinkSoft LogViewer
  3.  * Copyright 2018-2019 Daniel Marschall, ViaThinkSoft
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17.  
  18. function _solve(id) {
  19.         var xhr = new XMLHttpRequest();
  20.         xhr.onreadystatechange = function () {
  21.                 if (xhr.readyState === 4 /* DONE */) {
  22.                         if (xhr.status !== 200 /* OK */) {
  23.                                 alert('Generic network failure. Please try again.');
  24.                                 return;
  25.                         }
  26.                         try {
  27.                                 obj = JSON.parse(xhr.responseText);
  28.                         } catch (e) {
  29.                                 alert('Server side error!');
  30.                                 return;
  31.                         }
  32.                         if (!obj.success) {
  33.                                 alert(/* 'JSON server error: ' + */ obj.error);
  34.                                 return;
  35.                         }
  36.                         if (document.getElementById('line'+obj.id).style.display != 'none') {
  37.                                 document.getElementById('line'+obj.id).style.display = 'none';
  38.                                 document.getElementById('count').innerHTML = document.getElementById('count').innerHTML - 1;
  39.                         }
  40.                 }
  41.         };
  42.         xhr.open('POST', 'ajax_cmd.php', true);
  43.         xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
  44.         xhr.send('cmd=solve&id='+id);
  45. }
  46.