X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=root%2Fstatic%2Fjs%2Fsite.js;h=5af7d110154db7496a4b29063f217cdad8ef04b8;hb=8d2e9264ba847b07c5a5a8dc612e01fcb219cdef;hp=ba4a990371f4f5c823634ff762403ff0e92bcd0e;hpb=feb6e8816886de983c0f17a360d715fd5138ed99;p=catagits%2FGitalist.git diff --git a/root/static/js/site.js b/root/static/js/site.js index ba4a990..5af7d11 100755 --- a/root/static/js/site.js +++ b/root/static/js/site.js @@ -1,12 +1,12 @@ function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) { - do { - curleft += obj.offsetLeft; - curtop += obj.offsetTop; - } - while (obj = obj.offsetParent); - return [curleft,curtop]; + do { + curleft += obj.offsetLeft; + curtop += obj.offsetTop; + } + while (obj = obj.offsetParent); + return [curleft,curtop]; } } @@ -45,8 +45,9 @@ function uriFor(action, sha1) { } function switchBranch() { - var branch = jQuery('#branch-list').val(); - document.location.href = uriFor('current', branch); + var branch = jQuery('#branch-list').val(), + action = branch != '...' ? 'current' : 'heads'; + document.location.href = uriFor(action, encodeURIComponent(branch).replace('/', '%2F')); } function compareDiffs(){ @@ -54,21 +55,27 @@ function compareDiffs(){ baseSha1 = jQuery('#compare-form input[name=sha1_a]:checked').val(), compSha1 = jQuery('#compare-form input[name=sha1_b]:checked').val(), diffUri = uriFor('diff', baseSha1); - document.location.href = diffUri + '/' + compSha1 + (path ? '/' + escape(path) : ''); + document.location.href = diffUri + '/' + compSha1 + (path ? '/' + encodeURIComponent(path) : ''); return false; } -function loadCommitInfo() { - jQuery('#commit-tree .message').each(function() { - var cell = jQuery(this); - var filename = unescape( cell.find('.js-data').text() ); - jQuery.getJSON(uriFor('file_commit_info') + '/' + filename, {}, function(commitInfo) { - cell.empty(); - cell.html(''+commitInfo.comment+' '+commitInfo.age); - }); +function _loadCommitInfo(cells) { + var cell = jQuery(cells.shift()); + var filename = cell.find('.js-data').text(); + jQuery.getJSON(uriFor('file_commit_info') + '/' + filename, {}, function(commitInfo) { + cell.empty(); + cell.html(''+commitInfo.comment+' '+commitInfo.age); + if(cells.length > 0) + _loadCommitInfo(cells); }); } +function loadCommitInfo() { + var cells = jQuery('#commit-tree .message').get(); + if(cells.length > 0) + _loadCommitInfo( cells ); +} + jQuery(function() { // Provide sub-nav dropdowns (I think). startList();