From 55992dd834a14aaa06e3782f773eeae5debc771f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 29 May 2012 14:22:39 +0200 Subject: [PATCH] use Ox.SyntaxHighlighter on /api/ --- pandora/templates/api.html | 2 - static/css/highlight.css | 67 --------------------------------- static/js/api/highlight.pack.js | 1 - static/js/api/pandora.js | 63 ++++++++++++++++++------------- 4 files changed, 37 insertions(+), 96 deletions(-) delete mode 100644 static/css/highlight.css delete mode 100644 static/js/api/highlight.pack.js diff --git a/pandora/templates/api.html b/pandora/templates/api.html index b511859e7..adb12da53 100644 --- a/pandora/templates/api.html +++ b/pandora/templates/api.html @@ -5,9 +5,7 @@
"+y.value+"
";v=x.firstChild.firstChild;x.firstChild.cN=s.cN;s.parentNode.replaceChild(x.firstChild,s)}else{v.innerHTML=y.value}v.className=u;v.dataset={};v.dataset.result={language:y.language,kw:y.keyword_count,re:y.r};if(z&&z.language){v.dataset.second_best={language:z.language,kw:z.keyword_count,re:z.r}}}function l(){if(l.called){return}l.called=true;f();if(arguments.length){for(var c=0;c') - .html(app.actions[id].doc.replace('/\n/
\n/g')) - .appendTo(info); - var $code = $('') - .html(app.actions[id].code[1].replace('/\n/
\n/g')) - .hide(); - /* - var $button = Ox.Button({ - type: "image", - options: [ - {id: "one", title: "right"}, - {id: "two", title: "down"}, - ], - }) - .addClass("margin") - .click(function() { $code.toggle()}) - .appendTo(info); - */ - var f = app.actions[id].code[0]; - $('') - .html(' View Source ('+f+')') - .click(function() { $code.toggle()}) - .appendTo(info) - $('').append($code).appendTo(info) - hljs.highlightBlock($code[0], ' '); + info.append( + $("") + .html(id) + .css({ + marginBottom: '8px' + }) + ); + var code = app.actions[id].code[1], + f = app.actions[id].code[0], + line = Math.round(Ox.last(f.split(':')) || 0), + doc = app.actions[id].doc.replace('/\n/
\n/g'), + $code, $doc; + $doc = Ox.SyntaxHighlighter({ + source: doc, + }) + .appendTo(info); + + Ox.Button({ + title: 'View Source (' + f + ')', + }).bindEvent({ + click: function() { + $code.toggle(); + } + }) + .css({ + margin: '4px' + }) + .appendTo(info); + $code = Ox.SyntaxHighlighter({ + showLineNumbers: true, + source: code, + offset: line + }) + .css({ + borderWidth: '1px', + }).appendTo(info).hide(); + Ox.print(code); hash += id + ',' }); else