2018-02-08 23:38:41 +01:00
|
|
|
var whiteboardId = getQueryVariable("whiteboardid");
|
|
|
|
whiteboardId = whiteboardId || "myNewWhiteboard";
|
|
|
|
var myUsername = getQueryVariable("username");
|
2019-02-11 12:43:23 +01:00
|
|
|
var accessToken = getQueryVariable("accesstoken");
|
2018-09-08 19:15:23 +02:00
|
|
|
myUsername = myUsername || "unknown" + (Math.random() + "").substring(2, 6);
|
2019-02-11 12:43:23 +01:00
|
|
|
accessToken = accessToken || "";
|
2019-06-02 17:40:20 +02:00
|
|
|
var accessDenied = false;
|
2018-02-08 17:45:07 +01:00
|
|
|
|
2018-09-08 19:15:23 +02:00
|
|
|
var url = document.URL.substr(0, document.URL.lastIndexOf('/'));
|
2018-02-09 00:45:10 +01:00
|
|
|
var signaling_socket = null;
|
|
|
|
var urlSplit = url.split("/");
|
|
|
|
var subdir = "";
|
2018-09-08 19:15:23 +02:00
|
|
|
for (var i = 3; i < urlSplit.length; i++) {
|
|
|
|
subdir = subdir + '/' + urlSplit[i];
|
2018-02-09 00:45:10 +01:00
|
|
|
}
|
2018-09-08 19:15:23 +02:00
|
|
|
if (subdir != "") {
|
|
|
|
signaling_socket = io("", { "path": subdir + "/socket.io" }); //Connect even if we are in a subdir behind a reverse proxy
|
2018-02-09 00:45:10 +01:00
|
|
|
} else {
|
|
|
|
signaling_socket = io();
|
|
|
|
}
|
|
|
|
|
|
|
|
signaling_socket.on('connect', function () {
|
2018-09-08 19:15:23 +02:00
|
|
|
console.log("Websocket connected!");
|
2018-02-08 17:45:07 +01:00
|
|
|
|
|
|
|
signaling_socket.on('drawToWhiteboard', function (content) {
|
|
|
|
whiteboard.handleEventsAndData(content, true);
|
|
|
|
});
|
2018-02-08 23:38:41 +01:00
|
|
|
|
|
|
|
signaling_socket.on('refreshUserBadges', function () {
|
|
|
|
whiteboard.refreshUserBadges();
|
|
|
|
});
|
2018-02-09 02:04:50 +01:00
|
|
|
|
2019-02-11 12:43:23 +01:00
|
|
|
signaling_socket.on('wrongAccessToken', function () {
|
2019-06-02 17:40:20 +02:00
|
|
|
if(!accessDenied) {
|
|
|
|
accessDenied = true;
|
|
|
|
showBasicAlert("Access denied! Wrong accessToken!")
|
|
|
|
}
|
2019-02-11 12:43:23 +01:00
|
|
|
});
|
|
|
|
|
2019-05-07 08:36:42 +02:00
|
|
|
signaling_socket.on('updateSmallestScreenResolution', function (widthHeight) {
|
|
|
|
whiteboard.updateSmallestScreenResolution(widthHeight["w"], widthHeight["h"]);
|
|
|
|
});
|
|
|
|
|
|
|
|
signaling_socket.emit('joinWhiteboard', { wid: whiteboardId, at: accessToken, windowWidthHeight: { w: $(window).width(), h: $(window).height() } });
|
2018-02-08 17:45:07 +01:00
|
|
|
});
|
|
|
|
|
2018-09-08 19:15:23 +02:00
|
|
|
$(document).ready(function () {
|
|
|
|
whiteboard.loadWhiteboard("#whiteboardContainer", { //Load the whiteboard
|
|
|
|
whiteboardId: whiteboardId,
|
|
|
|
username: myUsername,
|
|
|
|
sendFunction: function (content) {
|
2019-02-11 12:43:23 +01:00
|
|
|
content["at"] = accessToken;
|
2018-09-08 19:15:23 +02:00
|
|
|
signaling_socket.emit('drawToWhiteboard', content);
|
2018-02-08 17:45:07 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// request whiteboard from server
|
2019-04-05 14:56:09 +02:00
|
|
|
$.get(subdir + "/loadwhiteboard", { wid: whiteboardId, at: accessToken }).done(function (data) {
|
2018-02-08 17:45:07 +01:00
|
|
|
whiteboard.loadData(data)
|
|
|
|
});
|
2018-02-08 20:04:13 +01:00
|
|
|
|
2019-05-07 08:36:42 +02:00
|
|
|
$(window).resize(function () {
|
|
|
|
signaling_socket.emit('updateScreenResolution', { at: accessToken, windowWidthHeight: { w: $(window).width(), h: $(window).height() } });
|
|
|
|
})
|
|
|
|
|
2018-02-08 20:04:13 +01:00
|
|
|
/*----------------/
|
|
|
|
Whiteboard actions
|
|
|
|
/----------------*/
|
|
|
|
|
2019-02-22 13:14:34 +01:00
|
|
|
//Handle key actions
|
|
|
|
$(document).on("keydown", function (e) {
|
|
|
|
if (e.which == 17) {
|
|
|
|
whiteboard.pressedKeys["strg"] = true;
|
|
|
|
} else if (e.which == 90) { //z key
|
|
|
|
if (whiteboard.pressedKeys["strg"] && !whiteboard.pressedKeys["z"]) {
|
|
|
|
whiteboard.undoWhiteboardClick();
|
|
|
|
}
|
|
|
|
whiteboard.pressedKeys["z"] = true;
|
|
|
|
} else if (e.which == 16) {
|
|
|
|
whiteboard.pressedKeys["shift"] = true; //Used for straight lines...
|
|
|
|
} else if (e.which == 27) { //Esc
|
|
|
|
whiteboard.escKeyAction();
|
|
|
|
} else if (e.which == 46) { //Remove / Entf
|
|
|
|
whiteboard.entfKeyAction();
|
|
|
|
}
|
|
|
|
//console.log(e.which);
|
|
|
|
});
|
|
|
|
$(document).on("keyup", function (e) {
|
|
|
|
if (e.which == 17) {
|
|
|
|
whiteboard.pressedKeys["strg"] = false;
|
|
|
|
} else if (e.which == 90) {
|
|
|
|
whiteboard.pressedKeys["z"] = false;
|
|
|
|
} else if (e.which == 16) {
|
|
|
|
whiteboard.pressedKeys["shift"] = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// whiteboard clear button
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#whiteboardTrashBtn").click(function () {
|
2019-02-11 14:09:21 +01:00
|
|
|
$("#whiteboardTrashBtnConfirm").show().focus();
|
|
|
|
});
|
|
|
|
|
2019-04-05 14:56:09 +02:00
|
|
|
$("#whiteboardTrashBtnConfirm").focusout(function () {
|
2019-02-11 14:09:21 +01:00
|
|
|
$(this).hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#whiteboardTrashBtnConfirm").click(function () {
|
|
|
|
$(this).hide();
|
2018-09-08 19:15:23 +02:00
|
|
|
whiteboard.clearWhiteboard();
|
2018-02-08 20:04:13 +01:00
|
|
|
});
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// undo button
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#whiteboardUndoBtn").click(function () {
|
|
|
|
whiteboard.undoWhiteboardClick();
|
2018-02-08 20:04:13 +01:00
|
|
|
});
|
2018-09-08 19:15:23 +02:00
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// switch tool
|
2018-09-08 19:15:23 +02:00
|
|
|
$(".whiteboardTool").click(function () {
|
2018-02-08 20:04:13 +01:00
|
|
|
$(".whiteboardTool").removeClass("active");
|
|
|
|
$(this).addClass("active");
|
2019-02-05 13:51:59 +01:00
|
|
|
var activeTool = $(this).attr("tool");
|
|
|
|
whiteboard.setTool(activeTool);
|
2019-04-05 14:56:09 +02:00
|
|
|
if (activeTool == "mouse" || activeTool == "recSelect") {
|
2019-02-05 13:51:59 +01:00
|
|
|
$(".activeToolIcon").empty();
|
|
|
|
} else {
|
|
|
|
$(".activeToolIcon").html($(this).html()); //Set Active icon the same as the button icon
|
2019-04-05 14:56:09 +02:00
|
|
|
}
|
2018-02-08 20:04:13 +01:00
|
|
|
});
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// upload image button
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#addImgToCanvasBtn").click(function () {
|
2019-06-02 17:26:26 +02:00
|
|
|
showBasicAlert("Please drag the image into the browser.");
|
2018-02-08 20:04:13 +01:00
|
|
|
});
|
|
|
|
|
2019-05-07 08:36:42 +02:00
|
|
|
// save image as png
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#saveAsImageBtn").click(function () {
|
|
|
|
var imgData = whiteboard.getImageDataBase64();
|
2019-04-05 14:56:09 +02:00
|
|
|
|
|
|
|
var w = window.open('about:blank'); //Firefox will not allow downloads without extra window
|
|
|
|
setTimeout(function () { //FireFox seems to require a setTimeout for this to work.
|
|
|
|
var a = document.createElement('a');
|
|
|
|
a.href = imgData;
|
|
|
|
a.download = 'whiteboard.png';
|
|
|
|
w.document.body.appendChild(a);
|
|
|
|
a.click();
|
|
|
|
w.document.body.removeChild(a);
|
|
|
|
setTimeout(function () { w.close(); }, 100);
|
|
|
|
}, 0);
|
2018-02-08 20:04:13 +01:00
|
|
|
});
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// save image to json containing steps
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#saveAsJSONBtn").click(function () {
|
|
|
|
var imgData = whiteboard.getImageDataJson();
|
2019-04-05 14:56:09 +02:00
|
|
|
|
|
|
|
var w = window.open('about:blank'); //Firefox will not allow downloads without extra window
|
|
|
|
setTimeout(function () { //FireFox seems to require a setTimeout for this to work.
|
|
|
|
var a = document.createElement('a');
|
|
|
|
a.href = window.URL.createObjectURL(new Blob([imgData], { type: 'text/json' }));
|
|
|
|
a.download = 'whiteboard.json';
|
|
|
|
w.document.body.appendChild(a);
|
|
|
|
a.click();
|
|
|
|
w.document.body.removeChild(a);
|
|
|
|
setTimeout(function () { w.close(); }, 100);
|
|
|
|
}, 0);
|
2018-09-08 19:15:23 +02:00
|
|
|
});
|
2018-02-08 23:25:57 +01:00
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// upload json containing steps
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#uploadJsonBtn").click(function () {
|
|
|
|
$("#myFile").click();
|
2018-02-08 23:25:57 +01:00
|
|
|
});
|
2019-04-05 14:56:09 +02:00
|
|
|
|
2019-03-04 19:50:38 +01:00
|
|
|
$("#shareWhiteboardBtn").click(function () {
|
|
|
|
var url = window.location.href;
|
2019-04-05 14:56:09 +02:00
|
|
|
var s = url.indexOf("&username=") !== -1 ? "&username=" : "username="; //Remove username from url
|
2019-03-04 19:50:38 +01:00
|
|
|
var urlSlpit = url.split(s);
|
|
|
|
var urlStart = urlSlpit[0];
|
2019-04-05 14:56:09 +02:00
|
|
|
if (urlSlpit.length > 1) {
|
2019-03-04 19:50:38 +01:00
|
|
|
var endSplit = urlSlpit[1].split("&");
|
|
|
|
endSplit = endSplit.splice(1, 1);
|
2019-04-05 14:56:09 +02:00
|
|
|
urlStart += "&" + endSplit.join("&");
|
2019-03-04 19:50:38 +01:00
|
|
|
}
|
|
|
|
$("<textarea/>").appendTo("body").val(urlStart).select().each(function () {
|
|
|
|
document.execCommand('copy');
|
|
|
|
}).remove();
|
2019-06-02 17:26:26 +02:00
|
|
|
showBasicAlert("Copied Whiteboard-URL to clipboard.")
|
2019-03-04 19:50:38 +01:00
|
|
|
});
|
2018-02-08 23:25:57 +01:00
|
|
|
|
2019-05-13 11:39:33 +02:00
|
|
|
var btnsMini = false;
|
2019-06-02 16:49:48 +02:00
|
|
|
$("#minMaxBtn").click(function () {
|
|
|
|
if (!btnsMini) {
|
2019-05-13 11:39:33 +02:00
|
|
|
$("#toolbar").find(".btn-group:not(.minGroup)").hide();
|
|
|
|
$(this).find("#minBtn").hide();
|
|
|
|
$(this).find("#maxBtn").show();
|
|
|
|
} else {
|
|
|
|
$("#toolbar").find(".btn-group").show();
|
|
|
|
$(this).find("#minBtn").show();
|
|
|
|
$(this).find("#maxBtn").hide();
|
|
|
|
}
|
|
|
|
btnsMini = !btnsMini;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// load json to whiteboard
|
2018-09-08 19:15:23 +02:00
|
|
|
$("#myFile").on("change", function () {
|
|
|
|
var file = document.getElementById("myFile").files[0];
|
|
|
|
var reader = new FileReader();
|
|
|
|
reader.onload = function (e) {
|
|
|
|
try {
|
|
|
|
var j = JSON.parse(e.target.result);
|
|
|
|
whiteboard.loadJsonData(j);
|
|
|
|
} catch (e) {
|
2019-06-02 17:26:26 +02:00
|
|
|
showBasicAlert("File was not a valid JSON!");
|
2018-09-08 19:15:23 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
reader.readAsText(file);
|
|
|
|
$(this).val("");
|
2018-02-08 23:25:57 +01:00
|
|
|
});
|
2018-02-08 20:04:13 +01:00
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// On thickness slider change
|
2019-02-22 13:49:40 +01:00
|
|
|
$("#whiteboardThicknessSlider").on("input", function () {
|
|
|
|
whiteboard.setStrokeThickness($(this).val());
|
2019-01-11 11:24:04 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// handle drag&drop
|
2018-02-08 20:04:13 +01:00
|
|
|
var dragCounter = 0;
|
2018-09-08 19:15:23 +02:00
|
|
|
$('#whiteboardContainer').on("dragenter", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2018-02-08 20:04:13 +01:00
|
|
|
dragCounter++;
|
|
|
|
whiteboard.dropIndicator.show();
|
|
|
|
});
|
|
|
|
|
2018-09-08 19:15:23 +02:00
|
|
|
$('#whiteboardContainer').on("dragleave", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
dragCounter--;
|
|
|
|
if (dragCounter === 0) {
|
|
|
|
whiteboard.dropIndicator.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
$('#whiteboardContainer').on('drop', function (e) { //Handle drop
|
2018-09-08 19:15:23 +02:00
|
|
|
if (e.originalEvent.dataTransfer) {
|
|
|
|
if (e.originalEvent.dataTransfer.files.length) { //File from harddisc
|
2018-02-08 20:04:13 +01:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
var filename = e.originalEvent.dataTransfer.files[0]["name"];
|
2018-09-08 19:15:23 +02:00
|
|
|
if (isImageFileName(filename)) {
|
|
|
|
var blob = e.originalEvent.dataTransfer.files[0];
|
|
|
|
var reader = new window.FileReader();
|
|
|
|
reader.readAsDataURL(blob);
|
|
|
|
reader.onloadend = function () {
|
|
|
|
base64data = reader.result;
|
|
|
|
uploadImgAndAddToWhiteboard(base64data);
|
|
|
|
}
|
|
|
|
} else {
|
2019-06-05 00:55:48 +02:00
|
|
|
showBasicAlert("File must be an image!");
|
2018-09-08 19:15:23 +02:00
|
|
|
}
|
2018-02-08 20:04:13 +01:00
|
|
|
} else { //File from other browser
|
2019-06-05 00:55:48 +02:00
|
|
|
|
2018-09-08 19:15:23 +02:00
|
|
|
var fileUrl = e.originalEvent.dataTransfer.getData('URL');
|
|
|
|
var imageUrl = e.originalEvent.dataTransfer.getData('text/html');
|
|
|
|
var rex = /src="?([^"\s]+)"?\s*/;
|
|
|
|
var url = rex.exec(imageUrl);
|
|
|
|
if (url && url.length > 1) {
|
|
|
|
url = url[1];
|
|
|
|
} else {
|
|
|
|
url = "";
|
|
|
|
}
|
2018-02-08 20:04:13 +01:00
|
|
|
|
2018-09-08 19:15:23 +02:00
|
|
|
isValidImageUrl(fileUrl, function (isImage) {
|
|
|
|
if (isImage && isImageFileName(url)) {
|
|
|
|
whiteboard.addImgToCanvasByUrl(fileUrl);
|
|
|
|
} else {
|
|
|
|
isValidImageUrl(url, function (isImage) {
|
|
|
|
if (isImage) {
|
2019-06-05 00:55:48 +02:00
|
|
|
if (isImageFileName(url) || url.startsWith("http")) {
|
2018-09-08 19:15:23 +02:00
|
|
|
whiteboard.addImgToCanvasByUrl(url);
|
|
|
|
} else {
|
2019-06-05 00:55:48 +02:00
|
|
|
uploadImgAndAddToWhiteboard(url); //Last option maybe its base64
|
2018-09-08 19:15:23 +02:00
|
|
|
}
|
|
|
|
} else {
|
2019-06-05 00:55:48 +02:00
|
|
|
showBasicAlert("Can only upload Imagedata!");
|
2018-09-08 19:15:23 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-02-08 20:04:13 +01:00
|
|
|
}
|
|
|
|
dragCounter = 0;
|
|
|
|
whiteboard.dropIndicator.hide();
|
|
|
|
});
|
2018-09-08 19:15:23 +02:00
|
|
|
|
2018-02-08 20:04:13 +01:00
|
|
|
$('#whiteboardColorpicker').colorPicker({
|
2018-09-08 19:15:23 +02:00
|
|
|
renderCallback: function (elm) {
|
2019-02-22 13:49:40 +01:00
|
|
|
whiteboard.setDrawColor(elm.val());
|
2018-09-08 19:15:23 +02:00
|
|
|
}
|
2018-02-08 20:04:13 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-02-08 21:53:48 +01:00
|
|
|
//Prevent site from changing tab on drag&drop
|
2018-09-08 19:15:23 +02:00
|
|
|
window.addEventListener("dragover", function (e) {
|
|
|
|
e = e || event;
|
|
|
|
e.preventDefault();
|
|
|
|
}, false);
|
|
|
|
window.addEventListener("drop", function (e) {
|
|
|
|
e = e || event;
|
|
|
|
e.preventDefault();
|
|
|
|
}, false);
|
2018-02-08 21:53:48 +01:00
|
|
|
|
2018-02-08 23:16:28 +01:00
|
|
|
function uploadImgAndAddToWhiteboard(base64data) {
|
2018-09-08 19:15:23 +02:00
|
|
|
var date = (+new Date());
|
|
|
|
$.ajax({
|
2018-02-08 23:16:28 +01:00
|
|
|
type: 'POST',
|
2018-09-08 19:15:23 +02:00
|
|
|
url: document.URL.substr(0, document.URL.lastIndexOf('/')) + '/upload',
|
|
|
|
data: {
|
2018-02-08 23:16:28 +01:00
|
|
|
'imagedata': base64data,
|
2018-09-08 19:15:23 +02:00
|
|
|
'whiteboardId': whiteboardId,
|
2019-02-11 12:43:23 +01:00
|
|
|
'date': date,
|
2019-04-05 14:56:09 +02:00
|
|
|
'at': accessToken
|
2018-09-08 19:15:23 +02:00
|
|
|
},
|
|
|
|
success: function (msg) {
|
|
|
|
var filename = whiteboardId + "_" + date + ".png";
|
|
|
|
whiteboard.addImgToCanvasByUrl(document.URL.substr(0, document.URL.lastIndexOf('/')) + "/uploads/" + filename); //Add image to canvas
|
2018-02-08 23:16:28 +01:00
|
|
|
console.log("Image uploaded!");
|
|
|
|
},
|
2018-09-08 19:15:23 +02:00
|
|
|
error: function (err) {
|
2019-06-05 00:55:48 +02:00
|
|
|
showBasicAlert("Failed to upload frame: " + JSON.stringify(err));
|
2018-02-08 23:16:28 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// verify if filename refers to an image
|
2018-02-08 20:04:13 +01:00
|
|
|
function isImageFileName(filename) {
|
2019-01-11 11:24:04 +01:00
|
|
|
var extension = filename.split(".")[filename.split(".").length - 1];
|
2019-07-01 10:52:39 +02:00
|
|
|
var known_extensions = ["png", "jpg", "jpeg", "gif", "tiff", "bmp", "webp"];
|
2019-01-11 11:24:04 +01:00
|
|
|
return known_extensions.includes(extension.toLowerCase());
|
2018-02-08 20:04:13 +01:00
|
|
|
}
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// verify if given url is url to an image
|
|
|
|
function isValidImageUrl(url, callback) {
|
2018-02-08 20:04:13 +01:00
|
|
|
var img = new Image();
|
|
|
|
var timer = null;
|
|
|
|
img.onerror = img.onabort = function () {
|
|
|
|
clearTimeout(timer);
|
|
|
|
callback(false);
|
|
|
|
};
|
|
|
|
img.onload = function () {
|
|
|
|
clearTimeout(timer);
|
|
|
|
callback(true);
|
|
|
|
};
|
|
|
|
timer = setTimeout(function () {
|
|
|
|
callback(false);
|
|
|
|
}, 2000);
|
|
|
|
img.src = url;
|
|
|
|
}
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// handle pasting from clipboard
|
|
|
|
window.addEventListener("paste", function (e) {
|
2018-09-08 19:15:23 +02:00
|
|
|
if (e.clipboardData) {
|
|
|
|
var items = e.clipboardData.items;
|
2019-06-02 17:26:26 +02:00
|
|
|
var imgItemFound = false;
|
2018-09-08 19:15:23 +02:00
|
|
|
if (items) {
|
|
|
|
// Loop through all items, looking for any kind of image
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i].type.indexOf("image") !== -1) {
|
2019-06-02 17:26:26 +02:00
|
|
|
imgItemFound = true;
|
2018-09-08 19:15:23 +02:00
|
|
|
// We need to represent the image as a file,
|
|
|
|
var blob = items[i].getAsFile();
|
|
|
|
|
|
|
|
var reader = new window.FileReader();
|
|
|
|
reader.readAsDataURL(blob);
|
|
|
|
reader.onloadend = function () {
|
|
|
|
console.log("Uploading image!");
|
|
|
|
base64data = reader.result;
|
|
|
|
uploadImgAndAddToWhiteboard(base64data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-08 20:04:13 +01:00
|
|
|
}
|
2019-06-02 17:26:26 +02:00
|
|
|
|
2019-06-05 23:30:46 +02:00
|
|
|
if (!imgItemFound && whiteboard.tool!="text") {
|
|
|
|
showBasicAlert("Please Drag&Drop the image into the Whiteboard. (Browsers don't allow copy+past from the filesystem directly)");
|
2019-06-02 17:26:26 +02:00
|
|
|
}
|
2018-09-08 19:15:23 +02:00
|
|
|
}
|
2018-02-08 23:38:41 +01:00
|
|
|
});
|
|
|
|
|
2019-06-02 17:26:26 +02:00
|
|
|
function showBasicAlert(text) {
|
|
|
|
var alertHtml = $('<div style="position:absolute; top:0px; left:0px; width:100%; top:70px; font-family: monospace;">' +
|
|
|
|
'<div style="width: 30%; margin: auto; background: #aaaaaa; border-radius: 5px; font-size: 1.2em; border: 1px solid gray;">'+
|
|
|
|
'<div style="border-bottom: 1px solid #676767; background: #d25d5d; padding-left: 5px; font-size: 0.8em;">INFO MESSAGE</div>'+
|
|
|
|
'<div style="padding: 10px;">' + text + '</div>'+
|
|
|
|
'<div style="height: 20px; padding: 10px;"><button style="float: right; padding: 5px; border-radius: 5px; border: 0px; min-width: 50px; cursor: pointer;">Ok</button></div>'+
|
|
|
|
'</div>' +
|
|
|
|
'</div>');
|
|
|
|
$("body").append(alertHtml);
|
|
|
|
alertHtml.find("button").click(function () {
|
|
|
|
alertHtml.remove();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-01-11 11:24:04 +01:00
|
|
|
// get 'GET' parameter by variable name
|
2018-02-08 23:38:41 +01:00
|
|
|
function getQueryVariable(variable) {
|
2018-09-08 19:15:23 +02:00
|
|
|
var query = window.location.search.substring(1);
|
|
|
|
var vars = query.split("&");
|
|
|
|
for (var i = 0; i < vars.length; i++) {
|
|
|
|
var pair = vars[i].split("=");
|
|
|
|
if (pair[0] == variable) {
|
|
|
|
return pair[1];
|
|
|
|
}
|
2018-02-08 23:38:41 +01:00
|
|
|
}
|
2018-09-08 19:15:23 +02:00
|
|
|
return false;
|
2018-02-08 23:38:41 +01:00
|
|
|
}
|