style(main.js): indented because in function now
This commit is contained in:
parent
99378c276b
commit
dcc5191a3c
@ -6,39 +6,39 @@ import Picker from "vanilla-picker";
|
|||||||
|
|
||||||
function main(){
|
function main(){
|
||||||
|
|
||||||
var whiteboardId = getQueryVariable("whiteboardid");
|
var whiteboardId = getQueryVariable("whiteboardid");
|
||||||
var randomid = getQueryVariable("randomid");
|
var randomid = getQueryVariable("randomid");
|
||||||
if (randomid && !whiteboardId) { //set random whiteboard on empty whiteboardid
|
if (randomid && !whiteboardId) { //set random whiteboard on empty whiteboardid
|
||||||
whiteboardId = Array(2).fill(null).map(() => Math.random().toString(36).substr(2)).join('');
|
whiteboardId = Array(2).fill(null).map(() => Math.random().toString(36).substr(2)).join('');
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
urlParams.set('whiteboardid', whiteboardId);
|
urlParams.set('whiteboardid', whiteboardId);
|
||||||
window.location.search = urlParams;
|
window.location.search = urlParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
whiteboardId = whiteboardId || "myNewWhiteboard";
|
whiteboardId = whiteboardId || "myNewWhiteboard";
|
||||||
whiteboardId = unescape(encodeURIComponent(whiteboardId)).replace(/[^a-zA-Z0-9 ]/g, "");
|
whiteboardId = unescape(encodeURIComponent(whiteboardId)).replace(/[^a-zA-Z0-9 ]/g, "");
|
||||||
var myUsername = getQueryVariable("username");
|
var myUsername = getQueryVariable("username");
|
||||||
var accessToken = getQueryVariable("accesstoken");
|
var accessToken = getQueryVariable("accesstoken");
|
||||||
myUsername = myUsername || "unknown" + (Math.random() + "").substring(2, 6);
|
myUsername = myUsername || "unknown" + (Math.random() + "").substring(2, 6);
|
||||||
accessToken = accessToken || "";
|
accessToken = accessToken || "";
|
||||||
var accessDenied = false;
|
var accessDenied = false;
|
||||||
|
|
||||||
// Custom Html Title
|
// Custom Html Title
|
||||||
var title = getQueryVariable("title");
|
var title = getQueryVariable("title");
|
||||||
if (!title === false) {
|
if (!title === false) {
|
||||||
document.title = decodeURIComponent(title);
|
document.title = decodeURIComponent(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = document.URL.substr(0, document.URL.lastIndexOf('/'));
|
var url = document.URL.substr(0, document.URL.lastIndexOf('/'));
|
||||||
var signaling_socket = null;
|
var signaling_socket = null;
|
||||||
var urlSplit = url.split("/");
|
var urlSplit = url.split("/");
|
||||||
var subdir = "";
|
var subdir = "";
|
||||||
for (var i = 3; i < urlSplit.length; i++) {
|
for (var i = 3; i < urlSplit.length; i++) {
|
||||||
subdir = subdir + '/' + urlSplit[i];
|
subdir = subdir + '/' + urlSplit[i];
|
||||||
}
|
}
|
||||||
signaling_socket = io("", { "path": subdir + "/ws-api" }); // Connect even if we are in a subdir behind a reverse proxy
|
signaling_socket = io("", { "path": subdir + "/ws-api" }); // Connect even if we are in a subdir behind a reverse proxy
|
||||||
|
|
||||||
signaling_socket.on('connect', function () {
|
signaling_socket.on('connect', function () {
|
||||||
console.log("Websocket connected!");
|
console.log("Websocket connected!");
|
||||||
|
|
||||||
signaling_socket.on('drawToWhiteboard', function (content) {
|
signaling_socket.on('drawToWhiteboard', function (content) {
|
||||||
@ -61,9 +61,9 @@ signaling_socket.on('connect', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
signaling_socket.emit('joinWhiteboard', { wid: whiteboardId, at: accessToken, windowWidthHeight: { w: $(window).width(), h: $(window).height() } });
|
signaling_socket.emit('joinWhiteboard', { wid: whiteboardId, at: accessToken, windowWidthHeight: { w: $(window).width(), h: $(window).height() } });
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
if (getQueryVariable("webdav") == "true") {
|
if (getQueryVariable("webdav") == "true") {
|
||||||
$("#uploadWebDavBtn").show();
|
$("#uploadWebDavBtn").show();
|
||||||
}
|
}
|
||||||
@ -517,19 +517,19 @@ $(document).ready(function () {
|
|||||||
whiteboard.setDrawColor(color.rgbaString);
|
whiteboard.setDrawColor(color.rgbaString);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Prevent site from changing tab on drag&drop
|
//Prevent site from changing tab on drag&drop
|
||||||
window.addEventListener("dragover", function (e) {
|
window.addEventListener("dragover", function (e) {
|
||||||
e = e || event;
|
e = e || event;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}, false);
|
}, false);
|
||||||
window.addEventListener("drop", function (e) {
|
window.addEventListener("drop", function (e) {
|
||||||
e = e || event;
|
e = e || event;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
function uploadImgAndAddToWhiteboard(base64data) {
|
function uploadImgAndAddToWhiteboard(base64data) {
|
||||||
var date = (+new Date());
|
var date = (+new Date());
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -549,9 +549,9 @@ function uploadImgAndAddToWhiteboard(base64data) {
|
|||||||
showBasicAlert("Failed to upload frame: " + JSON.stringify(err));
|
showBasicAlert("Failed to upload frame: " + JSON.stringify(err));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveWhiteboardToWebdav(base64data, webdavaccess, callback) {
|
function saveWhiteboardToWebdav(base64data, webdavaccess, callback) {
|
||||||
var date = (+new Date());
|
var date = (+new Date());
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
@ -579,17 +579,17 @@ function saveWhiteboardToWebdav(base64data, webdavaccess, callback) {
|
|||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify if filename refers to an image
|
// verify if filename refers to an image
|
||||||
function isImageFileName(filename) {
|
function isImageFileName(filename) {
|
||||||
var extension = filename.split(".")[filename.split(".").length - 1];
|
var extension = filename.split(".")[filename.split(".").length - 1];
|
||||||
var known_extensions = ["png", "jpg", "jpeg", "gif", "tiff", "bmp", "webp"];
|
var known_extensions = ["png", "jpg", "jpeg", "gif", "tiff", "bmp", "webp"];
|
||||||
return known_extensions.includes(extension.toLowerCase());
|
return known_extensions.includes(extension.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify if given url is url to an image
|
// verify if given url is url to an image
|
||||||
function isValidImageUrl(url, callback) {
|
function isValidImageUrl(url, callback) {
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
var timer = null;
|
var timer = null;
|
||||||
img.onerror = img.onabort = function () {
|
img.onerror = img.onabort = function () {
|
||||||
@ -604,10 +604,10 @@ function isValidImageUrl(url, callback) {
|
|||||||
callback(false);
|
callback(false);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
img.src = url;
|
img.src = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle pasting from clipboard
|
// handle pasting from clipboard
|
||||||
window.addEventListener("paste", function (e) {
|
window.addEventListener("paste", function (e) {
|
||||||
if ($(".basicalert").length > 0) {
|
if ($(".basicalert").length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -637,9 +637,9 @@ window.addEventListener("paste", function (e) {
|
|||||||
showBasicAlert("Please Drag&Drop the image into the Whiteboard. (Browsers don't allow copy+past from the filesystem directly)");
|
showBasicAlert("Please Drag&Drop the image into the Whiteboard. (Browsers don't allow copy+past from the filesystem directly)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function showBasicAlert(html, newOptions) {
|
function showBasicAlert(html, newOptions) {
|
||||||
var options = {
|
var options = {
|
||||||
header: "INFO MESSAGE",
|
header: "INFO MESSAGE",
|
||||||
okBtnText: "Ok",
|
okBtnText: "Ok",
|
||||||
@ -668,10 +668,10 @@ function showBasicAlert(html, newOptions) {
|
|||||||
alertHtml.find(".okbtn").click();
|
alertHtml.find(".okbtn").click();
|
||||||
}, 1000 * options.hideAfter)
|
}, 1000 * options.hideAfter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get 'GET' parameter by variable name
|
// get 'GET' parameter by variable name
|
||||||
function getQueryVariable(variable) {
|
function getQueryVariable(variable) {
|
||||||
var query = window.location.search.substring(1);
|
var query = window.location.search.substring(1);
|
||||||
var vars = query.split("&");
|
var vars = query.split("&");
|
||||||
for (var i = 0; i < vars.length; i++) {
|
for (var i = 0; i < vars.length; i++) {
|
||||||
@ -681,7 +681,7 @@ function getQueryVariable(variable) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user