-
Notifications
You must be signed in to change notification settings - Fork 0
/
c9.ide.reviewcomments.js
82 lines (70 loc) · 2.86 KB
/
c9.ide.reviewcomments.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
define(function(require, exports, module) {
main.consumes = ["Plugin", "panels", "ui", "Panel", "tabManager", "settings"];
main.provides = ["c9.ide.reviewcomments"];
return main;
function main(options, imports, register) {
var Panel = imports.Panel;
var panels = imports.panels;
var ui = imports.ui;
var tabManager = imports.tabManager;
var settings = imports.settings;
/***** Initialization *****/
var plugin = new Panel("reviews", main.consumes, {
index: 300,
caption: "Reviews",
where: "right",
});
plugin.on("draw", function(e){
ui.insertCss(require("text!./panel.css"), options.staticPrefix, plugin);
// Load iframe from nt1m.github.io
let iframe = document.createElement("iframe");
iframe.src = "https://nt1m.github.io/review-comments-viewer/";
iframe.onload = function() {
iframe.contentWindow.postMessage({ origin: window.location.origin }, "https://nt1m.github.io");
window.addEventListener("message", function(e) {
if (e.data.file) {
tabManager.open({
path: "/" + e.data.file,
active: true,
focus: true,
document: {
ace: {
jump: {
row: e.data.lineNumber - 1,
column: 0,
}
}
}
}, function(err) {
// TODO: ugly
!err && setTimeout(() =>
tabManager.open({
path: "/" + e.data.file,
document: {
ace: {
jump: {
row: e.data.lineNumber - 1,
column: 0,
}
}
}
})
, 800);
});
}
});
};
e.html.appendChild(iframe);
});
/* Don't show reviews panel by default */
if (panels.activePanels.includes("reviews")) {
plugin.deactivate("reviews");
}
/***** Register and define API *****/
plugin.freezePublicAPI({
});
register(null, {
"c9.ide.reviewcomments": plugin
});
}
});