2013-12-31 14:14:58 +00:00
|
|
|
var current_diff;
|
2012-07-09 20:48:27 +00:00
|
|
|
|
2012-07-10 15:06:18 +00:00
|
|
|
// Extract query parameters
|
|
|
|
var params = function(query) {
|
|
|
|
var search = /([^&=]+)=?([^&]*)/g,
|
|
|
|
pl = /\+/g,
|
|
|
|
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
|
|
|
|
ret = {};
|
2012-07-09 20:48:27 +00:00
|
|
|
|
2012-07-10 15:06:18 +00:00
|
|
|
while (match = search.exec(query))
|
|
|
|
{
|
|
|
|
ret[decode(match[1])] = decode(match[2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}(document.location.search.substring(1));
|
|
|
|
|
2012-07-11 12:04:38 +00:00
|
|
|
var settings = {
|
|
|
|
wrap: true,
|
|
|
|
tab_width: 4,
|
2013-03-02 13:33:20 +00:00
|
|
|
debug: false,
|
2013-07-03 14:37:58 +00:00
|
|
|
staged: false,
|
|
|
|
unstaged: false,
|
2013-07-03 14:44:13 +00:00
|
|
|
strings: {
|
|
|
|
stage: 'stage',
|
|
|
|
unstage: 'unstage',
|
2014-07-10 12:11:13 +00:00
|
|
|
loading_diff: 'Loading diff...',
|
|
|
|
get_patch: 'Get Patch'
|
2013-12-07 15:15:55 +00:00
|
|
|
},
|
2012-07-11 12:04:38 +00:00
|
|
|
};
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
var avatar_cache = {};
|
|
|
|
|
2012-07-11 12:04:38 +00:00
|
|
|
if ('settings' in params)
|
|
|
|
{
|
2013-07-03 14:37:58 +00:00
|
|
|
$.extend(settings, JSON.parse(params.settings));
|
2012-07-11 12:04:38 +00:00
|
|
|
}
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
var escapeDiv = document.createElement('div');
|
|
|
|
var escapeElement = document.createTextNode('');
|
|
|
|
escapeDiv.appendChild(escapeElement);
|
|
|
|
|
|
|
|
function html_escape(str)
|
|
|
|
{
|
|
|
|
escapeElement.data = str;
|
|
|
|
return escapeDiv.innerHTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
var commit_elements = null;
|
|
|
|
|
|
|
|
function get_commit_elements(content)
|
|
|
|
{
|
|
|
|
if (commit_elements != null)
|
|
|
|
{
|
|
|
|
return commit_elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
var elems = content.find('[data-id]');
|
|
|
|
|
|
|
|
commit_elements = {};
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
for (var i = 0; i < elems.length; i++)
|
|
|
|
{
|
|
|
|
var elem = $(elems[i]);
|
|
|
|
var name = elem.attr('data-id');
|
|
|
|
|
|
|
|
commit_elements[name] = elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
return commit_elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
function write_avatar(avatar, commit)
|
2012-07-10 15:06:18 +00:00
|
|
|
{
|
2014-07-01 09:02:37 +00:00
|
|
|
var h = commit.author.email_md5;
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
if (h in avatar_cache)
|
2012-07-11 12:04:38 +00:00
|
|
|
{
|
2014-07-01 09:02:37 +00:00
|
|
|
var avc = avatar_cache[h];
|
|
|
|
|
|
|
|
if (avc != null && avatar.attr('src') != avc)
|
|
|
|
{
|
|
|
|
avatar.attr('src', avc);
|
|
|
|
}
|
|
|
|
|
2012-07-11 12:04:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
var loader = $('<img/>');
|
|
|
|
var gravatar = 'http://www.gravatar.com/avatar/' + h + '?d=404&s=50';
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
loader.on('load', function () {
|
|
|
|
avatar_cache[h] = gravatar;
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
avatar.attr('src', gravatar);
|
2012-07-11 12:04:38 +00:00
|
|
|
});
|
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
loader.on('error', function () {
|
|
|
|
var avc = 'gitg-diff:/icon/avatar-default-symbolic?size=50';
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
avatar_cache[h] = avc;
|
|
|
|
avatar.attr('src', avc);
|
|
|
|
});
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
loader.attr('src', gravatar);
|
2012-07-11 12:04:38 +00:00
|
|
|
}
|
|
|
|
|
2014-07-12 08:52:59 +00:00
|
|
|
function prettify_message(message)
|
|
|
|
{
|
|
|
|
var lines = message.split(/\n/);
|
|
|
|
var ret = '';
|
|
|
|
var isempty = false;
|
|
|
|
|
|
|
|
for (var i = 0; i < lines.length; i++)
|
|
|
|
{
|
|
|
|
var l = lines[i];
|
|
|
|
l = l.trimRight();
|
|
|
|
|
|
|
|
if (isempty && l.length != 0)
|
|
|
|
{
|
|
|
|
ret += '\n\n';
|
|
|
|
}
|
|
|
|
else if (l.match(/^[^a-zA-Z_]/))
|
|
|
|
{
|
|
|
|
ret += '\n';
|
|
|
|
}
|
|
|
|
else if (l.length != 0 && ret.length != 0)
|
|
|
|
{
|
|
|
|
ret += ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
ret += l;
|
|
|
|
isempty = (l.length == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
function write_commit(content, commit)
|
2012-07-11 12:04:38 +00:00
|
|
|
{
|
2014-07-01 09:02:37 +00:00
|
|
|
var elems = get_commit_elements(content);
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
// Author
|
|
|
|
var name = $('<span/>', {'class': 'author name'}).text(commit.author.name);
|
|
|
|
var a = $('<a/>', {href: 'mailto:' + commit.author.email}).text(commit.author.email);
|
|
|
|
elems.author.html($('<span/>').append(name).append(' <').append(a).append('>'));
|
2012-10-29 15:58:23 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
// Date
|
|
|
|
elems.date.text(commit.author.time);
|
2012-10-29 15:58:23 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
// Message
|
2014-07-12 08:52:59 +00:00
|
|
|
elems.message.text(prettify_message(commit.message));
|
2012-10-30 21:21:41 +00:00
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
// Sha1
|
|
|
|
elems.sha1.text(commit.id);
|
|
|
|
|
2014-07-10 12:11:13 +00:00
|
|
|
// Get patch string
|
|
|
|
elems.format_patch.text(settings.strings.get_patch);
|
|
|
|
|
2014-07-01 09:02:37 +00:00
|
|
|
write_avatar(elems.avatar, commit);
|
2012-10-30 21:21:41 +00:00
|
|
|
}
|
2012-10-29 15:58:23 +00:00
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
var html_builder_worker = 0;
|
|
|
|
var html_builder_tick = 0;
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2013-12-28 14:50:22 +00:00
|
|
|
function expand_collapse()
|
|
|
|
{
|
|
|
|
var expander = $(this);
|
|
|
|
|
|
|
|
// If expanded, will be true
|
|
|
|
var toExpand = expander.text() == "+";
|
|
|
|
|
|
|
|
if (toExpand)
|
|
|
|
{
|
|
|
|
// next step to close it
|
|
|
|
expander.text("-");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// next step is to open it
|
|
|
|
expander.text("+");
|
|
|
|
}
|
|
|
|
|
|
|
|
expander.closest('tbody').toggleClass("collapsed");
|
|
|
|
}
|
|
|
|
|
2013-12-31 14:17:20 +00:00
|
|
|
function next_element(elem)
|
|
|
|
{
|
|
|
|
elem = elem.nextSibling;
|
|
|
|
|
|
|
|
while (elem != null && elem.nodeType != Node.ELEMENT_NODE)
|
|
|
|
{
|
|
|
|
elem = elem.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
function has_class(e, cls)
|
|
|
|
{
|
|
|
|
return e.classList.contains(cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
function update_has_selection()
|
|
|
|
{
|
|
|
|
var selection = document.querySelectorAll('tr.added.selected, tr.removed.selected');
|
|
|
|
var hs = (selection.length != 0);
|
|
|
|
|
2014-07-01 09:24:33 +00:00
|
|
|
var v = hs ? "yes" : "no";
|
|
|
|
xhr_get('internal', {action: 'selection-changed', value: v});
|
2013-12-31 14:17:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function prepare_patchset(filediv)
|
|
|
|
{
|
|
|
|
var elem = filediv.querySelector('tr.file_header');
|
|
|
|
|
|
|
|
elem = next_element(elem);
|
|
|
|
|
|
|
|
var patches = [];
|
|
|
|
var doffset = 0;
|
|
|
|
|
|
|
|
var a = "a".charCodeAt(0);
|
|
|
|
var r = "r".charCodeAt(0);
|
|
|
|
|
2013-12-31 16:09:22 +00:00
|
|
|
var last = null;
|
|
|
|
|
2013-12-31 14:17:20 +00:00
|
|
|
while (elem != null)
|
|
|
|
{
|
|
|
|
var e = elem;
|
|
|
|
elem = next_element(elem);
|
|
|
|
|
|
|
|
var added = has_class(e, 'added');
|
|
|
|
var removed = has_class(e, 'removed');
|
|
|
|
|
|
|
|
if (!added && !removed)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
var selected = has_class(e, 'selected');
|
|
|
|
var offset = parseInt(e.getAttribute('data-offset'));
|
|
|
|
var length = parseInt(e.getAttribute('data-length'));
|
|
|
|
|
|
|
|
if (selected)
|
|
|
|
{
|
2013-12-31 16:09:22 +00:00
|
|
|
var tp = added ? a : r;
|
|
|
|
|
|
|
|
if (last != null && last[0] == tp && last[2] + last[3] == offset)
|
|
|
|
{
|
2014-07-09 19:42:23 +00:00
|
|
|
// Contiguous block, just add the length
|
2013-12-31 16:09:22 +00:00
|
|
|
last[3] += length;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-02 12:29:10 +00:00
|
|
|
var o = {old: offset, new: offset};
|
|
|
|
|
|
|
|
if (added)
|
|
|
|
{
|
|
|
|
o.old -= doffset;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
o.new += doffset;
|
|
|
|
}
|
|
|
|
|
2013-12-31 16:09:22 +00:00
|
|
|
// [sign, old_offset, new_offset, length]
|
2014-01-02 12:29:10 +00:00
|
|
|
last = [tp, o.old, o.new, length];
|
2013-12-31 16:09:22 +00:00
|
|
|
patches.push(last);
|
|
|
|
}
|
2013-12-31 14:17:20 +00:00
|
|
|
}
|
2013-12-31 16:09:44 +00:00
|
|
|
|
2014-07-09 19:42:23 +00:00
|
|
|
// Keep track of the total offset difference between old and new
|
2014-01-02 12:29:10 +00:00
|
|
|
doffset += added ? length : -length;
|
2013-12-31 14:17:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var filename = filediv.getAttribute('data-filename');
|
|
|
|
return [filename, patches];
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_selection()
|
|
|
|
{
|
|
|
|
var files = document.querySelectorAll('#diff_content div.file');
|
|
|
|
var ret = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++)
|
|
|
|
{
|
2014-01-01 17:32:55 +00:00
|
|
|
if (!has_class(files[i], 'background'))
|
|
|
|
{
|
|
|
|
ret.push(prepare_patchset(files[i]));
|
|
|
|
}
|
2013-12-31 14:17:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2013-12-28 14:51:39 +00:00
|
|
|
|
|
|
|
function stage_unstage_hunk()
|
|
|
|
{
|
2013-12-31 14:17:20 +00:00
|
|
|
var elem = next_element(this);
|
2013-12-28 14:51:39 +00:00
|
|
|
|
2013-12-31 14:17:20 +00:00
|
|
|
var hasunsel = false;
|
|
|
|
var lines = [];
|
2013-12-28 14:51:39 +00:00
|
|
|
|
2013-12-31 14:17:20 +00:00
|
|
|
while (elem != null && !(has_class(elem, 'file_header') || has_class(elem, 'hunk_header')))
|
2013-12-28 14:51:39 +00:00
|
|
|
{
|
2013-12-31 14:17:20 +00:00
|
|
|
if ((has_class(elem, 'added') || has_class(elem, 'removed')))
|
|
|
|
{
|
|
|
|
lines.push(elem);
|
|
|
|
|
|
|
|
if (!has_class(elem, 'selected'))
|
|
|
|
{
|
|
|
|
hasunsel = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elem = next_element(elem);
|
2013-12-28 14:51:39 +00:00
|
|
|
}
|
2013-12-31 14:17:20 +00:00
|
|
|
|
|
|
|
for (var i = 0; i < lines.length; i++)
|
|
|
|
{
|
|
|
|
if (hasunsel)
|
|
|
|
{
|
|
|
|
lines[i].classList.add('selected');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lines[i].classList.remove('selected');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
update_has_selection();
|
2013-12-28 14:51:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function stage_unstage_line()
|
|
|
|
{
|
2013-12-31 14:17:20 +00:00
|
|
|
if (has_class(this, 'selected'))
|
|
|
|
{
|
|
|
|
this.classList.remove('selected');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.classList.add('selected');
|
|
|
|
}
|
|
|
|
|
|
|
|
update_has_selection();
|
|
|
|
}
|
2013-12-31 14:14:58 +00:00
|
|
|
|
|
|
|
function xhr_get(action, data, onload)
|
|
|
|
{
|
|
|
|
var r = new XMLHttpRequest();
|
|
|
|
|
|
|
|
if (onload)
|
|
|
|
{
|
|
|
|
r.onload = function(e) { onload(r.responseText); }
|
|
|
|
}
|
|
|
|
|
|
|
|
t = (new Date()).getTime();
|
|
|
|
d = '?_t=' + t + '&viewid=' + params.viewid + "&diffid=" + current_diff;
|
|
|
|
|
|
|
|
for (var k in data)
|
|
|
|
{
|
|
|
|
d += '&' + encodeURIComponent(k) + '=' + encodeURIComponent(data[k]);
|
|
|
|
}
|
|
|
|
|
|
|
|
r.open("GET", "gitg-diff:/" + action + "/" + d);
|
|
|
|
r.send();
|
2013-12-28 14:51:39 +00:00
|
|
|
}
|
2013-12-28 14:52:13 +00:00
|
|
|
|
2014-07-10 17:09:51 +00:00
|
|
|
var tab_width_rule = null;
|
|
|
|
|
|
|
|
function update_tab_width(width)
|
|
|
|
{
|
|
|
|
settings.tab_width = width;
|
|
|
|
|
|
|
|
if (tab_width_rule == null)
|
|
|
|
{
|
|
|
|
var sheet = document.getElementById('dynamic_styles').sheet;
|
|
|
|
sheet.addRule('#diff td.code', 'tab-size: ' + width, 0);
|
|
|
|
tab_width_rule = sheet.rules[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
tab_width_rule.style.tabSize = width;
|
|
|
|
}
|
|
|
|
|
2013-07-03 14:37:58 +00:00
|
|
|
function update_diff(id, lsettings)
|
2012-10-30 21:21:41 +00:00
|
|
|
{
|
|
|
|
if (html_builder_worker)
|
2012-07-10 15:06:18 +00:00
|
|
|
{
|
2012-10-30 21:21:41 +00:00
|
|
|
html_builder_worker.terminate();
|
|
|
|
}
|
|
|
|
|
2013-12-08 12:00:59 +00:00
|
|
|
var content = $('#diff_content');
|
2013-07-03 16:50:18 +00:00
|
|
|
|
|
|
|
if (typeof id == 'undefined')
|
|
|
|
{
|
2013-12-08 12:00:59 +00:00
|
|
|
content.empty();
|
2014-01-02 12:37:53 +00:00
|
|
|
update_has_selection();
|
2013-07-03 16:50:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-02 12:37:53 +00:00
|
|
|
current_diff = id;
|
|
|
|
|
2013-07-03 16:50:18 +00:00
|
|
|
if (typeof lsettings != 'undefined')
|
|
|
|
{
|
|
|
|
$.extend(settings, lsettings);
|
|
|
|
}
|
|
|
|
|
2013-03-02 13:33:20 +00:00
|
|
|
workeruri = 'diff-view-html-builder.js';
|
|
|
|
|
|
|
|
if (settings.debug)
|
|
|
|
{
|
|
|
|
var t = (new Date()).getTime();
|
|
|
|
workeruri += '?t' + t;
|
|
|
|
}
|
|
|
|
|
2014-07-10 17:09:51 +00:00
|
|
|
update_tab_width(settings.tab_width);
|
|
|
|
|
2013-03-02 13:33:20 +00:00
|
|
|
html_builder_worker = new Worker(workeruri);
|
2012-10-30 21:21:41 +00:00
|
|
|
html_builder_tick = 0;
|
|
|
|
|
|
|
|
html_builder_progress_timeout = setTimeout(function (){
|
|
|
|
var eta = 200 / html_builder_tick - 200;
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
if (eta > 1000)
|
2012-07-11 12:04:38 +00:00
|
|
|
{
|
2012-10-30 21:21:41 +00:00
|
|
|
// Show the progress
|
2014-01-02 13:02:14 +00:00
|
|
|
content.html(' \
|
|
|
|
<div class="loading"> \
|
|
|
|
' + settings.strings.loading_diff + ' \
|
|
|
|
</div> \
|
2013-12-08 12:00:59 +00:00
|
|
|
');
|
2014-01-02 12:37:53 +00:00
|
|
|
|
|
|
|
update_has_selection();
|
2012-07-11 12:04:38 +00:00
|
|
|
}
|
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
html_builder_progress_timeout = 0;
|
|
|
|
}, 200);
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
html_builder_worker.onmessage = function (event) {
|
|
|
|
if (event.data.log)
|
2012-07-10 15:06:18 +00:00
|
|
|
{
|
2012-10-30 21:21:41 +00:00
|
|
|
console.log(event.data.log);
|
|
|
|
}
|
|
|
|
else if (event.data.tick)
|
|
|
|
{
|
|
|
|
html_builder_tick = event.data.tick;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
html_builder_worker.terminate();
|
|
|
|
html_builder_worker = 0;
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
if (html_builder_progress_timeout)
|
2012-07-10 15:06:18 +00:00
|
|
|
{
|
2012-10-30 21:21:41 +00:00
|
|
|
clearTimeout(html_builder_progress_timeout);
|
|
|
|
html_builder_progress_timeout = 0;
|
2012-07-10 15:06:18 +00:00
|
|
|
}
|
|
|
|
|
2013-12-08 12:00:59 +00:00
|
|
|
content.html(event.data.diff_html);
|
2014-01-02 12:37:53 +00:00
|
|
|
update_has_selection();
|
2013-06-09 15:41:39 +00:00
|
|
|
|
2013-12-28 14:50:22 +00:00
|
|
|
$(".expander").click(expand_collapse);
|
2013-12-31 14:17:20 +00:00
|
|
|
|
|
|
|
if (settings.staged || settings.unstaged)
|
|
|
|
{
|
|
|
|
$("tr.hunk_header").click(stage_unstage_hunk);
|
|
|
|
$("tr.added, tr.removed").click(stage_unstage_line);
|
|
|
|
}
|
2012-07-10 15:06:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
var t = (new Date()).getTime();
|
2012-10-29 15:58:23 +00:00
|
|
|
|
2013-03-02 13:33:41 +00:00
|
|
|
var file_template = $('#templates div.file')[0].outerHTML;
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2012-10-30 21:21:41 +00:00
|
|
|
// Load the diff asynchronously
|
|
|
|
html_builder_worker.postMessage({
|
2013-03-01 23:33:29 +00:00
|
|
|
url: "gitg-diff:/diff/?t=" + t + "&viewid=" + params.viewid + "&diffid=" + id + "&format=diff_only",
|
2012-10-30 21:21:41 +00:00
|
|
|
settings: settings,
|
2013-03-02 13:33:41 +00:00
|
|
|
file_template: file_template,
|
2012-10-30 21:21:41 +00:00
|
|
|
});
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2013-12-31 14:14:58 +00:00
|
|
|
xhr_get("diff", {format: "commit_only"}, function(r) {
|
2014-07-09 19:42:23 +00:00
|
|
|
if (!r)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-31 14:14:58 +00:00
|
|
|
var j = JSON.parse(r);
|
2012-07-10 15:06:18 +00:00
|
|
|
|
2012-07-11 06:44:23 +00:00
|
|
|
if ('commit' in j)
|
|
|
|
{
|
2014-07-01 09:02:37 +00:00
|
|
|
write_commit($('#diff_header .commit'), j.commit);
|
|
|
|
$('#diff_header').show();
|
2013-12-31 14:14:58 +00:00
|
|
|
|
2014-06-30 21:03:17 +00:00
|
|
|
$('.format_patch').click(function() {
|
2013-12-31 14:14:58 +00:00
|
|
|
xhr_get('patch', {id: j.commit.id});
|
2013-08-20 18:50:06 +00:00
|
|
|
});
|
2012-07-11 06:44:23 +00:00
|
|
|
}
|
2014-07-01 09:02:37 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$('#diff_header').hide();
|
|
|
|
}
|
2013-12-31 14:14:58 +00:00
|
|
|
});
|
2012-07-09 20:48:27 +00:00
|
|
|
}
|
2012-07-11 12:04:38 +00:00
|
|
|
|
2012-07-12 12:07:28 +00:00
|
|
|
addEventListener('DOMContentLoaded', function () {
|
2014-06-29 07:58:54 +00:00
|
|
|
xhr_get('internal', {action: 'loaded'});
|
2012-07-11 12:04:38 +00:00
|
|
|
}, false);
|
|
|
|
|
|
|
|
// vi:ts=4
|