mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-27 17:24:12 +00:00
--HG-- rename : sites/dev.scrapy.org/htdocs/asc.png => sites/static.scrapy.org/asc.png rename : sites/dev.scrapy.org/htdocs/attachment.png => sites/static.scrapy.org/attachment.png rename : sites/dev.scrapy.org/htdocs/changeset.png => sites/static.scrapy.org/changeset.png rename : sites/dev.scrapy.org/htdocs/closedticket.png => sites/static.scrapy.org/closedticket.png rename : sites/dev.scrapy.org/htdocs/collapsed.png => sites/static.scrapy.org/collapsed.png rename : sites/dev.scrapy.org/htdocs/css/about.css => sites/static.scrapy.org/css/about.css rename : sites/dev.scrapy.org/htdocs/css/admin.css => sites/static.scrapy.org/css/admin.css rename : sites/dev.scrapy.org/htdocs/css/browser.css => sites/static.scrapy.org/css/browser.css rename : sites/dev.scrapy.org/htdocs/css/changeset.css => sites/static.scrapy.org/css/changeset.css rename : sites/dev.scrapy.org/htdocs/css/code.css => sites/static.scrapy.org/css/code.css rename : sites/dev.scrapy.org/htdocs/css/diff.css => sites/static.scrapy.org/css/diff.css rename : sites/dev.scrapy.org/htdocs/css/prefs.css => sites/static.scrapy.org/css/prefs.css rename : sites/dev.scrapy.org/htdocs/css/report.css => sites/static.scrapy.org/css/report.css rename : sites/dev.scrapy.org/htdocs/css/roadmap.css => sites/static.scrapy.org/css/roadmap.css rename : sites/dev.scrapy.org/htdocs/css/search.css => sites/static.scrapy.org/css/search.css rename : sites/dev.scrapy.org/htdocs/css/ticket.css => sites/static.scrapy.org/css/ticket.css rename : sites/dev.scrapy.org/htdocs/css/timeline.css => sites/static.scrapy.org/css/timeline.css rename : sites/dev.scrapy.org/htdocs/css/trac-0.11rc2.css.diff => sites/static.scrapy.org/css/trac-0.11rc2.css.diff rename : sites/dev.scrapy.org/htdocs/css/trac.css => sites/static.scrapy.org/css/trac.css rename : sites/dev.scrapy.org/htdocs/css/wiki.css => sites/static.scrapy.org/css/wiki.css rename : sites/dev.scrapy.org/htdocs/desc.png => sites/static.scrapy.org/desc.png rename : sites/dev.scrapy.org/htdocs/dots.gif => sites/static.scrapy.org/dots.gif rename : sites/dev.scrapy.org/htdocs/draft.png => sites/static.scrapy.org/draft.png rename : sites/dev.scrapy.org/htdocs/edit_toolbar.png => sites/static.scrapy.org/edit_toolbar.png rename : sites/dev.scrapy.org/htdocs/editedticket.png => sites/static.scrapy.org/editedticket.png rename : sites/dev.scrapy.org/htdocs/envelope.png => sites/static.scrapy.org/envelope.png rename : sites/dev.scrapy.org/htdocs/expanded.png => sites/static.scrapy.org/expanded.png rename : sites/dev.scrapy.org/htdocs/expander_normal.png => sites/static.scrapy.org/expander_normal.png rename : sites/dev.scrapy.org/htdocs/expander_normal_hover.png => sites/static.scrapy.org/expander_normal_hover.png rename : sites/dev.scrapy.org/htdocs/expander_open.png => sites/static.scrapy.org/expander_open.png rename : sites/dev.scrapy.org/htdocs/expander_open_hover.png => sites/static.scrapy.org/expander_open_hover.png rename : sites/dev.scrapy.org/htdocs/extlink.gif => sites/static.scrapy.org/extlink.gif rename : sites/dev.scrapy.org/htdocs/feed.png => sites/static.scrapy.org/feed.png rename : sites/dev.scrapy.org/htdocs/file.png => sites/static.scrapy.org/file.png rename : sites/dev.scrapy.org/htdocs/folder.png => sites/static.scrapy.org/folder.png rename : sites/dev.scrapy.org/htdocs/guide/basic-workflow.png => sites/static.scrapy.org/guide/basic-workflow.png rename : sites/dev.scrapy.org/htdocs/guide/original-workflow.png => sites/static.scrapy.org/guide/original-workflow.png rename : sites/dev.scrapy.org/htdocs/ics.png => sites/static.scrapy.org/ics.png rename : sites/dev.scrapy.org/htdocs/imggrid.png => sites/static.scrapy.org/imggrid.png rename : sites/dev.scrapy.org/htdocs/js/blame.js => sites/static.scrapy.org/js/blame.js rename : sites/dev.scrapy.org/htdocs/js/diff.js => sites/static.scrapy.org/js/diff.js rename : sites/dev.scrapy.org/htdocs/js/expand_dir.js => sites/static.scrapy.org/js/expand_dir.js rename : sites/dev.scrapy.org/htdocs/js/folding.js => sites/static.scrapy.org/js/folding.js rename : sites/dev.scrapy.org/htdocs/js/ie_pre7_hacks.js => sites/static.scrapy.org/js/ie_pre7_hacks.js rename : sites/dev.scrapy.org/htdocs/js/jquery.js => sites/static.scrapy.org/js/jquery.js rename : sites/dev.scrapy.org/htdocs/js/keyboard_nav.js => sites/static.scrapy.org/js/keyboard_nav.js rename : sites/dev.scrapy.org/htdocs/js/noconflict.js => sites/static.scrapy.org/js/noconflict.js rename : sites/dev.scrapy.org/htdocs/js/query.js => sites/static.scrapy.org/js/query.js rename : sites/dev.scrapy.org/htdocs/js/search.js => sites/static.scrapy.org/js/search.js rename : sites/dev.scrapy.org/htdocs/js/suggest.js => sites/static.scrapy.org/js/suggest.js rename : sites/dev.scrapy.org/htdocs/js/trac.js => sites/static.scrapy.org/js/trac.js rename : sites/dev.scrapy.org/htdocs/js/wikitoolbar.js => sites/static.scrapy.org/js/wikitoolbar.js rename : sites/dev.scrapy.org/htdocs/loading.gif => sites/static.scrapy.org/loading.gif rename : sites/dev.scrapy.org/htdocs/lock-locked.png => sites/static.scrapy.org/lock-locked.png rename : sites/dev.scrapy.org/htdocs/logo.jpg => sites/static.scrapy.org/logo.jpg rename : sites/dev.scrapy.org/htdocs/main-bg.jpg => sites/static.scrapy.org/main-bg.jpg rename : sites/dev.scrapy.org/htdocs/milestone.png => sites/static.scrapy.org/milestone.png rename : sites/dev.scrapy.org/htdocs/newticket.png => sites/static.scrapy.org/newticket.png rename : sites/dev.scrapy.org/htdocs/parent.png => sites/static.scrapy.org/parent.png rename : sites/dev.scrapy.org/htdocs/python.png => sites/static.scrapy.org/python.png rename : sites/dev.scrapy.org/htdocs/topbar_gradient.png => sites/static.scrapy.org/topbar_gradient.png rename : sites/dev.scrapy.org/htdocs/topbar_gradient2.png => sites/static.scrapy.org/topbar_gradient2.png rename : sites/dev.scrapy.org/htdocs/trac.ico => sites/static.scrapy.org/trac.ico rename : sites/dev.scrapy.org/htdocs/trac_banner.png => sites/static.scrapy.org/trac_banner.png rename : sites/dev.scrapy.org/htdocs/trac_logo_mini.png => sites/static.scrapy.org/trac_logo_mini.png rename : sites/dev.scrapy.org/htdocs/vgradient.png => sites/static.scrapy.org/vgradient.png rename : sites/dev.scrapy.org/htdocs/wiki.png => sites/static.scrapy.org/wiki.png extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%4023
114 lines
3.8 KiB
JavaScript
114 lines
3.8 KiB
JavaScript
(function($){
|
|
|
|
function convertDiff(name, table) {
|
|
var inline = table.className == 'inline';
|
|
var ths = table.tHead.rows[0].cells;
|
|
var afile, bfile;
|
|
if ( inline ) {
|
|
afile = ths[0].title;
|
|
bfile = ths[1].title;
|
|
} else {
|
|
afile = $(ths[0]).find('a').text();
|
|
bfile = $(ths[1]).find('a').text();
|
|
}
|
|
if ( afile.match(/^Revision /) ) {
|
|
afile = 'a/' + name;
|
|
bfile = 'b/' + name;
|
|
}
|
|
var lines = [
|
|
"Index: " + name,
|
|
"===================================================================",
|
|
"--- " + afile.replace(/File /, ''),
|
|
"+++ " + bfile.replace(/File /, ''),
|
|
];
|
|
var sepIndex = 0;
|
|
var oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;
|
|
|
|
for (var i = 0; i < table.tBodies.length; i++) {
|
|
var tBody = table.tBodies[i];
|
|
if (i == 0 || tBody.className == "skipped") {
|
|
if (i > 0) {
|
|
if (!oldOffset && oldLength) oldOffset = 1
|
|
if (!newOffset && newLength) newOffset = 1
|
|
lines[sepIndex] = lines[sepIndex]
|
|
.replace("{1}", oldOffset).replace("{2}", oldLength)
|
|
.replace("{3}", newOffset).replace("{4}", newLength);
|
|
}
|
|
sepIndex = lines.length;
|
|
lines.push("@@ -{1},{2} +{3},{4} @@");
|
|
oldOffset = 0, oldLength = 0, newOffset = 0, newLength = 0;
|
|
if (tBody.className == "skipped") continue;
|
|
}
|
|
var tmpLines = [];
|
|
for (var j = 0; j < tBody.rows.length; j++) {
|
|
var cells = tBody.rows[j].cells;
|
|
var oldLineNo = parseInt($(cells[0]).text());
|
|
var newLineNo = parseInt($(cells[inline ? 1 : 2]).text());
|
|
if (tBody.className == 'unmod') {
|
|
lines.push(" " + $(cells[inline ? 2 : 1]).text());
|
|
oldLength += 1;
|
|
newLength += 1;
|
|
if (!oldOffset) oldOffset = oldLineNo;
|
|
if (!newOffset) newOffset = newLineNo;
|
|
} else {
|
|
var oldLine;
|
|
var newLine;
|
|
if (inline) {
|
|
oldLine = newLine = $(cells[2]).text();
|
|
} else {
|
|
oldLine = $(cells[1]).text();
|
|
newLine = $(cells[3]).text();
|
|
}
|
|
if (!isNaN(oldLineNo)) {
|
|
lines.push("-" + oldLine);
|
|
oldLength += 1;
|
|
}
|
|
if (!isNaN(newLineNo)) {
|
|
tmpLines.push("+" + newLine);
|
|
newLength += 1;
|
|
}
|
|
}
|
|
}
|
|
if (tmpLines.length > 0) {
|
|
lines = lines.concat(tmpLines);
|
|
}
|
|
}
|
|
|
|
if (!oldOffset && oldLength) oldOffset = 1;
|
|
if (!newOffset && newLength) newOffset = 1;
|
|
lines[sepIndex] = lines[sepIndex]
|
|
.replace("{1}", oldOffset).replace("{2}", oldLength)
|
|
.replace("{3}", newOffset).replace("{4}", newLength);
|
|
|
|
/* remove trailing and join lines (with CR for IExplorer) */
|
|
for ( var i = 0; i < lines.length; i++ )
|
|
if ( lines[i] )
|
|
lines[i] = lines[i].replace(/\xa0$/, '');
|
|
return lines.join($.browser.msie ? "\r" : "\n");
|
|
}
|
|
|
|
$(document).ready(function($) {
|
|
$("div.diff h2").each(function() {
|
|
var switcher = $("<span class='switch'></span>").prependTo(this);
|
|
var name = $.trim($(this).text());
|
|
var table = $(this).siblings("table").get(0);
|
|
if (! table) return;
|
|
var pre = $("<pre></pre>").hide().insertAfter(table);
|
|
$("<span>Tabular</span>").click(function() {
|
|
$(pre).hide();
|
|
$(table).show();
|
|
$(this).addClass("active").siblings("span").removeClass("active");
|
|
return false;
|
|
}).addClass("active").appendTo(switcher);
|
|
$("<span>Unified</span>").click(function() {
|
|
$(table).hide();
|
|
if (!pre.get(0).firstChild) pre.text(convertDiff(name, table));
|
|
$(pre).fadeIn("fast")
|
|
$(this).addClass("active").siblings("span").removeClass("active");
|
|
return false;
|
|
}).appendTo(switcher);
|
|
});
|
|
});
|
|
|
|
})(jQuery);
|