From 2ea1283901e8d9db00031adfe58febdcda58c13a Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 27 May 2012 21:33:04 +0200 Subject: [PATCH] use new-style tokens --- source/Ox.UI/js/Code/Ox.SourceViewer.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/Ox.UI/js/Code/Ox.SourceViewer.js b/source/Ox.UI/js/Code/Ox.SourceViewer.js index f102cde7..e7acf5ad 100644 --- a/source/Ox.UI/js/Code/Ox.SourceViewer.js +++ b/source/Ox.UI/js/Code/Ox.SourceViewer.js @@ -41,17 +41,18 @@ Ox.SourceViewer = function(options, self) { Ox.get(self.options.file, function(source) { var sections = [{comment: '', code: ''}]; Ox.tokenize(source).forEach(function(token, i) { - var text = source.substr(token.offset, token.length), - type = token.type == 'comment' ? 'comment' : 'code'; - if (!/^\/\//.test(text)) { + var type = token.type == 'comment' ? 'comment' : 'code'; + if (!/^\/\//.test(token.value)) { if (type == 'comment') { i && sections.push({comment: '', code: ''}); - text = text.slice(2, -2); + token.value = token.value.slice(2, -2); self.options.replaceComment.forEach(function(replace) { - text = text.replace(replace[0], replace[1]); + token.value = token.value.replace( + replace[0], replace[1] + ); }); } - Ox.last(sections)[type] += text; + Ox.last(sections)[type] += token.value; } }); sections.forEach(function(section) {