This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
conclave-transpiled.js
103 lines (79 loc) · 5.23 KB
/
conclave-transpiled.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _peerjs_fork_firefox = require('peerjs_fork_firefox40');
var _peerjs_fork_firefox2 = _interopRequireDefault(_peerjs_fork_firefox);
var _simplemde = require('simplemde');
var _simplemde2 = _interopRequireDefault(_simplemde);
var _jquery = require('jquery');
var _jquery2 = _interopRequireDefault(_jquery);
var _controller = require('./build/controller');
var _controller2 = _interopRequireDefault(_controller);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Conclave = function () {
function Conclave(options) {
_classCallCheck(this, Conclave);
var defaults = {
peerId: null,
peer: null,
shareLink: true,
icons: true,
video: true,
changeUrl: true,
errorMessage: true,
showPeers: true,
peersLeft: true,
placeholder: 'Share the link to invite collaborators to your room'
};
options = Object.assign(defaults, options);
this.generateConclaveEditor(options);
this.initializeController(options);
}
_createClass(Conclave, [{
key: 'generateConclaveEditor',
value: function generateConclaveEditor(options) {
var editorHTMLStr = '<div class="text-wrapper">\n <div id="peerId">\n <p class=\'no-margin-bottom\'>Peers:</p>\n </div>\n <div class="editor">\n <div class="header">\n <div class="peer-toggle show"></div>\n <p class=\'share-link hide\'>\n <a id=\'myLink\' target="_blank">Public Share Link</a>\n <span id="myLinkInput" class="disappear aside"></span>\n <span class="copy-container" data-tooltip="Copy to Clipboard"></span>\n <span class="copy-status">Copied!</span>\n </p>\n <div class="buttons">\n <button id="download" type="button">Save</button>\n <label id="upload" for="file">Upload</label>\n <input id="file" type="file" accept=".txt, .js, .rb, .md, .pug, .py"/>\n </div>\n </div>\n <div class="textarea">\n <textarea row="10" col="20"></textarea>\n </div>\n </div>\n </div>\n <div class="video-modal hide">\n <div class="video-bar"></div>\n <div class="video-container">\n <video></video>\n </div>\n </div>';
var $editor = (0, _jquery2.default)(editorHTMLStr);
(0, _jquery2.default)('#conclave').append($editor).addClass('hide');
if (options.shareLink) (0, _jquery2.default)('.share-link').removeClass('hide');
if (!options.peersLeft) (0, _jquery2.default)('.text-wrapper').addClass('reverse');
if (!options.showPeers) (0, _jquery2.default)('#peerId').addClass('disappear');
}
}, {
key: 'initializeController',
value: function initializeController(options) {
var peerOptions = [{
host: 'conclavepeerjs.herokuapp.com',
port: 443,
secure: true,
config: { 'iceServers': [{ url: 'stun:stun1.l.google.com:19302' }, { url: 'turn:numb.viagenie.ca',
credential: 'conclave-rulez',
username: '[email protected]'
}]
},
debug: 1
}];
if (options.peerId) peerOptions.unshift(options.peerId);
var peer = options.peer || new (Function.prototype.bind.apply(_peerjs_fork_firefox2.default, [null].concat(peerOptions)))();
var locale = !!location.origin.match(/file:\/\//) ? location.href.split('?')[0] : location.origin;
this.controller = new _controller2.default(location.search.slice(1) || '0', locale, peer, new _simplemde2.default({
placeholder: options.placeholder,
spellChecker: false,
toolbar: false,
autofocus: false,
indentWithTabs: true,
status: false,
tabSize: 4,
indentUnit: 4,
lineWrapping: false,
shortCuts: []
}), options);
this.controller.init();
}
}]);
return Conclave;
}();
exports.default = Conclave;