add function to copy a whiteboard from another one

This commit is contained in:
raphael 2021-03-31 13:34:21 +02:00
parent ceedf5dfe8
commit ed16bddd1f
2 changed files with 12 additions and 0 deletions

View File

@ -108,6 +108,7 @@ Call your site with GET parameters to change the WhiteboardID or the Username
- username => The name which will be shown to others while drawing
- title => Change the name of the Browser Tab
- randomid => if set to true, a random whiteboardId will be generated if not given aswell
- copyfromwid => set this to a whiteboardId you want a copy from. Only copies the content if the current whiteboard is empty.
## Configuration

View File

@ -36,6 +36,7 @@ if (urlParams.get("whiteboardid") !== whiteboardId) {
const myUsername = urlParams.get("username") || "unknown" + (Math.random() + "").substring(2, 6);
const accessToken = urlParams.get("accesstoken") || "";
const copyfromwid = urlParams.get("copyfromwid") || "";
// Custom Html Title
const title = urlParams.get("title");
@ -170,7 +171,17 @@ function initWhiteboard() {
// request whiteboard from server
$.get(subdir + "/api/loadwhiteboard", { wid: whiteboardId, at: accessToken }).done(
function (data) {
console.log(data);
whiteboard.loadData(data);
if (copyfromwid && data.length == 0) {
//Copy from witheboard if current is empty and get parameter is given
$.get(subdir + "/api/loadwhiteboard", {
wid: copyfromwid,
at: accessToken,
}).done(function (data) {
whiteboard.loadData(data);
});
}
}
);