+
+
+ Drag a .gcode or .nc file to the command box or click Upload GCODE to upload it.
+
+
-
-
+
+
+
+
+
+
-
-Drag a .gcode or .nc file to the command box or click Upload GCODE to upload it.
+
+ Upload GCODE
+
+
-
-
-
-
-
-
-
-
-Upload GCODE
-
-
diff --git a/i/userButton.css b/i/userButton.css
new file mode 100644
index 0000000..668de6d
--- /dev/null
+++ b/i/userButton.css
@@ -0,0 +1,58 @@
+/*
+
+ userButton.css - An addition to GRBLWeb
+ Copyright (c) 2015, Ben Suffolk
+
+ GRBLWeb - a web based CNC controller for GRBL
+ Copyright (C) 2015 Andrew Hodel
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+*/
+
+
+.btn-user .dropdown-menu {
+ padding: 0px;
+ width: 200px;
+ border: none;
+}
+
+.btn-user .dropdown-menu input {
+ -webkit-border-top-left-radius: 4px;
+ -webkit-border-top-right-radius: 4px;
+ -moz-border-radius-topleft: 4px;
+ -moz-border-radius-topright: 4px;
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ -webkit-border-bottom-left-radius: 0px;
+ -webkit-border-bottom-right-radius: 0px;
+ -moz-border-radius-bottomleft: 0px;
+ -moz-border-radius-bottomright: 0px;
+ border-bottom-left-radius: 0px;
+ border-bottom-right-radius: 0px;
+}
+
+.btn-user .dropdown-menu textarea {
+ width: 100%;
+ overflow: auto;
+ display: block;
+ border-color: #CCCCCC
+}
diff --git a/i/userButton.js b/i/userButton.js
new file mode 100644
index 0000000..4ba3b9d
--- /dev/null
+++ b/i/userButton.js
@@ -0,0 +1,126 @@
+/*
+
+ userButton.js - An addition to GRBLWeb
+ Copyright (c) 2015, Ben Suffolk
+
+ GRBLWeb - a web based CNC controller for GRBL
+ Copyright (C) 2015 Andrew Hodel
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+ ********
+
+ 1. Inculde files in index.html :
+
+
+ 2. Add 1 or more user defined button elements, set the id of the button to
+ btn-user- where is a consecutive number starting at 1 :
+
+
+
+
+
+
+
+
+
+
+
+
+ 3. You may also add any simple button that executes GCode :
+
+
+
+ If your GCode should have more than 1 line, use
to sepcify a new line :
+
+
+
+*/
+
+
+var socket;
+
+function userButton(s) {
+
+ socket = s;
+
+ // Instruction from the server to configure the user buttons
+ socket.on('configUserButtons', function(data) {
+
+ // Loop over each user button on the page
+ $('div.btn-user > button.btn-gcode').each(function() {
+ var number = $(this).attr('id').substring(9);
+ // Do we have data for this button?
+ if(typeof data[number] != 'undefined') {
+ $('#btn-user-'+number).html(data[number].title);
+ $('#btn-user-'+number).data('gcodeline', data[number].line);
+ }
+ });
+ });
+}
+
+
+$(document).ready(function() {
+
+ // Make sure the dropdown form does not close when the form field is clicked.
+ $('.dropdown-menu :input').click(function(e) {
+ e.stopPropagation();
+ });
+
+ // Load the current details into the form when the uesr clicks the configure drop down
+ $('.btn-user .dropdown-toggle').click(function() {
+ var button = $(this).closest('.btn-user').find('> .btn');
+ $(this).parent().find('.dropdown-menu input').val(button.html());
+ $(this).parent().find('.dropdown-menu textarea').val(button.data('gcodeline'));
+ });
+
+ // Stop the axis step keys working in the form
+ $('.dropdown-menu :input').keydown(function (e) {
+ e.stopPropagation();
+ });
+
+
+ // Pick up any changes to the title
+ $('.dropdown-menu input').change(function(){
+ var button = $(this).closest('.btn-user').find('> .btn');
+ var number = button.attr('id').substring(9);
+ button.html($(this).val());
+ socket.emit('configUserButton', { 'button':number, 'title':button.html(), 'line': button.data('gcodeline')});
+ });
+
+ // Pick up any changes to the gcode
+ $('.dropdown-menu textarea').change(function() {
+ var button = $(this).closest('.btn-user').find('> .btn');
+ var number = button.attr('id').substring(9);
+ button.data('gcodeline', $(this).val());
+ socket.emit('configUserButton', { 'button':number, 'title':button.html(), 'line': button.data('gcodeline')});
+ });
+
+ // If its a button with gcode data the send the code
+ $('.btn-gcode').click(function() {
+ var gcode = $(this).data('gcodeline');
+ if(typeof gcode != 'undefined' && gcode != '') {
+ socket.emit('gcodeLine', { line: gcode});
+ }
+ });
+});
diff --git a/userButtons.js b/userButtons.js
new file mode 100644
index 0000000..6295f21
--- /dev/null
+++ b/userButtons.js
@@ -0,0 +1,59 @@
+/*
+
+ userButtons.js - An addition to GRBLWeb
+ Copyright (c) 2015, Ben Suffolk
+
+ GRBLWeb - a web based CNC controller for GRBL
+ Copyright (C) 2015 Andrew Hodel
+
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+*/
+
+var fs = require('fs');
+
+var userButtons = {};
+
+if(fs.existsSync("./userButtons.json")) {
+ userButtons = JSON.parse(fs.readFileSync("./userButtons.json"));
+}
+
+module.exports = function(io) {
+
+ io.sockets.on('connection', function (socket) {
+
+ socket.emit('configUserButtons', userButtons);
+
+ socket.on('configUserButton', function(data) {
+
+ var button = data['button'];
+ if(typeof button != 'undefined' && button >0 && button <99) {
+ console.log('new user button data for button: '+button);
+ userButtons[button] = data;
+ }
+
+ fs.writeFileSync("./userButtons.json", JSON.stringify(userButtons));
+ socket.emit('configUserButtons', userButtons);
+ });
+ });
+
+}
+