[extensions-web] Show the raw view if no HTML view exists.
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] Show the raw view if no HTML view exists.
- Date: Fri, 30 Sep 2011 17:40:33 +0000 (UTC)
commit 02fe1d72ff7bd68ebdbf636793739ea6651d7331
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Sep 27 15:40:13 2011 -0400
Show the raw view if no HTML view exists.
sweettooth/static/js/review.js | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/sweettooth/static/js/review.js b/sweettooth/static/js/review.js
index 94f477a..a2004ec 100644
--- a/sweettooth/static/js/review.js
+++ b/sweettooth/static/js/review.js
@@ -3,7 +3,11 @@
define(['jquery'], function($) {
function createFileView(data) {
- var lines = [];
+ var $fileView, $table, $tr;
+
+ $tr = $('<tr>');
+ $table = $('<table>').append($tr);
+
if (data.show_linenum) {
var rawLines = data.raw.split("\n");
var count = rawLines.length;
@@ -13,16 +17,26 @@ define(['jquery'], function($) {
if (rawLines[0] == "")
count --;
+ var lines = [];
lines.push("<td class=\"linenumbers\"><pre>");
for (var i = 1; i < (count + 1); i ++) {
lines.push("<span rel=\"L" + i + "\">" + i + "</span>\n");
}
lines.push("</pre></td>");
+
+ $tr.append(lines.join(''));
}
- var file = "<td width=\"100%\"><div class=\"file\">" + data.html + "</div></td>";
+ $fileView = $('<div>', {'class': 'file'}).
+ appendTo($('<td>', {'width': '100%'}).appendTo($tr));
+
+ if (data.html !== undefined) {
+ $fileView.html(data.html);
+ } else {
+ $fileView.text(data.raw);
+ }
- return $("<table><tr>" + lines.join('') + file + "</tr></table>");
+ return $table;
}
$.fn.reviewify = function(fileurl) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]