forked from codetainerapp/codetainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codetainer.js
61 lines (44 loc) · 1.4 KB
/
codetainer.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
(function ($) {
function Codetainer(element, options) {
var self = this;
self.options = options;
self.$element = $(element);
if (self.$element.data("url") !== undefined) {
options.host = self.$element.data("url");
}
if (self.$element.data("container") !== undefined) {
options.container = self.$element.data("container");
}
return self;
};
Codetainer.prototype.Build = function() {
var self = this;
var url = self.options.url + "/api/v1/codetainer/" +
self.options.container + "/view";
if (self.options.terminalOnly) {
url += "?terminal-only=1";
}
var iframe = "<iframe height='" + self.options.height + "'"+
"width='" + self.options.width + "' title='Codetainer' scrolling='no' " +
"frameborder='0' allowfullscreen='true' " +
"allowtransparency='true' " +
"src='"+url+"'>" +
"style='box-shadow: 0px 0px 6px rgba(214,214,214,0.87);' " +
"</iframe>";
self.$element.html(iframe);
};
$.fn.codetainer = function(options) {
// This is the easiest way to have default options.
var settings = $.extend({
url: "https://localhost:3000",
width: "700px",
height: "400px"
}, options);
$(this.selector).each(function(i, el) {
var ct = new Codetainer(el, settings);
$.data(el, "codetainer", ct);
ct.Build();
});
return this;
};
}(jQuery));