diff --git a/public/js/main.js b/public/js/main.js index 4212b5f..fec9c06 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -125,7 +125,7 @@ $(document).ready(function () { // upload image button $("#addImgToCanvasBtn").click(function () { - alert("Please drag the image into the browser."); + showBasicAlert("Please drag the image into the browser."); }); // save image as png @@ -178,7 +178,7 @@ $(document).ready(function () { $("").appendTo("body").val(urlStart).select().each(function () { document.execCommand('copy'); }).remove(); - alert("Copied Whiteboard-URL to clipboard.") + showBasicAlert("Copied Whiteboard-URL to clipboard.") }); var btnsMini = false; @@ -205,7 +205,7 @@ $(document).ready(function () { var j = JSON.parse(e.target.result); whiteboard.loadJsonData(j); } catch (e) { - alert("File was not a valid JSON!"); + showBasicAlert("File was not a valid JSON!"); } }; reader.readAsText(file); @@ -355,10 +355,12 @@ function isValidImageUrl(url, callback) { window.addEventListener("paste", function (e) { if (e.clipboardData) { var items = e.clipboardData.items; + var imgItemFound = false; 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) { + imgItemFound = true; // We need to represent the image as a file, var blob = items[i].getAsFile(); @@ -372,9 +374,27 @@ window.addEventListener("paste", function (e) { } } } + + if (!imgItemFound) { + showBasicAlert("Please Drag&Drop the file into the Whiteboard. (Browsers don't allow copy+past from the filesystem directly)"); + } } }); +function showBasicAlert(text) { + var alertHtml = $('