From 7a3166c0e670ccac047f21350f0be23a29fd1cd9 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Mon, 1 Dec 2008 15:09:48 +0100 Subject: [PATCH] WebHistoryView: Use diff callbacks to display history list This is the start of a callback system we can use to make the diff more interactive --- html/lib/diffHighlighter.js | 9 +++++++-- html/test.html | 16 ++++++++++++---- html/views/history/history.js | 27 ++++++++++++--------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/html/lib/diffHighlighter.js b/html/lib/diffHighlighter.js index 0f8b00a..a9b30cd 100644 --- a/html/lib/diffHighlighter.js +++ b/html/lib/diffHighlighter.js @@ -6,7 +6,9 @@ if (typeof Controller == 'undefined') { Controller.log_ = console.log; } -var highlightDiff = function(diff, element) { +var highlightDiff = function(diff, element, callbacks) { + if (!callbacks) + callbacks = {}; var start = new Date().getTime(); element.className = "diff" var content = diff.escapeHTML().replace(/\t/g, " ");; @@ -51,8 +53,11 @@ var highlightDiff = function(diff, element) { diffContent = ""; } - if(match = l.match(/diff --git a\/(\S*)/)) + if(match = l.match(/diff --git a\/(\S*)/)) { filename = match[1]; + if (callbacks["newfile"]) + callbacks["newfile"](filename, "file_index_" + (file_index - 1)); + } continue; } diff --git a/html/test.html b/html/test.html index b73d75a..795c686 100644 --- a/html/test.html +++ b/html/test.html @@ -8,13 +8,21 @@ - +
+