Changeset 105

Show
Ignore:
Timestamp:
08/09/07 16:10:22 (17 months ago)
Author:
chris
Message:

* Fixed javascript timer bug reported by Drarok
* Fixed error caused by trying to update finished items when there were none

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/CHANGELOG

    r104 r105  
     11.8 
     2 
     3* Fixed a couple of Javascript bugs, one would cause a drag and drop sort 
     4  to say an error had occured despite it having completed successfully if 
     5  there were no finished items and finished items were set to display. 
     6  The second javascript bug involved the 15 second refresh, instead of 
     7  re-creating the existing timer, it was creating a new one for each 
     8  refresh, meaning after a while it was refreshing every second or so. 
     9 
    1101.7 
    211 
  • trunk/js/hellaworld.js

    r98 r105  
    1313 
    1414        function startRefresher() { 
    15                 refresh = true; 
    16                 setTimeout('refresher()', 15000); 
     15                if (refresh) { 
     16                        clearTimeout(refresh); 
     17                } 
     18                refresh = setTimeout('refresher()', 15000); 
    1719        } 
    1820 
    1921        function stopRefresher() { 
    20                 refresh = false; 
     22                if (refresh) { 
     23                        clearTimeout(refresh); 
     24                        refresh = false; 
     25                } 
    2126        } 
    2227 
     
    3540                                                updateData(json); 
    3641                                        }, 
    37                                         error : function() { 
     42                                        error : function(foo, bar, wee) { 
    3843                                                alert('Apologies, there was an error while making the request'); 
    3944                                        } 
     
    9398                        makeSortable(); 
    9499                } 
    95                 if (json.finished) { 
     100                if (json.finished && json.finished.length > 0) { 
    96101                        var finished = ''; 
    97102                        for (i = 0; i < json.finished.length; i++) { 
     
    118123                if (refresh) { 
    119124                        $.getJSON('index.php?refresher=1', function(json) { updateData(json); });  
    120                         setTimeout('refresher()', 15000); 
     125                        clearTimeout(refresh); 
     126                        refresh = setTimeout('refresher()', 15000); 
    121127                } 
    122128        }