Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button for clearing a whiteboard #151

Open
mwllgr opened this issue Nov 25, 2020 · 5 comments
Open

Button for clearing a whiteboard #151

mwllgr opened this issue Nov 25, 2020 · 5 comments

Comments

@mwllgr
Copy link

mwllgr commented Nov 25, 2020

Similar to #120 - why isn't there a button to clear the whole board? It's easier than deleting the file or sharing a new link.

@topninja
Copy link

hello @mwllgr
I tried to make myself.

/client-data/board.html
insert this code under any icon what you want.
if you want to lay this icon at top of menu, then add under <script src="../tools/pencil/wbo_pencil_point.js"></script>
<script src="../tools/new/new.js"></script>

create "new" folder inside /tools
inside this directory, make new file as new.js, new.svg(add any icon what you want)
this is new.js file content.


(function grid() { //Code isolation

    function newPanel(evt) {
        Tools.drawingArea.innerHTML = ''
    }

    Tools.add({ //The new tool
        "name": "New",
        "shortcut": "n",
        "listeners": {},
        "icon": "tools/new/new.svg",
        "oneTouch": true,
        "onstart": newPanel,
        "mouseCursor": "crosshair",
    });

})(); //End of code isolation

Thanks

@mwllgr
Copy link
Author

mwllgr commented Nov 27, 2020

Thanks @topninja! Any info on how I can integrate this with the Docker container?

@lovasoa
Copy link
Owner

lovasoa commented Nov 27, 2020


(function grid() { //Code isolation

    function newPanel(evt) {
        Tools.drawingArea.innerHTML = ''
    }

    Tools.add({ //The new tool
        "name": "New",
        "shortcut": "n",
        "listeners": {},
        "icon": "tools/new/new.svg",
        "oneTouch": true,
        "onstart": newPanel,
        "mouseCursor": "crosshair",
    });

})(); //End of code isolation

This does not clear the board. This just clears the drawing area locally on your own screen, without sending anything to the server or to other connected users. If you simply refresh the page, you will the the board reappear.

@topninja
Copy link

topninja commented Nov 27, 2020

Thanks @topninja! Any info on how I can integrate this with the Docker container?
revise like below and run inside docker as before

This does not clear the board. This just clears the drawing area locally on your own screen, without sending anything to the server or to other connected users. If you simply refresh the page, you will the the board reappear.

sorry for check in deep.
I revised again. I checked this is working as well.

revise above new.js like this




(function grid() {
    
    function newPanel() {
        Tools.socket.emit('broadcast', {
            board: Tools.boardName,
            data : {
                tool : "New",
                type : "deleteall"
            }
        });
        Tools.drawingArea.innerHTML = '';
    }

    function eraseAll(data) {
		switch (data.type) {
			case "deleteall":
                Tools.drawingArea.innerHTML = '';
				break;
		}
    }

    Tools.add({
        "name": "New",
        "shortcut": "n",
        "listeners": {},
        "icon": "tools/new/new.svg",
        "oneTouch": true,
        "onstart": newPanel,
        "draw": eraseAll,
        "mouseCursor": "crosshair",
    });

})(); 

server/boardData.js

input this function

BoardData.prototype.deleteall = function (id) {
	//KISS
	this.board = [];
	this.delaySave();
};

server/socket.js
add this case in saveHistory function

case "deleteall":
			board.deleteall();
			break;

@lovasoa
Copy link
Owner

lovasoa commented Nov 27, 2020

This is already better, but isn't this.board supposed to be an object ? Anyway, can you please submit this as a pull request ? This will be easier to review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants