Commit d99b5261421eaf38601af991edf5b8c2b7672456

Authored by Jailson Dias
1 parent f10f68cc

Criando página para a video conferencia e conectando-a com o servidor do jitsi

amadeus/static/js/jitsi.js 0 → 100644
... ... @@ -0,0 +1,309 @@
  1 +! function(t, e) {
  2 + "object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.JitsiMeetExternalAPI = e() : t.JitsiMeetExternalAPI = e()
  3 +}(this, function() {
  4 + return function(t) {
  5 + function e(i) {
  6 + if (n[i]) return n[i].exports;
  7 + var o = n[i] = {
  8 + exports: {},
  9 + id: i,
  10 + loaded: !1
  11 + };
  12 + return t[i].call(o.exports, o, o.exports, e), o.loaded = !0, o.exports
  13 + }
  14 + var n = {};
  15 + return e.m = t, e.c = n, e.p = "/libs/", e(0)
  16 + }([function(t, e, n) {
  17 + (function(e) {
  18 + "use strict";
  19 +
  20 + function i(t, e) {
  21 + t.send(e)
  22 + }
  23 +
  24 + function o(t, e) {
  25 + t.numberOfParticipants += e
  26 + }
  27 +
  28 + function r(t, e, n, i, o, r, s, f) {
  29 + if ((!n || n < l) && (n = l), (!i || i < h) && (i = h), this.parentNode = null, o) this.parentNode = o;
  30 + else {
  31 + var p = document.scripts[document.scripts.length - 1];
  32 + this.parentNode = p.parentNode
  33 + }
  34 + this.iframeHolder = this.parentNode.appendChild(document.createElement("div")), this.iframeHolder.id = "jitsiConference" + u, n && (this.iframeHolder.style.width = "100%"), i && (this.iframeHolder.style.height = "100%"), this.frameName = "jitsiConferenceFrame" + u, this.url = f ? "http" : "https://" + t + "/", e && (this.url += e), this.url += "#jitsi_meet_external_api_id=" + u;
  35 + var c;
  36 + if (r)
  37 + for (c in r) r.hasOwnProperty(c) && "string" == typeof c && (this.url += "&config." + c + "=" + r[c]);
  38 + if (s)
  39 + for (c in s) s.hasOwnProperty(c) && "string" == typeof c && (this.url += "&interfaceConfig." + c + "=" + s[c]);
  40 + this.frame = document.createElement("iframe"), this.frame.src = this.url, this.frame.name = this.frameName, this.frame.id = this.frameName, this.frame.width = "100%", this.frame.height = "100%", this.frame.setAttribute("allowFullScreen", "true"), this.frame = this.iframeHolder.appendChild(this.frame), this.postis = a({
  41 + window: this.frame.contentWindow,
  42 + scope: "jitsi_meet_external_api_" + u
  43 + }), this.eventHandlers = {}, this.postisListeners = {}, this.numberOfParticipants = 1, this._setupListeners(), u++
  44 + }
  45 + var s = n(3).getLogger(e),
  46 + a = n(4),
  47 + l = 790,
  48 + h = 300,
  49 + u = 0,
  50 + f = {
  51 + displayName: "display-name",
  52 + toggleAudio: "toggle-audio",
  53 + toggleVideo: "toggle-video",
  54 + toggleFilmStrip: "toggle-film-strip",
  55 + toggleChat: "toggle-chat",
  56 + toggleContactList: "toggle-contact-list",
  57 + toggleShareScreen: "toggle-share-screen",
  58 + hangup: "video-hangup",
  59 + email: "email",
  60 + avatarUrl: "avatar-url"
  61 + },
  62 + p = {
  63 + incomingMessage: "incoming-message",
  64 + outgoingMessage: "outgoing-message",
  65 + displayNameChange: "display-name-change",
  66 + participantJoined: "participant-joined",
  67 + participantLeft: "participant-left",
  68 + videoConferenceJoined: "video-conference-joined",
  69 + videoConferenceLeft: "video-conference-left",
  70 + readyToClose: "video-ready-to-close"
  71 + };
  72 + r.prototype.executeCommand = function(t) {
  73 + for (var e = arguments.length, n = Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++) n[o - 1] = arguments[o];
  74 + return t in f ? void i(this.postis, {
  75 + method: f[t],
  76 + params: n
  77 + }) : void s.error("Not supported command name.")
  78 + }, r.prototype.executeCommands = function(t) {
  79 + for (var e in t) this.executeCommand(e, t[e])
  80 + }, r.prototype.addEventListeners = function(t) {
  81 + for (var e in t) this.addEventListener(e, t[e])
  82 + }, r.prototype.addEventListener = function(t, e) {
  83 + return t in p ? (this.postisListeners[t] || (this.postis.listen(p[t], function(e) {
  84 + t in this.eventHandlers && "function" == typeof this.eventHandlers[t] && this.eventHandlers[t].call(null, e)
  85 + }.bind(this)), this.postisListeners[t] = !0), void(this.eventHandlers[t] = e)) : void s.error("Not supported event name.")
  86 + }, r.prototype.removeEventListener = function(t) {
  87 + return t in this.eventHandlers ? void delete this.eventHandlers[t] : void s.error("The event " + t + " is not registered.")
  88 + }, r.prototype.removeEventListeners = function(t) {
  89 + for (var e = 0; e < t.length; e++) this.removeEventListener(t[e])
  90 + }, r.prototype.getNumberOfParticipants = function() {
  91 + return this.numberOfParticipants
  92 + }, r.prototype._setupListeners = function() {
  93 + this.postis.listen("participant-joined", o.bind(null, this, 1)), this.postis.listen("participant-left", o.bind(null, this, -1))
  94 + }, r.prototype.dispose = function() {
  95 + this.postis.destroy();
  96 + var t = document.getElementById(this.frameName);
  97 + t && (t.src = "about:blank");
  98 + var e = this;
  99 + window.setTimeout(function() {
  100 + e.iframeHolder.removeChild(e.frame), e.iframeHolder.parentNode.removeChild(e.iframeHolder)
  101 + }, 10)
  102 + }, t.exports = r
  103 + }).call(e, "modules/API/external/external_api.js")
  104 + }, function(t, e) {
  105 + function n() {
  106 + var t = {
  107 + methodName: "",
  108 + fileLocation: "",
  109 + line: null,
  110 + column: null
  111 + },
  112 + e = new Error,
  113 + n = e.stack ? e.stack.split("\n") : [];
  114 + if (!n || n.length < 1) return t;
  115 + var i = null;
  116 + return n[3] && (i = n[3].match(/\s*at\s*(.+?)\s*\((\S*)\s*:(\d*)\s*:(\d*)\)/)), !i || i.length <= 4 ? (0 === n[2].indexOf("log@") ? t.methodName = n[3].substr(0, n[3].indexOf("@")) : t.methodName = n[2].substr(0, n[2].indexOf("@")), t) : (t.methodName = i[1], t.fileLocation = i[2], t.line = i[3], t.column = i[4], t)
  117 + }
  118 +
  119 + function i() {
  120 + var t = arguments[0],
  121 + e = arguments[1],
  122 + i = Array.prototype.slice.call(arguments, 2);
  123 + if (!(r[e] < t.level))
  124 + for (var o = n(), a = s.concat(t.transports), l = 0; l < a.length; l++) {
  125 + var h = a[l],
  126 + u = h[e];
  127 + u && "function" == typeof u && u.bind(h, t.id ? "[" + t.id + "]" : "", "<" + o.methodName + ">: ").apply(h, i)
  128 + }
  129 + }
  130 +
  131 + function o(t, e, n, o) {
  132 + this.id = e, this.format = o, this.transports = n, this.transports || (this.transports = []), this.level = r[t];
  133 + for (var s = Object.keys(r), a = 0; a < s.length; a++) this[s[a]] = i.bind(null, this, s[a])
  134 + }
  135 + var r = {
  136 + trace: 0,
  137 + debug: 1,
  138 + info: 2,
  139 + log: 3,
  140 + warn: 4,
  141 + error: 5
  142 + };
  143 + o.consoleTransport = console;
  144 + var s = [o.consoleTransport];
  145 + o.addGlobalTransport = function(t) {
  146 + s.indexOf(t) === -1 && s.push(t)
  147 + }, o.removeGlobalTransport = function(t) {
  148 + var e = s.indexOf(t);
  149 + e !== -1 && s.splice(e, 1)
  150 + }, o.prototype.setLevel = function(t) {
  151 + this.level = r[t]
  152 + }, t.exports = o, o.levels = {
  153 + TRACE: "trace",
  154 + DEBUG: "debug",
  155 + INFO: "info",
  156 + LOG: "log",
  157 + WARN: "warn",
  158 + ERROR: "error"
  159 + }
  160 + }, function(t, e, n) {
  161 + function i(t, e) {
  162 + this.logStorage = t, this.stringifyObjects = !(!e || !e.stringifyObjects) && e.stringifyObjects, this.storeInterval = e && e.storeInterval ? e.storeInterval : 3e4, this.maxEntryLength = e && e.maxEntryLength ? e.maxEntryLength : 1e4, Object.keys(o.levels).forEach(function(t) {
  163 + var e = o.levels[t];
  164 + this[e] = function(t) {
  165 + this._log.apply(this, arguments)
  166 + }.bind(this, t)
  167 + }.bind(this)), this.storeLogsIntervalID = null, this.queue = [], this.totalLen = 0, this.outputCache = []
  168 + }
  169 + var o = n(1);
  170 + i.prototype.stringify = function(t) {
  171 + try {
  172 + return JSON.stringify(t)
  173 + } catch (t) {
  174 + return "[object with circular refs?]"
  175 + }
  176 + }, i.prototype.formatLogMessage = function(t) {
  177 + for (var e = "", n = 1, i = arguments.length; n < i; n++) {
  178 + var r = arguments[n];
  179 + !this.stringifyObjects && t !== o.levels.ERROR || "object" != typeof r || (r = this.stringify(r)), e += r, n != i - 1 && (e += " ")
  180 + }
  181 + return e.length ? e : null
  182 + }, i.prototype._log = function() {
  183 + var t = this.formatLogMessage.apply(this, arguments);
  184 + if (t) {
  185 + var e = this.queue.length ? this.queue[this.queue.length - 1] : void 0,
  186 + n = "object" == typeof e ? e.text : e;
  187 + n == t ? "object" == typeof e ? e.count += 1 : this.queue[this.queue.length - 1] = {
  188 + text: t,
  189 + count: 2
  190 + } : (this.queue.push(t), this.totalLen += t.length)
  191 + }
  192 + this.totalLen >= this.maxEntryLength && this._flush(!0, !0)
  193 + }, i.prototype.start = function() {
  194 + this._reschedulePublishInterval()
  195 + }, i.prototype._reschedulePublishInterval = function() {
  196 + this.storeLogsIntervalID && (window.clearTimeout(this.storeLogsIntervalID), this.storeLogsIntervalID = null), this.storeLogsIntervalID = window.setTimeout(this._flush.bind(this, !1, !0), this.storeInterval)
  197 + }, i.prototype.flush = function() {
  198 + this._flush(!1, !0)
  199 + }, i.prototype._flush = function(t, e) {
  200 + this.totalLen > 0 && (this.logStorage.isReady() || t) && (this.logStorage.isReady() ? (this.outputCache.length && (this.outputCache.forEach(function(t) {
  201 + this.logStorage.storeLogs(t)
  202 + }.bind(this)), this.outputCache = []), this.logStorage.storeLogs(this.queue)) : this.outputCache.push(this.queue), this.queue = [], this.totalLen = 0), e && this._reschedulePublishInterval()
  203 + }, i.prototype.stop = function() {
  204 + this._flush(!1, !1)
  205 + }, t.exports = i
  206 + }, function(t, e, n) {
  207 + var i = n(1),
  208 + o = n(2),
  209 + r = {},
  210 + s = [],
  211 + a = i.levels.TRACE;
  212 + t.exports = {
  213 + addGlobalTransport: function(t) {
  214 + i.addGlobalTransport(t)
  215 + },
  216 + removeGlobalTransport: function(t) {
  217 + i.removeGlobalTransport(t)
  218 + },
  219 + getLogger: function(t, e, n) {
  220 + var o = new i(a, t, e, n);
  221 + return t ? (r[t] = r[t] || [], r[t].push(o)) : s.push(o), o
  222 + },
  223 + setLogLevelById: function(t, e) {
  224 + for (var n = e ? r[e] || [] : s, i = 0; i < n.length; i++) n[i].setLevel(t)
  225 + },
  226 + setLogLevel: function(t) {
  227 + a = t;
  228 + for (var e = 0; e < s.length; e++) s[e].setLevel(t);
  229 + for (var n in r) {
  230 + var i = r[n] || [];
  231 + for (e = 0; e < i.length; e++) i[e].setLevel(t)
  232 + }
  233 + },
  234 + levels: i.levels,
  235 + LogCollector: o
  236 + }
  237 + }, function(t, e) {
  238 + function n(t) {
  239 + var e, n = t.scope,
  240 + i = t.window,
  241 + o = t.windowForEventListening || window,
  242 + r = {},
  243 + s = [],
  244 + a = {},
  245 + l = !1,
  246 + h = "__ready__",
  247 + u = function(t) {
  248 + var e;
  249 + try {
  250 + e = JSON.parse(t.data)
  251 + } catch (t) {
  252 + return
  253 + }
  254 + if (e.postis && e.scope === n) {
  255 + var i = r[e.method];
  256 + if (i)
  257 + for (var o = 0; o < i.length; o++) i[o].call(null, e.params);
  258 + else a[e.method] = a[e.method] || [], a[e.method].push(e.params)
  259 + }
  260 + };
  261 + o.addEventListener("message", u, !1);
  262 + var f = {
  263 + listen: function(t, e) {
  264 + r[t] = r[t] || [], r[t].push(e);
  265 + var n = a[t];
  266 + if (n)
  267 + for (var i = r[t], o = 0; o < i.length; o++)
  268 + for (var s = 0; s < n.length; s++) i[o].call(null, n[s]);
  269 + delete a[t]
  270 + },
  271 + send: function(t) {
  272 + var e = t.method;
  273 + (l || t.method === h) && i && "function" == typeof i.postMessage ? i.postMessage(JSON.stringify({
  274 + postis: !0,
  275 + scope: n,
  276 + method: e,
  277 + params: t.params
  278 + }), "*") : s.push(t)
  279 + },
  280 + ready: function(t) {
  281 + l ? t() : setTimeout(function() {
  282 + f.ready(t)
  283 + }, 50)
  284 + },
  285 + destroy: function(t) {
  286 + clearInterval(e), l = !1, o && "function" == typeof o.removeEventListener && o.removeEventListener("message", u), t && t()
  287 + }
  288 + },
  289 + p = +new Date + Math.random() + "";
  290 + return e = setInterval(function() {
  291 + f.send({
  292 + method: h,
  293 + params: p
  294 + })
  295 + }, 50), f.listen(h, function(t) {
  296 + if (t === p) {
  297 + clearInterval(e), l = !0;
  298 + for (var n = 0; n < s.length; n++) f.send(s[n]);
  299 + s = []
  300 + } else f.send({
  301 + method: h,
  302 + params: t
  303 + })
  304 + }), f
  305 + }
  306 + t.exports = n
  307 + }])
  308 +});
  309 +//# sourceMappingURL=external_api.min.map
