Changeset 7652:45f4b870f75e


Ignore:
Timestamp:
11/08/07 18:49:11 (6 years ago)
Author:
Yi Qiang <yqiang@…>
Branch:
default
Message:

Added ajax history!

Location:
sage/dsage/web
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • sage/dsage/web/index.html

    r7651 r7652  
    1111        <script src='static/jquery-latest.js' type='text/javascript'></script> 
    1212        <script src='static/jquery.tablesorter.pack.js' type='text/javascript'></script> 
     13        <script src='static/jquery.history.js' type='text/javascript'></script> 
     14         
    1315        <script src='static/dsage_web.js' type='text/javascript'></script> 
    1416</head> 
  • sage/dsage/web/static/dsage_web.js

    r7649 r7652  
    1010    $('#job_details').hide(); 
    1111    $('#help').hide(); 
     12    $('#navigator').hide(); 
    1213    $('#server_details').show(); 
    13     $('#navigator').hide(); 
    1414} 
    1515function getJobs (c) { 
     
    3030    $('#help').hide(); 
    3131    $('#jobs_table').show(); 
     32    $('#navigator').show(); 
    3233} 
    3334 
     
    5960} 
    6061 
     62// PageLoad function 
     63// This function is called when: 
     64// 1. after calling $.historyInit(); 
     65// 2. after calling $.historyLoad(); 
     66// 3. after pushing "Go Back" button of a browser 
     67function pageload(hash) { 
     68        // hash doesn't contain the first # character. 
     69        if(hash) { 
     70                // restore ajax loaded state 
     71        if (hash=='jobs') { 
     72            showJobs() 
     73        } 
     74        else if (hash=='server') { 
     75            getServerDetails() 
     76        } 
     77        else if (hash=='help') { 
     78            getHelp() 
     79        } 
     80        }  
     81        else { 
     82                // start page 
     83                showJobs() 
     84        } 
     85} 
     86 
     87function gethash (that) { 
     88    var hash = that.href; 
     89        hash = hash.replace(/^.*#/, ''); 
     90        // moves to a new page.  
     91        // pageload is called at once.  
     92    $.historyLoad(hash); 
     93        return false; 
     94} 
     95 
    6196$(document).ready(function()  
    6297    {  
     98        // Initialize history plugin. 
     99                // The callback is called at once by present location.hash.  
     100                $.historyInit(pageload); 
     101                console.log('historyInit') 
     102                // set onlick event for buttons 
     103                $("a[@rel='history']").click(function() {gethash(this); }); 
     104                console.log('setonclick') 
    63105        getJobs(count) // Run it the first time 
    64         showJobs() // Show jobs 
     106        // showJobs() // Show jobs 
    65107        // setInterval('getJobs(count)', 5000); // Update it every 5 seconds.   
    66108    }  
Note: See TracChangeset for help on using the changeset viewer.