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

Add one click clear button #202

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client-data/board.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<script src="../tools/grid/grid.js"></script>
<script src="../tools/download/download.js"></script>
<script src="../tools/zoom/zoom.js"></script>
<script src="../tools/clear/clear.js"></script>
<script src="../js/canvascolor.js"></script>
</body>

Expand Down
60 changes: 60 additions & 0 deletions client-data/tools/clear/clear.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* WHITEBOPHIR
*********************************************************
* @licstart The following is the entire license notice for the
* JavaScript code in this page.
*
* Copyright (C) 2013 Ophir LOJKINE
*
*
* The JavaScript code in this page is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend
*/

(function grid() {
// when clear button clicks then calls this function
function btnClickHandler() {
Tools.socket.emit('broadcast', {
board: Tools.boardName,
data : {
tool : "Clear",
type : "clear"
}
});
Tools.drawingArea.innerHTML = '';
}

// this is callback handler from socket
function eraseAll(data) {
switch (data.type) {
case "clear":
Tools.drawingArea.innerHTML = '';
break;
}
}

Tools.add({
"name": "Clear",
"shortcut": "Delete",
"listeners": {},
"icon": "tools/clear/clear.svg",
"oneTouch": true,
"onstart": btnClickHandler,
"draw": eraseAll,
"mouseCursor": "crosshair",
});

})();
1 change: 1 addition & 0 deletions client-data/tools/clear/clear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion server/boardData.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ class BoardData {
this.delaySave();
}

/** Process a batch of messages
/** Clear all data from the board
*/
clear() {
this.board = {};
this.delaySave();
}

/** Process a batch of messages
* @typedef {{
* id:string,
* type: "delete" | "update" | "child",
Expand All @@ -156,6 +163,9 @@ class BoardData {
case "delete":
if (id) this.delete(id);
break;
case "clear":
this.clear();
break;
case "update":
if (id) this.update(id, message);
break;
Expand Down
4 changes: 3 additions & 1 deletion server/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@
"tools": "工具",
"view_source": "GitHub上的源代码",
"white-out": "修正液",
"clear": "清空",
"download": "下载",
"zoom": "放大"
}
}
}