... ...
webconference/templates/webconference/jitsi.html 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +<!DOCTYPE html>
  2 +{% load static i18n %}
  3 +<html>
  4 + <head>
  5 + <meta charset="utf-8">
  6 + <title>{% trans "Web Conference" %}</title>
  7 + <script type="text/javascript" src="{% static 'js/jquery-3.1.0.min.js' %}"></script>
  8 + <!-- <script src="https://meet.jit.si/external_api.js"></script> -->
  9 + <script src="{% static 'js/jitsi.js' %}"></script>
  10 + <style>
  11 + body, html, #jitsi, iframe{
  12 + margin-left: -1px;
  13 + margin-right: 0px;
  14 + margin-top: -2px;
  15 + margin-bottom: -1px;
  16 + padding: 0px;
  17 + width: 100%;
  18 + min-height: 100%;
  19 + height: 100%;
  20 + }
  21 + </style>
  22 + </head>
  23 + <body>
  24 + <div id="jitsi">
  25 +
  26 + </div>
  27 +
  28 + <script>
  29 + // code to start jitsi api
  30 + var domain = "meet.jit.si"; // domain that jitsi will itself connect
  31 + var room = "{{name_room}}"; // name of the room to be created
  32 + var width = $("body").width(); // width of the window to be created
  33 + var height = $("body").height(); // height of the window to be created
  34 + var html = document.getElementById("jitsi");
  35 + var api = new JitsiMeetExternalAPI(domain, room, width, height,html);
  36 + </script>
  37 +
  38 + </body>
  39 +</html>
... ...
webconference/templates/webconference/view.html
... ... @@ -65,7 +65,7 @@
65 65 <!-- Button to join in web conference -->
66 66 <div class="row">
67 67 <div class="text-center">
68   - <a href="#" class="btn btn-raised btn-success">{% trans "Participate" %}</a>
  68 + <a href="{% url 'webconferences:conference' webconference.slug %}" class="btn btn-raised btn-success">{% trans "Participate" %}</a>
69 69 </div>
70 70 </div>
71 71 {% endif %}
... ...
webconference/urls.py
1 1 from django.conf.urls import url
2 2 from django.contrib.auth import views as auth_views
  3 +from django.views.generic import TemplateView
3 4  
4 5 from . import views
5 6  
... ... @@ -9,4 +10,5 @@ urlpatterns = [
9 10 url(r'^delete/(?P<slug>[\w_-]+)/$', views.DeleteView.as_view(), name = 'delete'),
10 11 url(r'^window_view/(?P<slug>[\w_-]+)/$', views.NewWindowView.as_view(), name = 'window_view'),
11 12 url(r'^view/(?P<slug>[\w_-]+)/$', views.InsideView.as_view(), name = 'view'),
  13 + url(r'^conference/(?P<slug>[\w_-]+)/$',views.Conference.as_view(), name = 'conference'),
12 14 ]
... ...
webconference/views.py
... ... @@ -65,6 +65,20 @@ class NewWindowView(LoginRequiredMixin,
65 65  
66 66 return context
67 67  
  68 +class Conference(LoginRequiredMixin,generic.TemplateView):
  69 +
  70 + login_url = reverse_lazy("users:login")
  71 + redirect_field_name = 'next'
  72 +
  73 + template_name = 'webconference/jitsi.html'
  74 +
  75 +
  76 + def get_context_data(self, **kwargs):
  77 + context = super(Conference, self).get_context_data(**kwargs)
  78 + context['name_room'] = kwargs.get('slug')
  79 + return context
  80 +
  81 +
68 82 class InsideView(LoginRequiredMixin,
69 83 # '''LogMixin,'''
70 84 generic.DetailView):
... ...