1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
// jshint esversion: 5 
/* 
  This is a consolidation of the the two scripts dbs/ajax_optimizeall.js 
  and dbs/ajax_repairall.js 
 
  This script is referenced in dbs/db_optimizeall.html and dbs/db_repairall.html 
*/ 
 
(function(window, document, R) { 
  'use strict'; 
 
  var resTarget   = document.querySelector('#result'), 
    resTargetText = resTarget.querySelector('.text'), 
    href          = resTarget.dataset.dbHref, 
    typeStr       = resTarget.dataset.progressMsg; 
 
  if (!href) { 
    resTarget.innerHTML = 
      '<div class="notify error">No <code>data-db-href</code> attribute' + 
      ' found on the result target. Something is really wrong!</div>'; 
 
    return; 
  } 
 
  resTargetText.innerHTML = typeStr || 'Doing things...'; 
 
  R.wget(href, 
    function(res) { 
      resTarget.innerHTML = res; 
    }, 
    function(err) { 
      resTarget.innerHTML = 
        '<div class="notify error">' + err + '</div>'; 
    }); 
 
}(window, document, rxnlib));