mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-15 16:12:51 +11:00
Ability to link and open to diffs directly. Fixes issue #2.
This commit is contained in:
parent
e14192d2d1
commit
1f863b345f
2 changed files with 26 additions and 8 deletions
|
@ -155,8 +155,8 @@ ol.linenums li.marked {
|
|||
/* ----------------------------------------------------------------------------
|
||||
Pygments
|
||||
---------------------------------------------------------------------------- */
|
||||
pre .gd { background-color: #d68c83; display: block; }
|
||||
pre .gi { background-color: #a7cb7d; display: block; }
|
||||
pre .gd { background-color: rgba(226, 12, 19, .5); display: block; }
|
||||
pre .gi { background-color: rgba(23, 189, 10, .5); display: block; }
|
||||
|
||||
|
||||
pre .hll { background-color: #49483e }
|
||||
|
|
|
@ -83,26 +83,44 @@ $(document).ready(function(){
|
|||
$(this).removeClass('snippet-reply-hidden');
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Diff Ajax Call
|
||||
*/
|
||||
$('.snippet-diff-trigger').click(function(e){
|
||||
e.preventDefault();
|
||||
$('#snippet-diff').slideDown('fast');
|
||||
$('#snippet-diff form').submit();
|
||||
});
|
||||
|
||||
/**
|
||||
* Diff Ajax Call
|
||||
*/
|
||||
|
||||
$("form#diffform").submit(function() {
|
||||
var a = $("input[name=a]:checked").val(),
|
||||
b = $("input[name=b]:checked").val(),
|
||||
hash = 'D'+a+','+b;
|
||||
$.get("{% url "snippet_diff" %}", {
|
||||
a: $("input[name=a]:checked").val(),
|
||||
b: $("input[name=b]:checked").val()
|
||||
a: a,
|
||||
b: b
|
||||
}, function(data){
|
||||
$('#diff').html(data).slideDown('fast');
|
||||
});
|
||||
window.location.hash = hash;
|
||||
return false;
|
||||
});
|
||||
|
||||
var curLine = document.location.hash,
|
||||
hashlist;
|
||||
|
||||
if(curLine.substring(0,2) == '#D'){
|
||||
hashlist = curLine.substring(2).split(',');
|
||||
if (hashlist.length == 2) {
|
||||
console.log(hashlist);
|
||||
$('form#diffform input[name=a][value='+hashlist[0]+']').attr('checked', true);
|
||||
$('form#diffform input[name=b][value='+hashlist[1]+']').attr('checked', true);
|
||||
$('#snippet-diff').slideDown('fast');
|
||||
$('#snippet-diff form').submit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Line Highlighting
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue