From aac7c92b39aac59a5bf335035761444b546d9c56 Mon Sep 17 00:00:00 2001
From: hristoterezov <hristo@jitsi.org>
Date: Fri, 14 Jul 2017 16:24:30 -0500
Subject: [PATCH] feat(alwaysontop):Implement

---
 README.md                     |  3 +-
 config.js                     |  4 +--
 windows/jitsi-meet/index.html |  5 ----
 windows/jitsi-meet/render.js  | 55 ++++++++++++++++-------------------
 4 files changed, 28 insertions(+), 39 deletions(-)

diff --git a/README.md b/README.md
index 3eb11e4..2ba1359 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,7 @@ Jitsi Meet Electron
 Electron application for [Jitsi Meet](https://github.com/jitsi/jitsi-meet).
 
 ## Configuration
-You can change the Jitsi Meet deployment url with the jitsiMeetURL property
-from config.js
+You can change the Jitsi Meet deployment domain with the jitsiMeetDomain property from config.js
 
 ## Building the sources
 ```bash
diff --git a/config.js b/config.js
index f48850b..84df4b0 100644
--- a/config.js
+++ b/config.js
@@ -1,6 +1,6 @@
 module.exports = {
     /**
-     * The URL of the Jitsi Meet deployment that will be used.
+     * The domain of the Jitsi Meet deployment that will be used.
      */
-    jitsiMeetURL: "https://meet.jit.si/"
+    jitsiMeetDomain: "meet.jit.si"
 };
diff --git a/windows/jitsi-meet/index.html b/windows/jitsi-meet/index.html
index 5572fe0..65c6915 100644
--- a/windows/jitsi-meet/index.html
+++ b/windows/jitsi-meet/index.html
@@ -10,11 +10,6 @@
             body {
                 -webkit-app-region: drag
             }
-            iframe {
-                width: 100%;
-                height: 100%;
-                border: 0 none;
-            }
         </style>
     </head>
     <body>
diff --git a/windows/jitsi-meet/render.js b/windows/jitsi-meet/render.js
index 0a5284c..4ce648f 100644
--- a/windows/jitsi-meet/render.js
+++ b/windows/jitsi-meet/render.js
@@ -1,40 +1,35 @@
-/* global process */
-const utils = require("jitsi-meet-electron-utils");
+/* global process, JitsiMeetExternalAPI */
 const {
     RemoteControl,
     setupScreenSharingForWindow
-} = utils;
-const config = require("../../config.js");
+} = require("jitsi-meet-electron-utils");
+const { jitsiMeetDomain } = require("../../config.js");
 
 /**
- * The remote control instance.
+ * Loads a script from a specific source.
+ *
+ * @param src the source from the which the script is to be (down)loaded
+ * @param loadCallback on load callback function
+ * @param errorCallback callback to be called on error loading the script
  */
-let remoteControl;
+function loadScript(
+        src,
+        loadCallback = () => {},
+        errorCallback = console.error) {
+    const script = document.createElement('script');
 
-/**
- * Cteates the iframe that will load Jitsi Meet.
- */
-let iframe = document.createElement('iframe');
-iframe.src = process.env.JITSI_MEET_URL || config.jitsiMeetURL;
-iframe.allowFullscreen = true;
-iframe.onload = onload;
-document.body.appendChild(iframe);
+    script.async = true;
 
-/**
- * Handles loaded event for iframe:
- * Enables screen sharing functionality to the iframe webpage.
- * Initializes postis.
- * Initializes remote control.
- */
-function onload() {
-    setupScreenSharingForWindow(iframe.contentWindow);
-    iframe.contentWindow.onunload = onunload;
-    remoteControl = new RemoteControl(iframe);
+    script.onload = loadCallback;
+    script.onerror = errorCallback;
+    script.src = src;
+    document.head.appendChild(script);
 }
 
-/**
- * Clears the postis objects and remoteControl.
- */
-function onunload() {
-    remoteControl.dispose();
-}
+loadScript(`https://${jitsiMeetDomain}/external_api.js`, () => {
+    const api = new JitsiMeetExternalAPI(
+        process.env.JITSI_MEET_DOMAIN || jitsiMeetDomain);
+    const iframe = api.getIFrame();
+    setupScreenSharingForWindow(iframe);
+    new RemoteControl(iframe);
+});
-- 
GitLab