Changeset 14920 in project


Ignore:
Timestamp:
06/06/09 19:03:19 (10 years ago)
Author:
azul
Message:

Reuse code from svnwikiJavascript extension.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/svnwiki-progress/trunk/svnwiki-progress.scm

    r12533 r14920  
    88(define *progress-js-code*
    99  #<<EOJS
    10 if (typeof(svnwikiProgress) != "object") {
    11 
    1210var svnwikiProgress = new Object();
    13 
    14 // We use this to avoid the GC from collecting objects from loadXml before
    15 // they have actually loaded their documents and processed them:
    16 
    17 svnwikiProgress.requests = new Array();
    18 
    19 svnwikiProgress.loadXml = function (href, process)
    20 {
    21   var xmlDoc;
    22   var len = svnwikiProgress.requests.length;
    23 
    24   if (document.implementation && document.implementation.createDocument)
    25     {
    26       xmlDoc = document.implementation.createDocument("", "", null);
    27       xmlDoc.onload = function () { svnwikiProgress.removeRequest(xmlDoc); process(xmlDoc) };
    28     }
    29   else if (window.ActiveXObject)
    30     {
    31       xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    32       xmlDoc.onreadystatechange = function () { if (xmlDoc.readyState == 4) { svnwikiProgress.removeRequest(xmlDoc); process(xmlDoc); } };
    33     }
    34   else
    35     {
    36       alert('Your browser can\'t handle this script');
    37       return;
    38     }
    39 
    40   svnwikiProgress.requests.push(xmlDoc);
    41   xmlDoc.load(href);
    42 }
    43 
    44 svnwikiProgress.removeRequest = function (element)
    45 {
    46   var rd, wr;
    47   for (rd = 0, wr = 0; rd < svnwikiProgress.requests.length; rd ++)
    48     if (svnwikiProgress.requests[rd] != element)
    49       svnwikiProgress.requests[wr ++] = svnwikiProgress.requests[rd];
    50   while (wr < svnwikiProgress.requests.len)
    51     svnwikiProgress.requests.pop();
    52 }
    53 
    54 svnwikiProgress.cleanContent = function (element)
    55 {
    56   while (element.hasChildNodes())
    57     element.removeChild(element.firstChild);
    58 }
    59 
    60 svnwikiProgress.makeLink = function ( target, content )
    61 {
    62   var link = svnwikiProgress.makeElement('A', content);
    63   link.setAttribute('href', target);
    64   return link;
    65 }
    66 
    67 svnwikiProgress.makeElement = function ( type, content )
    68 {
    69   var elem = document.createElement(type);
    70   if (content)
    71     elem.appendChild(content);
    72   return elem;
    73 }
    7411
    7512svnwikiProgress.init = function ( expectedRev, target, staticURL )
     
    8724  for (var j = 0; j <= 8; ++j) {
    8825    if (j == 0 || j == 3 || j == 6) {
    89       var span = svnwikiProgress.makeElement('span');
     26      var span = svnwikiJavascript.makeElement('span');
    9027      span.setAttribute('class', 'progress-break');
    9128      svnwikiProgress.progressWidget.appendChild(span);
    9229    }
    93     var span = svnwikiProgress.makeElement('span');
     30    var span = svnwikiJavascript.makeElement('span');
    9431    span.setAttribute('class', 'progress-entry');
    9532    span.setAttribute('id', 'progress-id-' + j);
     
    9734  }
    9835
    99   svnwikiProgress.statusBar = svnwikiProgress.makeElement('p');
     36  svnwikiProgress.statusBar = svnwikiJavascript.makeElement('p');
    10037  svnwikiProgress.progressWidget.appendChild(svnwikiProgress.statusBar);
    10138  svnwikiProgress.advance("Checking status...");
     
    13471svnwikiProgress.showWaitText = function ( text )
    13572{
    136   svnwikiProgress.cleanContent(svnwikiProgress.statusBar);
    137   svnwikiProgress.statusBar.appendChild(document.createTextNode(svnwikiProgress.loading ? text : 'Done'));
     73  svnwikiJavascript.cleanContent(svnwikiProgress.statusBar).appendChild(document.createTextNode(svnwikiProgress.loading ? text : 'Done'));
    13874}
    13975
    140 svnwikiProgress.redirectStart = function ( )
     76svnwikiProgress.redirectUpdate = function ( )
    14177{
    142   svnwikiProgress.cleanContent(svnwikiProgress.showTime);
     78  svnwikiJavascript.cleanContent(svnwikiProgress.showTime);
    14379  if (svnwikiProgress.redirectTime == 0) {
    14480    svnwikiProgress.showTime.appendChild(document.createTextNode('You are now being redirected to '));
    145     svnwikiProgress.showTime.appendChild(svnwikiProgress.makeLink(svnwikiProgress.staticURL, document.createTextNode('the resulting page')));
     81    svnwikiProgress.showTime.appendChild(svnwikiJavascript.makeLink(svnwikiProgress.staticURL, document.createTextNode('the resulting page')));
    14682    svnwikiProgress.showTime.appendChild(document.createTextNode('.'));
    14783    window.location = svnwikiProgress.staticURL;
     
    15086
    15187  svnwikiProgress.showTime.appendChild(document.createTextNode('You will be redirected to '));
    152   svnwikiProgress.showTime.appendChild(svnwikiProgress.makeLink(svnwikiProgress.staticURL, document.createTextNode('the resulting page')));
     88  svnwikiProgress.showTime.appendChild(svnwikiJavascript.makeLink(svnwikiProgress.staticURL, document.createTextNode('the resulting page')));
    15389  svnwikiProgress.showTime.appendChild(document.createTextNode(' in ' + svnwikiProgress.redirectTime + ' ' + (svnwikiProgress.redirectTime == 1 ? 'second' : 'seconds') + '.'));
    154   setTimeout("svnwikiProgress.redirectStart();", 1000);
     90  setTimeout("svnwikiProgress.redirectUpdate();", 1000);
    15591  svnwikiProgress.redirectTime --;
    15692}
     
    167103  if (!svnwikiProgress.loading) {
    168104    svnwikiProgress.redirectTime = 5;
    169     var report = document.getElementById('commit-results');
     105    var report = document.getElementById('edit-meta');
    170106    if (report) {
    171       svnwikiProgress.cleanContent(report);
    172       report.appendChild(svnwikiProgress.makeElement('p', svnwikiProgress.makeElement('b', document.createTextNode('Your changes have been saved.'))));
    173       svnwikiProgress.showTime = svnwikiProgress.makeElement('p');
     107      svnwikiJavascript.cleanContent(report);
     108      report.appendChild(svnwikiJavascript.makeElement('p', svnwikiJavascript.makeElement('b', document.createTextNode('Your changes have been saved.'))));
     109      svnwikiProgress.showTime = svnwikiJavascript.makeElement('p');
    174110      report.appendChild(svnwikiProgress.showTime);
    175       svnwikiProgress.redirectStart();
     111      svnwikiProgress.redirectUpdate();
    176112    }
    177113    return;
     
    191127svnwikiProgress.checkProgress = function ( )
    192128{
    193   svnwikiProgress.loadXml('?action=extension&extension=progress&format=xml', svnwikiProgress.registerProgress);
    194 }
    195 
     129  svnwikiJavascript.loadXml('?action=extension&extension=progress&format=xml', svnwikiProgress.registerProgress);
    196130}
    197131EOJS
Note: See TracChangeset for help on using the changeset viewer.