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(){
|
||||
|
||||
var whiteboardId = getQueryVariable("whiteboardid");
|
||||
var randomid = getQueryVariable("randomid");
|
||||
if (randomid && !whiteboardId) { //set random whiteboard on empty whiteboardid
|
||||
var whiteboardId = getQueryVariable("whiteboardid");
|
||||
var randomid = getQueryVariable("randomid");
|
||||
if (randomid && !whiteboardId) { //set random whiteboard on empty whiteboardid
|
||||
whiteboardId = Array(2).fill(null).map(() => Math.random().toString(36).substr(2)).join('');
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
urlParams.set('whiteboardid', whiteboardId);
|
||||
window.location.search = urlParams;
|
||||
}
|
||||
}
|
||||
|
||||
whiteboardId = whiteboardId || "myNewWhiteboard";
|
||||
whiteboardId = unescape(encodeURIComponent(whiteboardId)).replace(/[^a-zA-Z0-9 ]/g, "");
|
||||
var myUsername = getQueryVariable("username");
|
||||
var accessToken = getQueryVariable("accesstoken");
|
||||
myUsername = myUsername || "unknown" + (Math.random() + "").substring(2, 6);
|
||||
accessToken = accessToken || "";
|
||||
var accessDenied = false;
|
||||
whiteboardId = whiteboardId || "myNewWhiteboard";
|
||||
whiteboardId = unescape(encodeURIComponent(whiteboardId)).replace(/[^a-zA-Z0-9 ]/g, "");
|
||||
var myUsername = getQueryVariable("username");
|
||||
var accessToken = getQueryVariable("accesstoken");
|
||||
myUsername = myUsername || "unknown" + (Math.random() + "").substring(2, 6);
|
||||
accessToken = accessToken || "";
|
||||
var accessDenied = false;
|
||||
|
||||
// Custom Html Title
|
||||
var title = getQueryVariable("title");
|
||||
if (!title === false) {
|
||||
// Custom Html Title
|
||||
var title = getQueryVariable("title");
|
||||
if (!title === false) {
|
||||
document.title = decodeURIComponent(title);
|
||||
}
|
||||
}
|
||||
|
||||
var url = document.URL.substr(0, document.URL.lastIndexOf('/'));
|
||||
var signaling_socket = null;
|
||||
var urlSplit = url.split("/");
|
||||
var subdir = "";
|
||||
for (var i = 3; i < urlSplit.length; i++) {
|
||||
var url = document.URL.substr(0, document.URL.lastIndexOf('/'));
|
||||
var signaling_socket = null;
|
||||
var urlSplit = url.split("/");
|
||||
var subdir = "";
|
||||
for (var i = 3; i < urlSplit.length; 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!");
|
||||
|
||||
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() } });
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(function () {
|
||||
if (getQueryVariable("webdav") == "true") {
|
||||
$("#uploadWebDavBtn").show();
|
||||
}
|
||||
@ -517,19 +517,19 @@ $(document).ready(function () {
|
||||
whiteboard.setDrawColor(color.rgbaString);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//Prevent site from changing tab on drag&drop
|
||||
window.addEventListener("dragover", function (e) {
|
||||
//Prevent site from changing tab on drag&drop
|
||||
window.addEventListener("dragover", function (e) {
|
||||
e = e || event;
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
window.addEventListener("drop", function (e) {
|
||||
}, false);
|
||||
window.addEventListener("drop", function (e) {
|
||||
e = e || event;
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
}, false);
|
||||
|
||||
function uploadImgAndAddToWhiteboard(base64data) {
|
||||
function uploadImgAndAddToWhiteboard(base64data) {
|
||||
var date = (+new Date());
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -549,9 +549,9 @@ function uploadImgAndAddToWhiteboard(base64data) {
|
||||
showBasicAlert("Failed to upload frame: " + JSON.stringify(err));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function saveWhiteboardToWebdav(base64data, webdavaccess, callback) {
|
||||
function saveWhiteboardToWebdav(base64data, webdavaccess, callback) {
|
||||
var date = (+new Date());
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -579,17 +579,17 @@ function saveWhiteboardToWebdav(base64data, webdavaccess, callback) {
|
||||
callback(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// verify if filename refers to an image
|
||||
function isImageFileName(filename) {
|
||||
// verify if filename refers to an image
|
||||
function isImageFileName(filename) {
|
||||
var extension = filename.split(".")[filename.split(".").length - 1];
|
||||
var known_extensions = ["png", "jpg", "jpeg", "gif", "tiff", "bmp", "webp"];
|
||||
return known_extensions.includes(extension.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
// verify if given url is url to an image
|
||||
function isValidImageUrl(url, callback) {
|
||||
// verify if given url is url to an image
|
||||
function isValidImageUrl(url, callback) {
|
||||
var img = new Image();
|
||||
var timer = null;
|
||||
img.onerror = img.onabort = function () {
|
||||
@ -604,10 +604,10 @@ function isValidImageUrl(url, callback) {
|
||||
callback(false);
|
||||
}, 2000);
|
||||
img.src = url;
|
||||
}
|
||||
}
|
||||
|
||||
// handle pasting from clipboard
|
||||
window.addEventListener("paste", function (e) {
|
||||
// handle pasting from clipboard
|
||||
window.addEventListener("paste", function (e) {
|
||||
if ($(".basicalert").length > 0) {
|
||||
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)");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showBasicAlert(html, newOptions) {
|
||||
function showBasicAlert(html, newOptions) {
|
||||
var options = {
|
||||
header: "INFO MESSAGE",
|
||||
okBtnText: "Ok",
|
||||
@ -668,10 +668,10 @@ function showBasicAlert(html, newOptions) {
|
||||
alertHtml.find(".okbtn").click();
|
||||
}, 1000 * options.hideAfter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get 'GET' parameter by variable name
|
||||
function getQueryVariable(variable) {
|
||||
// get 'GET' parameter by variable name
|
||||
function getQueryVariable(variable) {
|
||||
var query = window.location.search.substring(1);
|
||||
var vars = query.split("&");
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
@ -681,7 +681,7 @@ function getQueryVariable(variable) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user