+/*
+ * History
+ */
+
+function refreshHistory(callback){
+ $.blockUI({
+ message: 'Odświeżanie historii...'
+ });
+
+ $.ajax({
+ url: document.location.href + '/history',
+ dataType: 'json',
+ error: function() {
+ $('#history-view .message-box').html('Nie udało się odświeżyć historii').show();
+ $.unblockUI();
+ },
+ success: function(data) {
+ $('#history-view .message-box').hide();
+ var changes_list = $('#changes-list');
+ changes_list.html('');
+
+ $.each(data, function() {
+ var val = this[0];
+ changes_list.append('<tr>'
+ +'<td><input type="radio" name="rev_from" value="'+val+'">'
+ + '<input type="radio" name="rev_to" value="'+val+'">'
+ +'<td>'+ this[0]+'</td>'
+ +'<td>'+ this[3]+'</td>'
+ +'<td>'+ this[2]+'</td>'
+ +'<td>'+ this[1]+'</td></tr>')
+ });
+ $.unblockUI();
+ callback();
+ }
+ });
+};
+
+function historyDiff(callback) {
+ var changelist = $('#changes-list');
+ var rev_a = $("input[name='rev_from']:checked", changelist);
+ var rev_b = $("input[name='rev_to']:checked", changelist);
+
+ if (rev_a.length != 1 || rev_b.length != 1) {
+ window.alert("Musisz zaznaczyć dwie wersje do porównania.");
+ return false;
+ }
+
+ if (rev_a.val() == rev_b.val()) {
+ window.alert("Musisz zaznaczyć dwie różne wersje do porównania.");
+ return false;
+ }
+
+ $.blockUI({
+ message: 'Wczytywanie porównania...'
+ });
+
+ $.ajax({
+ url: document.location.href + '/diff/'+rev_a.val() + '/'+ rev_b.val(),
+ dataType: 'html',
+ error: function() {
+ $.unblockUI();
+ window.alert('Nie udało się wykonać porównania :(.')
+ },
+ success: function(data) {
+ $.unblockUI();
+ var diffview = $('#diff-view');
+ diffview.html(data);
+ diffview.show();
+ }
+ });
+}
+