-
-
Notifications
You must be signed in to change notification settings - Fork 423
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
Erase all button on menu #152
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 new button clicks then calls this function | ||
function btnClickHandler() { | ||
Tools.socket.emit('broadcast', { | ||
board: Tools.boardName, | ||
data : { | ||
tool : "New", | ||
type : "deleteall" | ||
} | ||
}); | ||
Tools.drawingArea.innerHTML = ''; | ||
Comment on lines
+30
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tools.socket shouldn't be used directly. You can use drawAndSend. See other tools for an example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, there should probably be a confirmation prompt. This erases all data forever, which could represent days of work by multiple people. |
||
} | ||
|
||
// this is callback handler from socket | ||
function eraseAll(data) { | ||
switch (data.type) { | ||
case "deleteall": | ||
Tools.drawingArea.innerHTML = ''; | ||
break; | ||
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have a formatting problem |
||
} | ||
} | ||
|
||
Tools.add({ | ||
"name": "New", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it shouldn't be called new |
||
"shortcut": "n", | ||
"listeners": {}, | ||
"icon": "tools/new/new.svg", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not new |
||
"oneTouch": true, | ||
"onstart": btnClickHandler, | ||
"draw": eraseAll, | ||
"mouseCursor": "crosshair", | ||
}); | ||
|
||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,14 @@ BoardData.prototype.delete = function (id) { | |
this.delaySave(); | ||
}; | ||
|
||
/** Removes all data from the board | ||
*/ | ||
BoardData.prototype.deleteall = function () { | ||
//KISS | ||
this.board = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This.board is an object, not an array |
||
this.delaySave(); | ||
}; | ||
|
||
/** Reads data from the board | ||
* @param {string} id - Identifier of the element to get. | ||
* @returns {object} The element with the given id, or undefined if no element has this id | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,9 @@ async function saveHistory(boardName, message) { | |
case "delete": | ||
if (id) board.delete(id); | ||
break; | ||
case "deleteall": | ||
board.deleteall(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should check that the tool is activated, and this tool should probably not be activated by default. |
||
break; | ||
case "update": | ||
if (id) board.update(id, message); | ||
break; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably not be called new, but something like clear