Skip to content

Commit

Permalink
Merge pull request #1 from jm-factorin/revise-code-rendering
Browse files Browse the repository at this point in the history
Revise code render function
  • Loading branch information
John Marlo Factorin committed Sep 11, 2015
2 parents c944d21 + 41bfe2b commit d8c6321
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
1 change: 1 addition & 0 deletions css/github.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
(function () {
'use strict';

//noinspection JSCheckFunctionSignatures
$(document).ready(function() {
setInterval(function() {
$('code.chatCode').each(function(i, block) {
if (!$(block).hasClass('hljs')) {
hljs.highlightBlock(block);
}
var doRenderChatCode = function (timeline) {
var $timeline = $('<div></div>').html(timeline);
var $messages = $timeline.find('.chatTimeLineMessage');

if (!$messages.length) {
return;
}

$messages.find('code.chatCode').each(function (i, block) {
hljs.highlightBlock(block);
});
}, 100);
});

return $timeline.html();
};

var renderTimeLine = TimeLineView.prototype.renderTimeLine;
TimeLineView.prototype.renderTimeLine = function (a, b) {
b = doRenderChatCode(b);
renderTimeLine.apply(TimeLineView, [a, b]);
};
})();
4 changes: 2 additions & 2 deletions js/extension.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var link = document.createElement('link');
link.rel = 'stylesheet';
link.href = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/styles/github.min.css';
link.href = chrome.extension.getURL('css/github.min.css');
document.querySelector('head').appendChild(link);

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js';
script.src = chrome.extension.getURL('js/highlight.min.js');
document.querySelector('body').appendChild(script);

var app = document.createElement('script');
Expand Down
2 changes: 2 additions & 0 deletions js/highlight.min.js

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ChatWork Code Highlight!",
"version": "1.0.1",
"version": "2.0.0",
"description": "ChatWork Code Highlight!",
"icons": {
"128": "icons/128.png",
Expand All @@ -10,17 +10,20 @@
},
"permissions": [
"https://kcw.kddi.ne.jp/*",
"https://www.chatwork.com/*",
"tabs"
],
"short_name": "ChatWork Code",
"short_name": "CW Code Highlight",
"content_scripts": [
{
"matches": ["https://kcw.kddi.ne.jp/*"],
"matches": ["https://kcw.kddi.ne.jp/*", "https://www.chatwork.com/*"],
"js": ["js/extension.js"],
"run_at": "document_end"
}
],
"web_accessible_resources": [
"js/app.js"
"js/app.js",
"js/highlight.min.js",
"css/github.min.css"
]
}

0 comments on commit d8c6321

Please sign in to comment.