Changeset 16835 in project for release/3


Ignore:
Timestamp:
12/21/09 01:54:59 (9 years ago)
Author:
azul
Message:

Lots of small fixes.

File:
1 edited

Legend:

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

    r16831 r16835  
    1010var svnwikiProgress = new Object();
    1111
    12 svnwikiProgress.init = function ( expectedRev, target, staticURL )
    13 {
     12svnwikiProgress.init = function ( reportURL, expectedRev, target, staticURL, logSize )
     13{
     14  svnwikiProgress.reportURL = reportURL;
    1415  svnwikiProgress.loading = true;
    1516  svnwikiProgress.delay = 1000;
     
    3435  }
    3536
    36   svnwikiProgress.statusBar = svnwikiJavascript.makeElement('p');
     37  svnwikiProgress.logSize = logSize;
     38  svnwikiProgress.statusBar = svnwikiJavascript.makeElement('ul');
     39  svnwikiProgress.statusBar.setAttribute('style', 'list-style-type: none');
     40  svnwikiProgress.lastState = '';
    3741  svnwikiProgress.progressWidget.appendChild(svnwikiProgress.statusBar);
    38   svnwikiProgress.advance("Checking status...");
    3942  svnwikiProgress.checkProgress();
    4043};
     
    5457  svnwikiProgress.position = (svnwikiProgress.position + 1) % colors.length;
    5558
    56   var current = chars.length;
    57 
    5859  for (var j = 0; j < 8; j ++) {
    59     colors[(svnwikiProgress.position + j) % colors.length] = current;
    60     current --;
     60    colors[(svnwikiProgress.position + j) % colors.length] = chars.length - 1 - j;
    6161  }
    6262
     
    7171svnwikiProgress.showWaitText = function ( text )
    7272{
    73   svnwikiJavascript.cleanContent(svnwikiProgress.statusBar).appendChild(document.createTextNode(svnwikiProgress.loading ? text : 'Done'));
     73  if (text != '' && svnwikiProgress.lastState == text) {
     74    svnwikiProgress.statusBar.childNodes[svnwikiProgress.statusBar.childNodes.length - 1].appendChild(document.createTextNode('.'));
     75    return;
     76  }
     77  if (svnwikiProgress.statusBar.childNodes.length == svnwikiProgress.logSize)
     78    svnwikiProgress.statusBar.removeChild(svnwikiProgress.statusBar.childNodes[0]);
     79  svnwikiProgress.lastState = text;
     80  svnwikiProgress.statusBar.appendChild(svnwikiJavascript.makeElement('li', document.createTextNode(svnwikiProgress.loading ? text : 'Done')));
    7481};
    7582
     
    118125    svnwikiProgress.actualTime = actualTime;
    119126    svnwikiProgress.delay = 1000;
    120   } else if (svnwikiProgress.delay < 120000) {
     127  } else if (svnwikiProgress.delay < 30000) {
    121128    svnwikiProgress.delay *= 1.5;
    122129  }
     
    127134svnwikiProgress.checkProgress = function ( )
    128135{
    129   svnwikiJavascript.loadXml('?action=extension&extension=progress&format=xml', svnwikiProgress.registerProgress);
     136  svnwikiJavascript.loadXml(svnwikiProgress.reportURL, svnwikiProgress.registerProgress);
    130137};
    131138EOJS
     
    133140
    134141(define (progress-code-write env)
    135   (let-from-environment env (path-out program)
     142  (let-from-environment env (path-out program static-url)
    136143    (when (and path-out (string=? program "post-commit"))
    137144      (assert (and 'progress-code-write (string? path-out)))
     
    141148        path-out
    142149        *progress-js-code*)
    143       (write-file-with-tmp
    144         (svnwiki-make-pathname (list "xsvnwiki-helper" "progress") "progress")
    145         "text/html"
    146         path-out
    147         (render-template
    148           env
    149           "State"
    150           (progress-html-code env -1 "")
    151           'view)))))
     150      (let ((path (svnwiki-make-pathname (list "xsvnwiki-helper" "progress") "progress")))
     151        (write-file-with-tmp
     152          path
     153          "text/html"
     154          path-out
     155          (render-template
     156            (environment env ((path path) (path-out-real path)))
     157            ""
     158            (progress-html-code
     159              env
     160              (svnwiki-make-pathname (list static-url "xsvnwiki-helper") "progress-report" "xml")
     161              -1
     162              ""
     163              20)
     164            'view))))))
    152165
    153166(define (show-progress-xml env)
     
    169182            (html
    170183              (body
    171                 (progress-html-code env -1 "")))))))))
     184                (progress-html-code env *report-url-cgi* -1 "" 20)))))))))
    172185
    173186; commit-rev must be the revision that has just been commited, or -1 if
    174187; unknown.  url must be the URL to redirect the user to once the server has
    175188; reached commit-rev or the empty string.
    176 (define (progress-html-code env commit-rev url)
     189(define (progress-html-code env report-url commit-rev url log-size)
    177190  (let-from-environment env (static-url)
    178191    (html-stream
     
    180193      ((script type "text/javascript" src (format #f "~A/xsvnwiki-helper/progress/progress" static-url)))
    181194      ((script type "text/javascript")
    182        (format #f "<!--~%if (typeof(svnwikiProgress) == 'object' && typeof(svnwikiProgress.init) == 'function') { svnwikiProgress.init(~A, 'progress-state', '~A'); }~%-->"
     195       (format #f "<!--~%if (typeof(svnwikiProgress) == 'object' && typeof(svnwikiProgress.init) == 'function') { svnwikiProgress.init('~A', ~A, 'progress-state', '~A', '~A'); }~%-->"
     196               report-url
    183197               commit-rev
    184                (or url ""))))))
     198               (or url "")
     199               log-size)))))
     200
     201(define *report-url-cgi* "?action=extension&extension=progress&format=xml")
    185202
    186203(define (progress-commit-confirmation env)
     
    188205    env
    189206    (let-from-environment env (static-url commit-rev path)
    190       (progress-html-code env commit-rev (svnwiki-make-pathname static-url path)))))
     207      (progress-html-code
     208        env
     209        *report-url-cgi*
     210        commit-rev
     211        (svnwiki-make-pathname static-url path)
     212        3))))
    191213
    192214(svnwiki-extension-define 'commit-handler 'progress progress-commit-confirmation)
Note: See TracChangeset for help on using the changeset viewer.