├── web ├── public │ ├── source │ │ ├── images │ │ │ ├── favicon.ico │ │ │ ├── apple-icon.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon-96x96.png │ │ │ ├── ms-icon-144x144.png │ │ │ ├── ms-icon-150x150.png │ │ │ ├── ms-icon-310x310.png │ │ │ ├── ms-icon-70x70.png │ │ │ ├── apple-icon-57x57.png │ │ │ ├── apple-icon-60x60.png │ │ │ ├── apple-icon-72x72.png │ │ │ ├── apple-icon-76x76.png │ │ │ ├── android-icon-144x144.png │ │ │ ├── android-icon-192x192.png │ │ │ ├── android-icon-36x36.png │ │ │ ├── android-icon-48x48.png │ │ │ ├── android-icon-72x72.png │ │ │ ├── android-icon-96x96.png │ │ │ ├── apple-icon-114x114.png │ │ │ ├── apple-icon-120x120.png │ │ │ ├── apple-icon-144x144.png │ │ │ ├── apple-icon-152x152.png │ │ │ ├── apple-icon-180x180.png │ │ │ ├── apple-icon-precomposed.png │ │ │ ├── browserconfig.xml │ │ │ └── manifest.json │ │ ├── scripts │ │ │ ├── app.js │ │ │ ├── services.js │ │ │ ├── controllers.js │ │ │ └── directives.js │ │ └── less │ │ │ ├── build.less │ │ │ ├── app.less │ │ │ └── variables.less │ ├── build │ │ ├── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ │ └── images │ │ │ ├── apple-icon.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon-96x96.png │ │ │ ├── ms-icon-70x70.png │ │ │ ├── apple-icon-57x57.png │ │ │ ├── apple-icon-60x60.png │ │ │ ├── apple-icon-72x72.png │ │ │ ├── apple-icon-76x76.png │ │ │ ├── ms-icon-144x144.png │ │ │ ├── ms-icon-150x150.png │ │ │ ├── ms-icon-310x310.png │ │ │ ├── android-icon-36x36.png │ │ │ ├── android-icon-48x48.png │ │ │ ├── android-icon-72x72.png │ │ │ ├── android-icon-96x96.png │ │ │ ├── apple-icon-114x114.png │ │ │ ├── apple-icon-120x120.png │ │ │ ├── apple-icon-144x144.png │ │ │ ├── apple-icon-152x152.png │ │ │ ├── apple-icon-180x180.png │ │ │ ├── android-icon-144x144.png │ │ │ ├── android-icon-192x192.png │ │ │ └── apple-icon-precomposed.png │ └── views │ │ ├── directives │ │ ├── status.html │ │ ├── progress-bar.html │ │ ├── delete-user-modal.html │ │ ├── delete-entry-modal.html │ │ └── history.html │ │ ├── index.html │ │ └── partials │ │ └── start.html ├── server │ ├── models │ │ ├── user.js │ │ ├── entry.js │ │ ├── users.js │ │ └── entries.js │ └── routes │ │ ├── index.js │ │ └── socket.js └── server.js ├── .gitmodules ├── wii-scale ├── 70-wii-scales.rules ├── BlueZDevice.h ├── XWiiMonitor.h ├── UDev.h ├── UDevDevice.h ├── XWiiIface.h ├── XWiiMonitor.cpp ├── UDev.cpp ├── CMakeLists.txt ├── UDevDevice.cpp ├── XWiiIface.cpp ├── BlueZDevice.cpp └── wii-scale.cpp ├── .jshintrc ├── scripts ├── start.js └── start-backend.js ├── package.json ├── .gitignore ├── README.md ├── test └── test.js ├── gruntfile.js └── LICENSE /web/public/source/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/favicon.ico -------------------------------------------------------------------------------- /web/public/build/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /web/public/build/images/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon.png -------------------------------------------------------------------------------- /web/public/views/directives/status.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
-------------------------------------------------------------------------------- /web/public/build/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/favicon-16x16.png -------------------------------------------------------------------------------- /web/public/build/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/favicon-32x32.png -------------------------------------------------------------------------------- /web/public/build/images/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/favicon-96x96.png -------------------------------------------------------------------------------- /web/public/build/images/ms-icon-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/ms-icon-70x70.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-57x57.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-60x60.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-72x72.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-76x76.png -------------------------------------------------------------------------------- /web/public/build/images/ms-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/ms-icon-144x144.png -------------------------------------------------------------------------------- /web/public/build/images/ms-icon-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/ms-icon-150x150.png -------------------------------------------------------------------------------- /web/public/build/images/ms-icon-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/ms-icon-310x310.png -------------------------------------------------------------------------------- /web/public/source/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/favicon-16x16.png -------------------------------------------------------------------------------- /web/public/source/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/favicon-32x32.png -------------------------------------------------------------------------------- /web/public/source/images/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/favicon-96x96.png -------------------------------------------------------------------------------- /web/public/source/images/ms-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/ms-icon-144x144.png -------------------------------------------------------------------------------- /web/public/source/images/ms-icon-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/ms-icon-150x150.png -------------------------------------------------------------------------------- /web/public/source/images/ms-icon-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/ms-icon-310x310.png -------------------------------------------------------------------------------- /web/public/source/images/ms-icon-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/ms-icon-70x70.png -------------------------------------------------------------------------------- /web/public/build/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /web/public/build/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /web/public/build/images/android-icon-36x36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/android-icon-36x36.png -------------------------------------------------------------------------------- /web/public/build/images/android-icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/android-icon-48x48.png -------------------------------------------------------------------------------- /web/public/build/images/android-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/android-icon-72x72.png -------------------------------------------------------------------------------- /web/public/build/images/android-icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/android-icon-96x96.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-114x114.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-120x120.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-144x144.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-152x152.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-180x180.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-57x57.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-60x60.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-72x72.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-76x76.png -------------------------------------------------------------------------------- /web/public/build/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /web/public/build/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /web/public/build/images/android-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/android-icon-144x144.png -------------------------------------------------------------------------------- /web/public/build/images/android-icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/android-icon-192x192.png -------------------------------------------------------------------------------- /web/public/source/images/android-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/android-icon-144x144.png -------------------------------------------------------------------------------- /web/public/source/images/android-icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/android-icon-192x192.png -------------------------------------------------------------------------------- /web/public/source/images/android-icon-36x36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/android-icon-36x36.png -------------------------------------------------------------------------------- /web/public/source/images/android-icon-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/android-icon-48x48.png -------------------------------------------------------------------------------- /web/public/source/images/android-icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/android-icon-72x72.png -------------------------------------------------------------------------------- /web/public/source/images/android-icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/android-icon-96x96.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-114x114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-114x114.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-120x120.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-144x144.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-152x152.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-180x180.png -------------------------------------------------------------------------------- /web/public/build/images/apple-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/build/images/apple-icon-precomposed.png -------------------------------------------------------------------------------- /web/public/source/images/apple-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aelveborn/Wii-Scale/HEAD/web/public/source/images/apple-icon-precomposed.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "wii-scale/socket.io-client-cpp"] 2 | path = wii-scale/socket.io-client-cpp 3 | url = https://github.com/ribbons/socket.io-client-cpp.git 4 | -------------------------------------------------------------------------------- /web/public/views/directives/progress-bar.html: -------------------------------------------------------------------------------- 1 |
2 |
5 |
6 |
-------------------------------------------------------------------------------- /web/public/source/images/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | #ffffff -------------------------------------------------------------------------------- /web/public/source/images/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "App", 3 | "icons": [ 4 | { 5 | "src": "\/android-icon-36x36.png", 6 | "sizes": "36x36", 7 | "type": "image\/png", 8 | "density": "0.75" 9 | }, 10 | { 11 | "src": "\/android-icon-48x48.png", 12 | "sizes": "48x48", 13 | "type": "image\/png", 14 | "density": "1.0" 15 | }, 16 | { 17 | "src": "\/android-icon-72x72.png", 18 | "sizes": "72x72", 19 | "type": "image\/png", 20 | "density": "1.5" 21 | }, 22 | { 23 | "src": "\/android-icon-96x96.png", 24 | "sizes": "96x96", 25 | "type": "image\/png", 26 | "density": "2.0" 27 | }, 28 | { 29 | "src": "\/android-icon-144x144.png", 30 | "sizes": "144x144", 31 | "type": "image\/png", 32 | "density": "3.0" 33 | }, 34 | { 35 | "src": "\/android-icon-192x192.png", 36 | "sizes": "192x192", 37 | "type": "image\/png", 38 | "density": "4.0" 39 | } 40 | ] 41 | } -------------------------------------------------------------------------------- /wii-scale/70-wii-scales.rules: -------------------------------------------------------------------------------- 1 | # This file is part of Wii-Scale 2 | # Copyright © 2017 Matt Robinson 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | KERNEL=="event*", SUBSYSTEM=="input", DRIVERS=="wiimote", MODE="0666" 19 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | { 24 | "globals": { 25 | "angular": true 26 | } 27 | } -------------------------------------------------------------------------------- /web/server/models/user.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var User = function(name) { 24 | this.name = name; 25 | }; 26 | 27 | module.exports = User; -------------------------------------------------------------------------------- /wii-scale/BlueZDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | class BlueZDevice 21 | { 22 | public: 23 | explicit BlueZDevice(const std::string &address, const std::string &name); 24 | void Disconnect(); 25 | 26 | private: 27 | std::string path; 28 | }; 29 | -------------------------------------------------------------------------------- /web/server/models/entry.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var Entry = function(userName, weight) { 24 | this.dateTime = new Date(); 25 | this.weight = weight; 26 | this.userName = userName; 27 | }; 28 | 29 | module.exports = Entry; -------------------------------------------------------------------------------- /web/public/views/directives/delete-user-modal.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /web/public/views/directives/delete-entry-modal.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /wii-scale/XWiiMonitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2016 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include "XWiiIface.h" 21 | #include 22 | 23 | class XWiiMonitor 24 | { 25 | public: 26 | XWiiMonitor(); 27 | ~XWiiMonitor(); 28 | std::unique_ptr Poll(); 29 | 30 | private: 31 | struct xwii_monitor* monitor; 32 | }; 33 | -------------------------------------------------------------------------------- /scripts/start.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | Copyright (C) 2017 Matt Robinson 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | var server = require('../web/server.js'); 25 | var backend = require('./start-backend.js'); 26 | 27 | // Starts Wii-Scale application 28 | backend.start(); 29 | 30 | // Starts the webserver 31 | server.start(); 32 | -------------------------------------------------------------------------------- /wii-scale/UDev.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | class UDevDevice; 24 | 25 | class UDev 26 | { 27 | public: 28 | UDev(); 29 | ~UDev(); 30 | std::unique_ptr DeviceFromSyspath(const std::string &syspath); 31 | 32 | private: 33 | struct udev *udev; 34 | }; 35 | -------------------------------------------------------------------------------- /wii-scale/UDevDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include "UDev.h" 23 | 24 | class UDevDevice 25 | { 26 | public: 27 | ~UDevDevice(); 28 | std::unique_ptr GetParent(); 29 | std::string GetAttrValue(const std::string &name); 30 | 31 | private: 32 | explicit UDevDevice(struct udev_device *device); 33 | struct udev_device *device; 34 | 35 | friend std::unique_ptr UDev::DeviceFromSyspath(const std::string &syspath); 36 | }; 37 | -------------------------------------------------------------------------------- /web/server/routes/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var options = { 24 | root: __dirname + '/../../public/views/' 25 | }; 26 | 27 | exports.index = function(req, res) { 28 | res.sendFile('index.html', options); 29 | }; 30 | 31 | exports.directives = function(req, res) { 32 | var page = req.params.page; 33 | res.sendFile('directives/' + page + '.html', options); 34 | }; 35 | 36 | exports.partials = function (req, res) { 37 | var page = req.params.page; 38 | res.sendFile('partials/' + page + '.html', options); 39 | }; -------------------------------------------------------------------------------- /wii-scale/XWiiIface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2016-2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | class XWiiIface 24 | { 25 | public: 26 | explicit XWiiIface(const std::string &path); 27 | ~XWiiIface(); 28 | bool HasBalanceBoard(); 29 | bool EnableBalanceBoard(); 30 | void Dispatch(unsigned int mask, struct xwii_event *event); 31 | void Disconnect(); 32 | 33 | private: 34 | struct xwii_iface* device; 35 | std::string address; 36 | struct pollfd fds[1]; 37 | bool sentDisconnect = false; 38 | }; 39 | -------------------------------------------------------------------------------- /web/public/views/directives/history.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 44 |
-------------------------------------------------------------------------------- /web/server/models/users.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var Users = function(collection) { 24 | this.users = collection; 25 | }; 26 | 27 | Users.prototype.add = function(user) { 28 | if(this.findUserByName(user.name) === null) { 29 | this.users.insert(user); 30 | } 31 | }; 32 | 33 | Users.prototype.get = function() { 34 | return this.users.data; 35 | }; 36 | 37 | Users.prototype.remove = function(user) { 38 | this.users.remove(user); 39 | }; 40 | 41 | Users.prototype.findUserByName = function(name) { 42 | var user = this.users.findObject({ 43 | name: { '$eq': name } 44 | }); 45 | return user; 46 | }; 47 | 48 | module.exports = Users; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wii-scale", 3 | "version": "0.0.4", 4 | "description": "Wii-Scale", 5 | "author": "Andreas Älveborn", 6 | "url": "https://github.com/aelveborn/Wii-Scale", 7 | "license": "GPL V2", 8 | "private": true, 9 | "main": "web/server.js", 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/aelveborn/Wii-Scale" 13 | }, 14 | "config": { 15 | "host": "localhost", 16 | "port": "8080", 17 | "calibrate": 0 18 | }, 19 | "scripts": { 20 | "test": "mocha", 21 | "start": "node scripts/start.js" 22 | }, 23 | "dependencies": { 24 | "express": "4.12.0", 25 | "lokijs": "1.3.7", 26 | "socket.io": "1.3.4" 27 | }, 28 | "devDependencies": { 29 | "angular": "^1.4.3", 30 | "angular-animate": "^1.4.3", 31 | "angular-route": "^1.4.3", 32 | "angular-socket-io": "^0.7.0", 33 | "bootstrap": "3.3.5", 34 | "chai": "^3.1.0", 35 | "font-awesome": "^4.3.0", 36 | "grunt": "^0.4.5", 37 | "grunt-contrib-clean": "^0.6.0", 38 | "grunt-contrib-concat": "^0.5.1", 39 | "grunt-contrib-copy": "^0.8.0", 40 | "grunt-contrib-cssmin": "^0.12.3", 41 | "grunt-contrib-imagemin": "^1.0.0", 42 | "grunt-contrib-jshint": "^0.11.2", 43 | "grunt-contrib-less": "^1.0.1", 44 | "grunt-contrib-uglify": "^0.9.1", 45 | "grunt-contrib-watch": "^0.6.1", 46 | "grunt-simple-mocha": "^0.4.0", 47 | "jquery": "1.11.3", 48 | "mocha": "^2.2.5", 49 | "chartist": "~0.9.1", 50 | "chartist-plugin-pointlabels": "0.0.4" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /scripts/start-backend.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | Copyright (C) 2017 Matt Robinson 8 | 9 | This program is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License along 20 | with this program; if not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 | */ 23 | 24 | var spawn = require('child_process').spawn; 25 | 26 | var host = process.env.npm_package_config_host; 27 | var port = process.env.npm_package_config_port; 28 | var calibrate = process.env.npm_package_config_calibrate; 29 | 30 | var args = [ 31 | '-h' + host, 32 | '-p' + port, 33 | '-c' + calibrate 34 | ] 35 | 36 | exports.start = function() { 37 | child = spawn('build/wii-scale', args); 38 | 39 | child.stderr.on('data', function (data) { 40 | console.log(data.toString()); 41 | }); 42 | 43 | child.stdout.on('data', function (data) { 44 | console.log(data.toString()); 45 | }); 46 | } 47 | -------------------------------------------------------------------------------- /wii-scale/XWiiMonitor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2016 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include "XWiiMonitor.h" 23 | 24 | XWiiMonitor::XWiiMonitor() 25 | { 26 | monitor = xwii_monitor_new(false, false); 27 | 28 | if(monitor == NULL) 29 | { 30 | throw std::runtime_error("Failed to create xwii_monitor"); 31 | } 32 | } 33 | 34 | XWiiMonitor::~XWiiMonitor() 35 | { 36 | xwii_monitor_unref(monitor); 37 | } 38 | 39 | std::unique_ptr XWiiMonitor::Poll() 40 | { 41 | char *path = xwii_monitor_poll(monitor); 42 | 43 | if(path == NULL) 44 | { 45 | return nullptr; 46 | } 47 | 48 | std::unique_ptr iface(new XWiiIface(path)); 49 | free(path); 50 | 51 | return iface; 52 | } 53 | -------------------------------------------------------------------------------- /wii-scale/UDev.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include "UDevDevice.h" 22 | 23 | UDev::UDev() 24 | { 25 | this->udev = udev_new(); 26 | 27 | if(this->udev == NULL) 28 | { 29 | throw std::system_error(-errno, std::system_category(), "Failed to create udev context"); 30 | } 31 | } 32 | 33 | UDev::~UDev() 34 | { 35 | udev_unref(udev); 36 | } 37 | 38 | std::unique_ptr UDev::DeviceFromSyspath(const std::string &syspath) 39 | { 40 | struct udev_device *device = udev_device_new_from_syspath(this->udev, syspath.c_str()); 41 | 42 | if(device == NULL) 43 | { 44 | throw std::system_error(errno, std::system_category(), "Failed to create device"); 45 | } 46 | 47 | return std::unique_ptr(new UDevDevice(device)); 48 | } 49 | -------------------------------------------------------------------------------- /web/server.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var app = require('express')(); 24 | var server = require('http').Server(app); 25 | var io = require('socket.io')(server); 26 | var socket = require('./server/routes/socket.js')(io); 27 | var routes = require('./server/routes/index.js'); 28 | 29 | var host = process.env.npm_package_config_host; 30 | var port = process.env.npm_package_config_port; 31 | 32 | app.use('/static', require('express').static('web/public/build')); 33 | 34 | // Routes 35 | app.get('/', routes.index); 36 | app.get('/directives/:page', routes.directives); 37 | app.get('/partials/:page', routes.partials); 38 | 39 | 40 | exports.start = function() { 41 | server.listen(port, host, function(){ 42 | console.log('Listening on ' + host + ':' + port); 43 | }); 44 | }; -------------------------------------------------------------------------------- /web/server/models/entries.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var loki = require('lokijs'), 24 | db = new loki('app-data.json'); 25 | 26 | var Entries = function(collection) { 27 | this.entries = collection; 28 | }; 29 | 30 | Entries.prototype.add = function(entry) { 31 | this.entries.insert(entry); 32 | }; 33 | 34 | Entries.prototype.get = function() { 35 | return this.entries.data; 36 | }; 37 | 38 | Entries.prototype.remove = function(entry) { 39 | this.entries.remove(entry); 40 | }; 41 | 42 | Entries.prototype.getUserEntries = function(user) { 43 | return this.entries.find({ 44 | userName: { '$eq': user.name } 45 | }); 46 | }; 47 | 48 | Entries.prototype.removeUserEntries = function(user) { 49 | this.entries.removeWhere({ 50 | userName: { '$eq': user.name } 51 | }); 52 | }; 53 | 54 | module.exports = Entries; -------------------------------------------------------------------------------- /wii-scale/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file is part of Wii-Scale 2 | # Copyright © 2017-2018 Matt Robinson 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) 19 | 20 | set(Boost_USE_STATIC_LIBS ON) 21 | find_package(Boost REQUIRED COMPONENTS program_options) 22 | 23 | find_package(PkgConfig REQUIRED) 24 | pkg_check_modules(GIOMM REQUIRED giomm-2.4) 25 | 26 | add_subdirectory(socket.io-client-cpp EXCLUDE_FROM_ALL) 27 | 28 | INCLUDE_DIRECTORIES(socket.io-client-cpp/src ${GIOMM_INCLUDE_DIRS}) 29 | 30 | add_executable(wii-scale wii-scale.cpp XWiiMonitor.cpp XWiiIface.cpp UDev.cpp 31 | UDevDevice.cpp BlueZDevice.cpp) 32 | 33 | set_property(TARGET wii-scale PROPERTY CXX_STANDARD 11) 34 | set_property(TARGET wii-scale PROPERTY CXX_STANDARD_REQUIRED ON) 35 | 36 | target_link_libraries(wii-scale sioclient ${Boost_LIBRARIES} pthread xwiimote 37 | udev ${GIOMM_LIBRARIES}) 38 | 39 | file(GLOB CPP_FILES *.cpp) 40 | 41 | add_custom_target(cppcheck ALL COMMAND cppcheck --quiet --error-exitcode=2 42 | --enable=all --suppress=missingIncludeSystem --std=c++11 43 | ${CPP_FILES} 44 | DEPENDS wii-scale VERBATIM) 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Author: Andreas Älveborn 2 | # URL: https://github.com/aelveborn/Wii-Scale 3 | # 4 | # This file is part of Wii-Scale 5 | # Copyright (C) 2015 Andreas Älveborn 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License along 18 | # with this program; if not, write to the Free Software Foundation, Inc., 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | 21 | ######################### 22 | # Node 23 | ######################### 24 | 25 | # Storage 26 | app-data.json 27 | 28 | # Logs 29 | web/logs 30 | web/*.log 31 | 32 | # Runtime data 33 | web/pids 34 | web/*.pid 35 | web/*.seed 36 | 37 | # Directory for instrumented libs generated by jscoverage/JSCover 38 | web/lib-cov 39 | 40 | # Coverage directory used by tools like istanbul 41 | web/coverage 42 | 43 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 44 | web/.grunt 45 | 46 | # node-waf configuration 47 | web/.lock-wscript 48 | 49 | # Dependency directory 50 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 51 | node_modules/ 52 | 53 | # Byte-compiled / optimized / DLL files 54 | web/__pycache__/ 55 | web/*.py[cod] 56 | 57 | # C extensions 58 | web/*.so 59 | 60 | ########################## 61 | # C++ 62 | ########################## 63 | 64 | build/ 65 | 66 | ######################### 67 | # Custom 68 | ######################### 69 | 70 | # Exclude web build files 71 | !web/public/build/ 72 | -------------------------------------------------------------------------------- /wii-scale/UDevDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include "UDevDevice.h" 22 | 23 | UDevDevice::UDevDevice(struct udev_device *device) 24 | { 25 | if(device == NULL) 26 | { 27 | throw std::invalid_argument("device is NULL"); 28 | } 29 | 30 | this->device = device; 31 | } 32 | 33 | UDevDevice::~UDevDevice() 34 | { 35 | udev_device_unref(this->device); 36 | } 37 | 38 | std::unique_ptr UDevDevice::GetParent() 39 | { 40 | struct udev_device *parent = udev_device_get_parent(this->device); 41 | 42 | if(parent == NULL) 43 | { 44 | throw std::system_error(errno, std::system_category(), "Failed to find parent"); 45 | } 46 | 47 | // Increment parent ref count so it isn't freed with child object 48 | udev_device_ref(this->device); 49 | 50 | return std::unique_ptr(new UDevDevice(parent)); 51 | } 52 | 53 | std::string UDevDevice::GetAttrValue(const std::string &name) 54 | { 55 | const char *attrVal = udev_device_get_sysattr_value(this->device, name.c_str()); 56 | 57 | if(attrVal != NULL) 58 | { 59 | return std::string(attrVal); 60 | } 61 | else 62 | { 63 | return std::string(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /web/public/source/scripts/app.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | (function() { 24 | 'use strict'; 25 | 26 | angular.module('app', [ 27 | 'ngRoute', 28 | 'ngAnimate', 29 | 'btford.socket-io', 30 | 'app.controllers', 31 | 'app.directives', 32 | 'app.services' 33 | ]). 34 | 35 | run(['$rootScope', 'entries', 'client', function ($rootScope, entries, client) { 36 | var defaultUser = { 37 | name: "Guest" 38 | }; 39 | $rootScope.defaultUser = defaultUser; 40 | $rootScope.selectedUser = defaultUser; 41 | entries.getUserEntries(defaultUser); 42 | client.load(); 43 | }]). 44 | 45 | config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { 46 | 47 | $routeProvider. 48 | when('/', { 49 | templateUrl: '/partials/start' 50 | }). 51 | when('/settings', { 52 | templateUrl: '/partials/settings' 53 | }). 54 | otherwise({ 55 | redirectTo: '/' 56 | }); 57 | 58 | $locationProvider.html5Mode(true); 59 | }]); 60 | 61 | })(); -------------------------------------------------------------------------------- /web/public/views/index.html: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 25 | Wii-Scale 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /wii-scale/XWiiIface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2016-2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "XWiiIface.h" 24 | #include "UDevDevice.h" 25 | #include "BlueZDevice.h" 26 | 27 | XWiiIface::XWiiIface(const std::string &path) 28 | { 29 | int ret = xwii_iface_new(&device, path.c_str()); 30 | 31 | if(ret) 32 | { 33 | throw std::system_error(-ret, std::system_category(), "Failed to connect to device " + path); 34 | } 35 | 36 | // Set up the pollfd structure ready for poll() in ::Dispatch 37 | memset(fds, 0, sizeof(fds)); 38 | fds[0].fd = xwii_iface_get_fd(device); 39 | fds[0].events = POLLIN; 40 | 41 | UDev udev; 42 | std::unique_ptr board = udev.DeviceFromSyspath(path); 43 | std::unique_ptr parent = board->GetParent(); 44 | this->address = parent->GetAttrValue("address"); 45 | } 46 | 47 | XWiiIface::~XWiiIface() 48 | { 49 | xwii_iface_unref(device); 50 | } 51 | 52 | bool XWiiIface::HasBalanceBoard() 53 | { 54 | return xwii_iface_available(device) & XWII_IFACE_BALANCE_BOARD; 55 | } 56 | 57 | bool XWiiIface::EnableBalanceBoard() 58 | { 59 | if(!HasBalanceBoard()) 60 | { 61 | return false; 62 | } 63 | 64 | int ret = xwii_iface_open(device, XWII_IFACE_BALANCE_BOARD); 65 | 66 | if(ret) 67 | { 68 | throw std::system_error(-ret, std::system_category(), "Failed to enable Balance Board"); 69 | } 70 | 71 | return true; 72 | } 73 | 74 | void XWiiIface::Dispatch(unsigned int mask, struct xwii_event *event) 75 | { 76 | for(;;) 77 | { 78 | // Block until an event is ready to be consumed 79 | int ret = poll(fds, (sizeof(fds) / sizeof(fds[0])), -1); 80 | 81 | if(ret < 0) 82 | { 83 | throw std::system_error(-ret, std::system_category(), "Polling for events failed"); 84 | } 85 | 86 | for(;;) 87 | { 88 | ret = xwii_iface_dispatch(device, event, sizeof(*event)); 89 | 90 | if(ret == -EAGAIN) 91 | { 92 | break; 93 | } 94 | 95 | if(ret) 96 | { 97 | throw std::system_error(-ret, std::system_category(), "Read failed"); 98 | } 99 | 100 | if (event->type & mask) 101 | { 102 | return; 103 | } 104 | } 105 | } 106 | } 107 | 108 | void XWiiIface::Disconnect() 109 | { 110 | if(!this->sentDisconnect) 111 | { 112 | BlueZDevice bluez(this->address, "Nintendo RVL-WBC-01"); 113 | bluez.Disconnect(); 114 | 115 | this->sentDisconnect = true; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /web/public/source/scripts/services.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | (function() { 24 | 'use strict'; 25 | 26 | angular.module('app.services', []). 27 | 28 | factory('socket', ['socketFactory', function (socketFactory) { 29 | return socketFactory(); 30 | }]). 31 | 32 | factory('socketCommands', function(){ 33 | var commands = Object.freeze({ 34 | CLIENT_LOAD: 'client load', 35 | 36 | DEVICE_CONNECT: 'device connect', 37 | DEVICE_DISCONNECT: 'device disconnect', 38 | 39 | USERS_ADD: 'users add', 40 | USERS_REMOVE: 'users remove', 41 | USERS_RECEIVE_LIST: 'users list', 42 | 43 | ENTRIES_ADD: 'entries add', 44 | ENTRIES_REMOVE: 'entries delete', 45 | ENTRIES_USER: 'entries user', 46 | ENTRIES_RECEIVE_LIST: 'entries list', 47 | 48 | WIISCALE_WEIGHT: 'wiiscale-weight', 49 | WIISCALE_STATUS: 'wiiscale-status' 50 | }); 51 | return commands; 52 | }). 53 | 54 | factory('client', ['socket', 'socketCommands', function (socket, socketCommands){ 55 | var client = { 56 | load: load, 57 | }; 58 | 59 | return client; 60 | 61 | function load() { 62 | socket.emit(socketCommands.CLIENT_LOAD); 63 | } 64 | }]). 65 | 66 | factory('device', ['socket', 'socketCommands', function (socket, socketCommands){ 67 | var device = { 68 | connect: connect, 69 | disconnect: disconnect, 70 | }; 71 | 72 | return device; 73 | 74 | function connect() { 75 | socket.emit(socketCommands.DEVICE_CONNECT); 76 | } 77 | 78 | function disconnect() { 79 | socket.emit(socketCommands.DEVICE_DISCONNECT); 80 | } 81 | }]). 82 | 83 | factory('users', ['socket', 'socketCommands', function (socket, socketCommands){ 84 | var users = { 85 | add: add, 86 | remove: remove, 87 | }; 88 | 89 | return users; 90 | 91 | function remove(user) { 92 | socket.emit(socketCommands.USERS_REMOVE, user); 93 | } 94 | 95 | function add(user) { 96 | socket.emit(socketCommands.USERS_ADD, user); 97 | } 98 | 99 | }]). 100 | 101 | factory('entries', ['socket', 'socketCommands', function (socket, socketCommands){ 102 | var entries = { 103 | add: add, 104 | remove: remove, 105 | getUserEntries: getUserEntries, 106 | }; 107 | 108 | return entries; 109 | 110 | function add(user, weight) { 111 | socket.emit(socketCommands.ENTRIES_ADD, {userName: user.name, weight: weight}); 112 | } 113 | 114 | function remove(entry) { 115 | socket.emit(socketCommands.ENTRIES_REMOVE, entry); 116 | } 117 | 118 | function getUserEntries(user) { 119 | socket.emit(socketCommands.ENTRIES_USER, user); 120 | } 121 | 122 | }]); 123 | 124 | })(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wii-Scale 2 | 3 | Wii-Scale turns your Wii Balance Board into a digital scale. Wii-Scale will automatically find your Wii Balance Board when it is connected to your computer. All you have to do is just stand on it :) No boring console interface, watch your weight being calculated in realtime on a beautiful web insterface. 4 | 5 | You can also create multiple users for the whole family and see each members weight history. Wii-Scale runs on Linux and it also runs on a Raspberry Pi. 6 | 7 | ![Wii-Scale](https://github.com/aelveborn/Wii-Scale/blob/gh-pages/images/wiiscale_0_0_4_start.png?raw=true) 8 | 9 | Wii-Scale is based on C++, node.js, AngularJS and communicates over the lightning fast WebSocket protocol. 10 | 11 | ## Usage 12 | 13 | Before you can use Wii-Scale, you need to have your balance board paired with your computer and connected. To start, just press the green "Connect" button in Wii-Scale and follow the on-screen prompts in the web interface. 14 | 15 | ![Wii-Scale scanning for Wii Balance Board](https://github.com/aelveborn/Wii-Scale/blob/gh-pages/images/wiiscale_0_0_4_measuring.png?raw=true) 16 | 17 | The weight is calculated by taking the mean of 50 readings. Wii-Scale will ignore all weights under 30 kg to give you the most accurate reading possible. Oh, and all this will take about 3 seconds. 18 | 19 | ## Installation 20 | 21 | Wii-Scale runs most likely only on Linux. Follow these guides to install Wii-Scale on Ubuntu or Raspberry Pi: 22 | 23 | - [How to install Wii-Scale on Ubuntu](https://github.com/aelveborn/Wii-Scale/wiki/Guide:-How-to-install-Wii-Scale-on-Ubuntu) 24 | - [How to install Wii-Scale on Raspberry Pi](https://github.com/aelveborn/Wii-Scale/wiki/Guide:-How-to-install-Wii-Scale-on-Raspberry-Pi) 25 | 26 | To communicate with your Wii Balance Board you'll need a bluetooth 2.0 or 2.1 compatible device. You can find [compatible devices here](http://wiibrew.org/wiki/List_of_Working_Bluetooth_Devices). Wii-Scale is based on the following dependencies `Python 2`, `Python-pip` and `Node.js with npm` and `BlueZ` bluetooth stack. 27 | 28 | 29 | ### Install Wii-Scale 30 | 31 | Download latest version of Wii-Scale: 32 | 33 | cd / 34 | git clone https://github.com/aelveborn/Wii-Scale.git --recursive --depth 1 35 | cd Wii-Scale/ 36 | 37 | Allow non-root users to access balance board: 38 | 39 | sudo cp wii-scale/70-wii-scales.rules /etc/udev/rules.d/ 40 | 41 | Run install: 42 | 43 | mkdir build && cd build 44 | cmake ../wii-scale && make 45 | npm install --production 46 | 47 | 48 | ### Run 49 | 50 | npm start 51 | 52 | Now the web server and Wii-Scale should be up and running at [http://localhost:8080](http://localhost:8080) 53 | 54 | ## Configuration (optional) 55 | 56 | You can configure a different host, port and calibration. 57 | 58 | ### Access the web interface from other computers 59 | 60 | To open up the web server to be accessable from the outside, like if you'll running Wii-Scale on an Raspberry Pi or a server: 61 | 62 | npm config set wii-scale:host 0.0.0.0 63 | 64 | ### Web server port 65 | 66 | Define a custom port for the webserver (default is 8080): 67 | 68 | npm config set wii-scale:port 8080 69 | 70 | ### Webserver host 71 | 72 | Define a different host for the webserver (default is localhost): 73 | 74 | npm config set wii-scale:host localhost 75 | 76 | ### Calibrate Wii-Scale 77 | 78 | If the scales weight is off by any amout you can calibrate it by your own by setting the calibration i Kg. So `npm config set wii-scale:calibrate 2`will add 2kg to your weight, default is set to 0. 79 | 80 | npm config set wii-scale:calibrate 0 81 | 82 | 83 | ## Update 84 | 85 | To update Wii-Scale, grab the latest version from GitHub: 86 | 87 | cd /Wii-Scale 88 | git pull origin master 89 | 90 | Update Wii-Scale by running install: 91 | 92 | cd build 93 | make 94 | npm install --production 95 | 96 | 97 | ## For developers 98 | 99 | If you whant to make a code contribution, run a `grunt clean-build` before you commit and create a pull request. 100 | 101 | ### Developer install 102 | 103 | If you are a developer you can install Wii-Scale with all developer dependecies: 104 | 105 | sudo python setup.py install 106 | sudo npm install 107 | 108 | If you are a developer and whant to contribute to the project, then this is some nice commands to know about. 109 | 110 | Run: 111 | 112 | npm start 113 | 114 | Run all tests: 115 | 116 | npm test 117 | 118 | Grunt commands: 119 | 120 | grunt 121 | grunt build 122 | grunt clean-build 123 | 124 | `grunt` will run `grunt watch` and build the whole project. 125 | 126 | ## Libraries 127 | 128 | Wii-Scale uses the [xwiimote](https://github.com/dvdhrm/xwiimote), [socket.io-client-cpp](https://github.com/socketio/socket.io-client-cpp), [glibmm / giomm](https://developer.gnome.org/glibmm) and [libudev](https://www.freedesktop.org/software/systemd/man/libudev.html) libraries. 129 | 130 | 131 | ## Licence 132 | 133 | Wii-Scale is created and copyrighted by [Andreas Älveborn](http://aelveborn.com) and lincensed under GPL v2. 134 | -------------------------------------------------------------------------------- /web/public/source/less/build.less: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | // Bootstrap 24 | // -------------------------------------------------- 25 | 26 | // Core variables and mixins 27 | @import "../../../../node_modules/bootstrap/less/variables.less"; 28 | @import "../../../../node_modules/bootstrap/less/mixins.less"; 29 | 30 | // Reset and dependencies 31 | @import "../../../../node_modules/bootstrap/less/normalize.less"; 32 | @import "../../../../node_modules/bootstrap/less/print.less"; 33 | //@import "../../../../node_modules/bootstrap/less/glyphicons.less"; 34 | 35 | // Core CSS 36 | @import "../../../../node_modules/bootstrap/less/scaffolding.less"; 37 | @import "../../../../node_modules/bootstrap/less/type.less"; 38 | //@import "../../../../node_modules/bootstrap/less/code.less"; 39 | @import "../../../../node_modules/bootstrap/less/grid.less"; 40 | //@import "../../../../node_modules/bootstrap/less/tables.less"; 41 | @import "../../../../node_modules/bootstrap/less/forms.less"; 42 | @import "../../../../node_modules/bootstrap/less/buttons.less"; 43 | 44 | // Components 45 | //@import "../../../../node_modules/bootstrap/less/component-animations.less"; 46 | @import "../../../../node_modules/bootstrap/less/dropdowns.less"; 47 | @import "../../../../node_modules/bootstrap/less/button-groups.less"; 48 | @import "../../../../node_modules/bootstrap/less/input-groups.less"; 49 | @import "../../../../node_modules/bootstrap/less/navs.less"; 50 | @import "../../../../node_modules/bootstrap/less/navbar.less"; 51 | //@import "../../../../node_modules/bootstrap/less/breadcrumbs.less"; 52 | //@import "../../../../node_modules/bootstrap/less/pagination.less"; 53 | //@import "../../../../node_modules/bootstrap/less/pager.less"; 54 | @import "../../../../node_modules/bootstrap/less/labels.less"; 55 | @import "../../../../node_modules/bootstrap/less/badges.less"; 56 | //@import "../../../../node_modules/bootstrap/less/jumbotron.less"; 57 | //@import "../../../../node_modules/bootstrap/less/thumbnails.less"; 58 | //@import "../../../../node_modules/bootstrap/less/alerts.less"; 59 | @import "../../../../node_modules/bootstrap/less/progress-bars.less"; 60 | //@import "../../../../node_modules/bootstrap/less/media.less"; 61 | @import "../../../../node_modules/bootstrap/less/list-group.less"; 62 | //@import "../../../../node_modules/bootstrap/less/panels.less"; 63 | //@import "../../../../node_modules/bootstrap/less/responsive-embed.less"; 64 | //@import "../../../../node_modules/bootstrap/less/wells.less"; 65 | @import "../../../../node_modules/bootstrap/less/close.less"; 66 | 67 | // Components w/ JavaScript 68 | @import "../../../../node_modules/bootstrap/less/modals.less"; 69 | //@import "../../../../node_modules/bootstrap/less/tooltip.less"; 70 | //@import "../../../../node_modules/bootstrap/less/popovers.less"; 71 | //@import "../../../../node_modules/bootstrap/less/carousel.less"; 72 | 73 | // Utility classes 74 | @import "../../../../node_modules/bootstrap/less/utilities.less"; 75 | @import "../../../../node_modules/bootstrap/less/responsive-utilities.less"; 76 | 77 | 78 | // Font-Awesome 79 | // -------------------------------------------------- 80 | 81 | @import "../../../../node_modules/font-awesome/less/variables.less"; 82 | @import "../../../../node_modules/font-awesome/less/mixins.less"; 83 | @import "../../../../node_modules/font-awesome/less/path.less"; 84 | @import "../../../../node_modules/font-awesome/less/core.less"; 85 | //@import "../../../../node_modules/font-awesome/less/larger.less"; 86 | //@import "../../../../node_modules/font-awesome/less/fixed-width.less"; 87 | //@import "../../../../node_modules/font-awesome/less/list.less"; 88 | //@import "../../../../node_modules/font-awesome/less/bordered-pulled.less"; 89 | @import "../../../../node_modules/font-awesome/less/animated.less"; 90 | //@import "../../../../node_modules/font-awesome/less/rotated-flipped.less"; 91 | //@import "../../../../node_modules/font-awesome/less/stacked.less"; 92 | @import "../../../../node_modules/font-awesome/less/icons.less"; 93 | 94 | 95 | // Chartist 96 | // -------------------------------------------------- 97 | @import "../../../../node_modules/chartist/dist/chartist.min.css"; 98 | 99 | 100 | // Wii-Scale 101 | // -------------------------------------------------- 102 | 103 | @import "variables.less"; 104 | @import "app.less"; -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var expect = require("chai").expect; 24 | 25 | var User = require('../web/server/models/user.js'); 26 | var Users = require('../web/server/models/users.js'); 27 | var Entry = require('../web/server/models/entry.js'); 28 | var Entries = require('../web/server/models/entries.js'); 29 | 30 | var loki = require('lokijs'), 31 | db = new loki('test-data.json'); 32 | 33 | describe("Server", function () { 34 | 35 | describe("User", function () { 36 | 37 | it('should create a user', function() { 38 | var user = new User('John Doe'); 39 | expect(user).to.have.property('name').and.to.equal('John Doe'); 40 | }); 41 | 42 | }); 43 | 44 | describe("Users", function () { 45 | 46 | var users = null; 47 | 48 | beforeEach(function() { 49 | users = new Users(db.addCollection('users')); 50 | }); 51 | 52 | it('should have created a new user instance', function () { 53 | expect(users).to.not.be.equal(null); 54 | }); 55 | 56 | it('should create a new collection if there is none', function () { 57 | expect(users.get()).to.not.equal(null); 58 | }); 59 | 60 | it('should add a user', function() { 61 | users.add(new User("John Doe")); 62 | expect(users.get()).length(1); 63 | }); 64 | 65 | it('should not add two users with the same name', function () { 66 | users.add(new User("John Doe")); 67 | users.add(new User("John Doe")); 68 | expect(users.get()).length(1); 69 | }); 70 | 71 | it('should remove a user', function () { 72 | var user = new User("John Doe"); 73 | 74 | users.add(user); 75 | expect(users.get()).length(1); 76 | 77 | users.remove(user); 78 | expect(users.get()).length(0); 79 | }); 80 | 81 | it('should find a user', function () { 82 | var user = new User("John Doe"); 83 | users.add(user); 84 | 85 | var result = users.findUserByName(user.name); 86 | expect(result).to.have.property('name').and.equal(user.name); 87 | }); 88 | 89 | it('should not find a user', function() { 90 | var user = new User("John Doe"); 91 | users.add(user); 92 | 93 | var result = users.findUserByName(''); 94 | expect(result).to.equal(null); 95 | }); 96 | }); 97 | 98 | describe("Entry", function () { 99 | 100 | it('should create an entry', function () { 101 | var entry = new Entry('John Doe', 30); 102 | expect(entry).to.have.property('userName').and.equal('John Doe'); 103 | expect(entry).to.have.property('weight').and.equal(30); 104 | expect(entry).to.have.property('dateTime').to.be.a('date'); 105 | }); 106 | 107 | }); 108 | 109 | describe("Entries", function () { 110 | 111 | var entries = null; 112 | 113 | beforeEach(function() { 114 | entries = new Entries(db.addCollection('entries')); 115 | }); 116 | 117 | it('should have created a new entries instance', function () { 118 | expect(entries).to.not.be.equal(null); 119 | }); 120 | 121 | it('should create a new collection if there is none', function () { 122 | expect(entries.get()).to.not.equal(null); 123 | }); 124 | 125 | it('should add an entry', function () { 126 | var entry = new Entry('John Doe', 30); 127 | entries.add(entry); 128 | expect(entries.get()).length(1); 129 | }); 130 | 131 | it('should remove entry', function () { 132 | var entry = new Entry('John Doe', 30); 133 | 134 | entries.add(entry); 135 | expect(entries.get()).length(1); 136 | 137 | entries.remove(entry); 138 | expect(entries.get()).length(0); 139 | }); 140 | 141 | it('should remove all entries for user', function () { 142 | var user1 = new User('John Doe'); 143 | var user2 = new User('Jane Doe'); 144 | 145 | entries.add(new Entry(user1.name, 10)); 146 | entries.add(new Entry(user1.name, 20)); 147 | entries.add(new Entry(user2.name, 30)); 148 | 149 | entries.removeUserEntries(user1); 150 | expect(entries.get()).length(1); 151 | }); 152 | 153 | it('should get all users entries', function () { 154 | var user1 = new User('John Doe'); 155 | var user2 = new User('Jane Doe'); 156 | 157 | var entry1 = new Entry(user1.name, 10); 158 | var entry2 = new Entry(user1.name, 20); 159 | var entry3 = new Entry(user2.name, 30); 160 | var entry4 = new Entry(user2.name, 40); 161 | 162 | entries.add(entry1); 163 | entries.add(entry2); 164 | entries.add(entry3); 165 | entries.add(entry4); 166 | 167 | var result = entries.getUserEntries(user1); 168 | 169 | expect(result) 170 | .to.include(entry1) 171 | .and.to.include(entry2) 172 | .and.to.not.include(entry3) 173 | .and.to.not.include(entry4); 174 | }); 175 | 176 | }); 177 | }); -------------------------------------------------------------------------------- /wii-scale/BlueZDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2017 Matt Robinson 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License along 16 | * with this program; if not, write to the Free Software Foundation, Inc., 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "BlueZDevice.h" 24 | 25 | template 26 | retType GetPropertyValue(Glib::VariantBase properties, const std::string &name) 27 | { 28 | Glib::VariantIter valuePairsIter(properties); 29 | Glib::VariantContainerBase container; 30 | 31 | while(valuePairsIter.next_value(container)) 32 | { 33 | Glib::Variant valueName; 34 | container.get_child(valueName, 0); 35 | 36 | if(valueName.get() != name) 37 | { 38 | continue; 39 | } 40 | 41 | Glib::Variant valueOuter; 42 | container.get_child(valueOuter, 1); 43 | 44 | Glib::Variant value; 45 | valueOuter.get(value); 46 | 47 | return value.get(); 48 | } 49 | 50 | return retType(); 51 | } 52 | 53 | BlueZDevice::BlueZDevice(const std::string &address, const std::string &name) 54 | { 55 | if(address.empty() && name.empty()) 56 | { 57 | throw std::invalid_argument("both address and name are empty - one is required"); 58 | } 59 | 60 | Gio::init(); 61 | 62 | try 63 | { 64 | auto managerProxy = Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SYSTEM, 65 | "org.bluez", 66 | "/", 67 | "org.freedesktop.DBus.ObjectManager"); 68 | 69 | auto managedObjs = managerProxy->call_sync("GetManagedObjects"); 70 | 71 | Glib::VariantIter objectsIter(managedObjs.get_child()); 72 | Glib::VariantContainerBase container; 73 | 74 | while(objectsIter.next_value(container)) 75 | { 76 | Glib::Variant objectPath; 77 | container.get_child(objectPath, 0); 78 | 79 | Glib::VariantIter objectPairsIter(container.get_child(1)); 80 | 81 | while(objectPairsIter.next_value(container)) 82 | { 83 | Glib::Variant key; 84 | container.get_child(key, 0); 85 | 86 | if(key.get() != "org.bluez.Device1") 87 | { 88 | continue; 89 | } 90 | 91 | auto properties = container.get_child(1); 92 | 93 | if(!GetPropertyValue(properties, "Connected")) 94 | { 95 | continue; 96 | } 97 | 98 | if(address.empty()) 99 | { 100 | std::string checkName = GetPropertyValue(properties, "Name"); 101 | 102 | if(checkName.empty()) 103 | { 104 | continue; 105 | } 106 | 107 | if(checkName == name) 108 | { 109 | this->path = objectPath.get(); 110 | return; 111 | } 112 | } 113 | else 114 | { 115 | std::string checkAddr = GetPropertyValue(properties, "Address"); 116 | 117 | if(checkAddr.empty()) 118 | { 119 | continue; 120 | } 121 | 122 | if(strcasecmp(checkAddr.c_str(), address.c_str()) == 0) 123 | { 124 | this->path = objectPath.get(); 125 | return; 126 | } 127 | } 128 | } 129 | } 130 | } 131 | catch(Gio::DBus::Error &dbusError) 132 | { 133 | // Dump details of the DBus error to stderr to aid troubleshooting 134 | std::cerr << dbusError.what() << std::endl; 135 | 136 | throw; 137 | } 138 | 139 | if(address.empty()) 140 | { 141 | throw std::runtime_error("Could not find path for Bluetooth name \"" + name + "\""); 142 | } 143 | else 144 | { 145 | throw std::runtime_error("Could not find path for Bluetooth address \"" + address + "\""); 146 | } 147 | } 148 | 149 | void BlueZDevice::Disconnect() 150 | { 151 | auto devProxy = Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SYSTEM, 152 | "org.bluez", 153 | this->path, 154 | "org.bluez.Device1"); 155 | 156 | devProxy->call_sync("Disconnect"); 157 | } 158 | -------------------------------------------------------------------------------- /gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | module.exports = function (grunt) { 24 | 25 | grunt.initConfig({ 26 | 27 | path: { 28 | root: 'web/', 29 | src: { 30 | root: 'web/public/source/', 31 | less: 'web/public/source/less/', 32 | styles: 'web/public/source/styles/', 33 | scripts: 'web/public/source/scripts/', 34 | images: 'web/public/source/images/', 35 | views: 'web/public/source/views/' 36 | }, 37 | dist: { 38 | root: 'web/public/build/', 39 | styles: 'web/public/build/styles/', 40 | scripts: 'web/public/build/scripts/', 41 | images: 'web/public/build/images/', 42 | views: 'web/public/build/views/' 43 | }, 44 | server: { 45 | root: 'web/server/' 46 | }, 47 | vendor: 'node_modules/', 48 | test: 'test/' 49 | }, 50 | 51 | pkg: grunt.file.readJSON('package.json'), 52 | 53 | concat: { 54 | build: { 55 | files: { 56 | '<%= path.dist.scripts %>scripts.js': [ 57 | '<%= path.vendor %>jquery/dist/jquery.js', 58 | '<%= path.vendor %>bootstrap/js/dropdown.js', 59 | '<%= path.vendor %>bootstrap/js/modal.js', 60 | '<%= path.vendor %>angular/angular.js', 61 | '<%= path.vendor %>angular-socket-io/socket.js', 62 | '<%= path.vendor %>angular-route/angular-route.js', 63 | '<%= path.vendor %>angular-animate/angular-animate.js', 64 | '<%= path.vendor %>chartist/dist/chartist.js', 65 | '<%= path.vendor %>chartist-plugin-pointlabels/dist/chartist-plugin-pointlabels.js', 66 | '<%= path.src.scripts %>**/*.js' 67 | ] 68 | } 69 | } 70 | }, 71 | 72 | clean: { 73 | build: { 74 | src: ['<%= path.dist.root %>'] 75 | } 76 | }, 77 | 78 | less: { 79 | build: { 80 | files: { 81 | '<%= path.dist.styles %>site.css': [ '<%= path.src.less %>build.less'] 82 | } 83 | } 84 | }, 85 | 86 | cssmin: { 87 | build: { 88 | files: { 89 | '<%= path.dist.styles %>site.css': [ '<%= path.dist.styles %>site.css' ] 90 | } 91 | } 92 | }, 93 | 94 | jshint: { 95 | build: { 96 | src: ['<%= path.src.scripts %>**/*.js', 'gruntfile.js'] 97 | }, 98 | server: { 99 | src: ['<%= path.server.root %>**/*.js', '<%= path.root %>*.js'] 100 | }, 101 | test: { 102 | src: ['<%= path.test %>**/*.js'] 103 | } 104 | }, 105 | 106 | uglify: { 107 | build: { 108 | src: ['<%= path.dist.scripts %>scripts.js'], 109 | dest: '<%= path.dist.scripts %>scripts.js' 110 | } 111 | }, 112 | 113 | imagemin: { 114 | build: { 115 | files: [{ 116 | expand: true, 117 | cwd: '<%= path.src.images %>', 118 | src: ['**/*.{png,jpg,gif}'], 119 | dest: '<%= path.dist.images %>' 120 | }] 121 | } 122 | }, 123 | 124 | copy: { 125 | build: { 126 | expand: true, 127 | cwd: '<%= path.src.root %>', 128 | src: ['**', '!**/less/**', '!**/images/**', '!**/scripts/**'], 129 | dest: '<%= path.dist.root %>' 130 | }, 131 | fontawesome: { 132 | expand: true, 133 | cwd: '<%= path.vendor %>/font-awesome/fonts/', 134 | src: '**', 135 | dest: '<%= path.dist.root %>/fonts/' 136 | } 137 | }, 138 | 139 | simplemocha: { 140 | all: { 141 | src: '<%= path.test %>**/*.js' 142 | } 143 | }, 144 | 145 | watch: { 146 | js: { 147 | files: ['<%= path.src.scripts %>**/*.js'], 148 | tasks: ['jshint:build', 'concat', 'uglify'] 149 | }, 150 | js_server: { 151 | files: ['<%= path.server.root %>**/*.js', '<%= path.root %>*.js'], 152 | tasks: ['jshint:server', 'simplemocha'] 153 | }, 154 | test: { 155 | files: ['<%= path.test %>**/*.js'], 156 | tasks: ['jshint:test', 'simplemocha'] 157 | }, 158 | less: { 159 | files: ['<%= path.src.less %>**/*.less'], 160 | tasks: ['less', 'cssmin'] 161 | }, 162 | image: { 163 | files: ['<%= path.src.images %>**/*.{png,jpg,gif}'], 164 | tasks: ['imagemin'] 165 | } 166 | } 167 | 168 | }); 169 | 170 | grunt.loadNpmTasks('grunt-contrib-jshint'); 171 | grunt.loadNpmTasks('grunt-contrib-uglify'); 172 | grunt.loadNpmTasks('grunt-contrib-watch'); 173 | grunt.loadNpmTasks('grunt-contrib-imagemin'); 174 | grunt.loadNpmTasks('grunt-contrib-cssmin'); 175 | grunt.loadNpmTasks('grunt-contrib-clean'); 176 | grunt.loadNpmTasks('grunt-contrib-copy'); 177 | grunt.loadNpmTasks('grunt-contrib-less'); 178 | grunt.loadNpmTasks('grunt-contrib-concat'); 179 | grunt.loadNpmTasks('grunt-simple-mocha'); 180 | 181 | grunt.registerTask('default', ['build', 'watch']); 182 | grunt.registerTask('build', ['less', 'cssmin', 'jshint:build', 'jshint:test', 'simplemocha', 'concat', 'uglify', 'imagemin', 'copy']); 183 | grunt.registerTask('clean-build', ['clean', 'build']); 184 | 185 | }; -------------------------------------------------------------------------------- /web/server/routes/socket.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | var Entry = require('../models/entry.js'); 24 | var Entries = require('../models/entries.js'); 25 | var User = require('../models/user.js'); 26 | var Users = require('../models/users.js'); 27 | 28 | var users = null; 29 | var entries = null; 30 | var NO_PREVIOUS_STATUS = "NO PREVIOUS STATUS"; 31 | 32 | 33 | // Database 34 | 35 | var loki = require('lokijs'), 36 | db = new loki('app-data.json', { 37 | autoload: true, 38 | autoloadCallback: loadHandler 39 | }); 40 | 41 | function loadUsers () { 42 | var userColl = db.getCollection('users'); 43 | if(userColl === null) { 44 | userColl = db.addCollection('users'); 45 | } 46 | users = new Users(userColl); 47 | } 48 | 49 | function loadEntries () { 50 | var entriesColl = db.getCollection('entries'); 51 | if(entriesColl === null) { 52 | entriesColl = db.addCollection('entries'); 53 | } 54 | entries = new Entries(entriesColl); 55 | } 56 | 57 | function loadHandler () { 58 | // Users 59 | loadUsers(); 60 | 61 | // Entries 62 | loadEntries(); 63 | } 64 | 65 | 66 | module.exports = function(io) { 67 | 68 | var cmd = Object.freeze({ 69 | SOCKET_CONNECT: 'connect', 70 | SOCKET_DISCONNECT: 'disconnect', 71 | 72 | DEVICE_RCV_CONNECT: 'device connect', 73 | DEVICE_RCV_DISCONNECT: 'device disconnect', 74 | 75 | CLIENT_RCV_LOAD: 'client load', 76 | 77 | USERS_RCV_ADD: 'users add', 78 | USERS_RCV_REMOVE: 'users remove', 79 | USERS_SEND_LIST: 'users list', 80 | 81 | ENTRIES_RCV_ADD: 'entries add', 82 | ENTRIES_RCV_REMOVE: 'entries delete', 83 | ENTRIES_RCV_USER: 'entries user', 84 | ENTRIES_SEND_LIST: 'entries list', 85 | 86 | WIISCALE_WEIGHT: 'wiiscale-weight', 87 | WIISCALE_STATUS: 'wiiscale-status', 88 | WIISCALE_SEND_CONNECT: 'wiiscale-connect', 89 | WIISCALE_SEND_DISCONNECT: 'wiiscale-disconnect', 90 | }); 91 | 92 | var connectedUsers = -1; // Start at negative one since wii-scale becomes a user 93 | var lastCommand = { status: NO_PREVIOUS_STATUS }; 94 | 95 | io.on(cmd.SOCKET_CONNECT, function(socket) { 96 | 97 | // Server 98 | // ----------------------------------- 99 | 100 | connectedUsers++; 101 | 102 | // Disconnect wii-scale if no users is on the site 103 | socket.on(cmd.SOCKET_DISCONNECT, function() { 104 | connectedUsers--; 105 | if(connectedUsers === 0) { 106 | lastCommand.status = NO_PREVIOUS_STATUS; 107 | io.emit(cmd.WIISCALE_SEND_DISCONNECT); 108 | } 109 | }); 110 | 111 | 112 | // From Client 113 | // ----------------------------------- 114 | 115 | // Send initial data to client 116 | socket.on(cmd.CLIENT_RCV_LOAD, function () { 117 | // Send all saved entries to the user 118 | socket.emit(cmd.USERS_SEND_LIST, users.get()); 119 | 120 | // Send current status to new users 121 | socket.emit(cmd.WIISCALE_STATUS, lastCommand); 122 | }); 123 | 124 | // Connecto to hardware 125 | socket.on(cmd.DEVICE_RCV_CONNECT, function() { 126 | io.emit(cmd.WIISCALE_SEND_CONNECT); 127 | }); 128 | 129 | // Disconnect device harware 130 | socket.on(cmd.DEVICE_RCV_DISCONNECT, function() { 131 | io.emit(cmd.WIISCALE_SEND_DISCONNECT); 132 | }); 133 | 134 | // Save a new entry for user 135 | // params.userName string 136 | // params.weight int 137 | socket.on(cmd.ENTRIES_RCV_ADD, function(params) { 138 | var item = new Entry(params.userName, params.weight); 139 | entries.add(item); 140 | db.saveDatabase(); 141 | 142 | var user = new User(params.userName); 143 | socket.emit(cmd.ENTRIES_SEND_LIST, entries.getUserEntries(user)); 144 | }); 145 | 146 | // Remove entry 147 | // entry entry 148 | socket.on(cmd.ENTRIES_RCV_REMOVE, function(entry) { 149 | entries.remove(entry); 150 | db.saveDatabase(); 151 | 152 | var user = new User(entry.userName); 153 | socket.emit(cmd.ENTRIES_SEND_LIST, entries.getUserEntries(user)); 154 | }); 155 | 156 | // Requests all entries for the user 157 | // params.name string 158 | socket.on(cmd.ENTRIES_RCV_USER, function(params) { 159 | var user = new User(params.name); 160 | socket.emit(cmd.ENTRIES_SEND_LIST, entries.getUserEntries(user)); 161 | }); 162 | 163 | // Save new user 164 | // params.name string 165 | socket.on(cmd.USERS_RCV_ADD, function(params) { 166 | if(users.findUserByName(params.name) === null) { 167 | users.add(new User(params.name)); 168 | db.saveDatabase(); 169 | socket.emit(cmd.USERS_SEND_LIST, users.get()); 170 | } else { 171 | // TODO: "User already exist" 172 | } 173 | }); 174 | 175 | // Remove user 176 | // params.name string 177 | socket.on(cmd.USERS_RCV_REMOVE, function(params) { 178 | var user = users.findUserByName(params.name); 179 | if(user !== null) { 180 | users.remove(user); 181 | db.saveDatabase(); 182 | socket.emit(cmd.USERS_SEND_LIST, users.get()); 183 | } else { 184 | // TODO: "Could not find user" 185 | } 186 | }); 187 | 188 | 189 | // From Wii-Scale 190 | // ----------------------------------- 191 | 192 | // Status from wii-scale 193 | // data.status string 194 | socket.on(cmd.WIISCALE_STATUS, function(data){ 195 | io.emit(cmd.WIISCALE_STATUS, data); 196 | latestStatus = data; 197 | }); 198 | 199 | // Measured weight from wii-scale 200 | // data.totalWeight int 201 | socket.on(cmd.WIISCALE_WEIGHT, function(data){ 202 | io.emit(cmd.WIISCALE_WEIGHT, data); 203 | }); 204 | }); 205 | 206 | }; -------------------------------------------------------------------------------- /web/public/views/partials/start.html: -------------------------------------------------------------------------------- 1 | 22 |
23 | 24 | 91 | 92 |
93 | 94 |
95 |
96 | 97 | 98 |

99 | Start by clicking the green Connect button 100 |

101 |
102 | 103 | 104 | 105 |

106 | Connecting to your Wii Balance Board 107 |

108 |
109 | 110 | 111 | 112 |

113 | Step on your board now 114 |

115 |
116 | 117 | 118 | 119 |

120 | Measuring 121 |

122 |
123 | 124 | 125 | 126 |

127 | Done! 128 |

129 |
130 | 131 | 132 | 133 |

134 | Disconnecting 135 |

136 |
137 | 138 | 139 | 140 |

141 | Could not find Wii Balance Board. Make sure that it is paired and connected. 142 |

143 |
144 | 145 |
146 |
147 | 148 |
149 | 150 |
151 | 152 |
153 | 154 |
155 |
156 | {{ measuring.weight | number:1 }} 157 | kg 158 |
159 |
160 | 161 |
162 |

163 | 164 | History for {{ selectedUser.name }} 165 |

166 | 167 |
168 | 169 |
170 | 171 |
172 |
173 | 174 |
175 |
176 |
177 | 178 |
179 | -------------------------------------------------------------------------------- /wii-scale/wii-scale.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of Wii-Scale 3 | * Copyright © 2015 Andreas Älveborn 4 | * Copyright © 2016-2017 Matt Robinson 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include "XWiiMonitor.h" 33 | 34 | namespace options = boost::program_options; 35 | 36 | sio::socket::ptr current_socket; 37 | std::unique_ptr board; 38 | 39 | const int sensitivity = 3000; // as 10ths of a kg 40 | 41 | // Number of standard deviations less than the mean to discard at start 42 | const int stdDevCutoff = 2; 43 | 44 | void send_status(const std::string &status) 45 | { 46 | auto object = sio::object_message::create(); 47 | std::static_pointer_cast(object)->insert("status", status); 48 | current_socket->emit("wiiscale-status", object); 49 | } 50 | 51 | void send_weight(std::deque *totals, double calibrate) 52 | { 53 | static std::chrono::high_resolution_clock::time_point lastTime; 54 | std::chrono::milliseconds ms = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - lastTime); 55 | 56 | if(ms.count() < 50) 57 | { 58 | // Only send the weight every 50 milliseconds 59 | return; 60 | } 61 | 62 | lastTime = std::chrono::high_resolution_clock::now(); 63 | 64 | // First, calculate the mean 65 | double mean = std::accumulate(totals->begin(), totals->end(), 0.0) / totals->size(); 66 | 67 | // Next, calculate the standard deviation 68 | uint32_t variance = 0; 69 | 70 | for(auto iter = totals->begin(); iter != totals->end(); ++iter) 71 | { 72 | variance += pow(*iter - mean, 2); 73 | } 74 | 75 | variance /= totals->size(); 76 | double stdev = sqrt(variance); 77 | 78 | /* Finally, discard any values from the start of measuring that are 79 | * significantly lower from the average than the standard deviation. 80 | * This prevents values generated when stepping on to the balance board 81 | * from dragging the mean down irrespective of how quickly the user steps. 82 | */ 83 | double threshold = (mean - (stdev * stdDevCutoff)); 84 | 85 | while(totals->at(0) < threshold) 86 | { 87 | totals->pop_front(); 88 | } 89 | 90 | auto value = sio::double_message::create(((double)mean / 100) + calibrate); 91 | auto object = sio::object_message::create(); 92 | std::static_pointer_cast(object)->insert("totalWeight", value); 93 | 94 | current_socket->emit("wiiscale-weight", object); 95 | } 96 | 97 | std::unique_ptr connect() 98 | { 99 | XWiiMonitor monitor; 100 | std::unique_ptr device; 101 | 102 | while(device = monitor.Poll()) 103 | { 104 | if(!device->HasBalanceBoard()) 105 | { 106 | // Not a balance board, try the next device 107 | continue; 108 | } 109 | 110 | device->EnableBalanceBoard(); 111 | return device; 112 | } 113 | 114 | return nullptr; 115 | } 116 | 117 | int main(int argc, const char* argv[]) 118 | { 119 | std::string host = "localhost"; 120 | int port = 8080; 121 | double calibrate = 0; 122 | 123 | options::options_description desc("wii-scale"); 124 | 125 | desc.add_options() 126 | ("help", "Show this help") 127 | ("host,h", options::value(&host), "host") 128 | ("port,p", options::value(&port), "port") 129 | ("calibrate,c", options::value(&calibrate), "calibration kg") 130 | ; 131 | 132 | options::variables_map map; 133 | options::store(options::parse_command_line(argc, argv, desc), map); 134 | options::notify(map); 135 | 136 | if (map.count("help")) { 137 | std::cout << desc << "\n"; 138 | return 1; 139 | } 140 | 141 | std::cout << "Wii-Scale started" << std::endl; 142 | 143 | sio::client client; 144 | client.connect("http://" + host + ":" + std::to_string(port)); 145 | current_socket = client.socket(); 146 | 147 | bool ready = false; 148 | bool firstStep; 149 | std::deque total; 150 | 151 | current_socket->on("wiiscale-connect", [&](sio::event& ev) 152 | { 153 | send_status("CONNECTING"); 154 | board = connect(); 155 | 156 | send_status(board ? "CONNECTED" : "NO DEVICE FOUND"); 157 | }); 158 | 159 | current_socket->on("wiiscale-disconnect", [&](sio::event& ev) 160 | { 161 | if(board) 162 | { 163 | board->Disconnect(); 164 | } 165 | }); 166 | 167 | // Scale 168 | for(;;) 169 | { 170 | if(!board) 171 | { 172 | // Waiting for connection or command 173 | usleep(100000); 174 | continue; 175 | } 176 | 177 | // Post ready status once 178 | if(!ready) 179 | { 180 | firstStep = true; 181 | total.clear(); 182 | 183 | ready = true; 184 | send_status("READY"); 185 | } 186 | 187 | struct xwii_event event; 188 | board->Dispatch(XWII_EVENT_WATCH | XWII_EVENT_BALANCE_BOARD, &event); 189 | 190 | if(event.type == XWII_EVENT_WATCH) 191 | { 192 | // Board has disconnected 193 | send_status("DISCONNECTED"); 194 | 195 | board = nullptr; 196 | continue; 197 | } 198 | 199 | // Measure weight 200 | uint32_t totalWeight = 0; 201 | 202 | for(int i = 0; i < 4; i++) 203 | { 204 | totalWeight += event.v.abs[i].x; 205 | } 206 | 207 | if(totalWeight <= sensitivity) 208 | { 209 | if(!firstStep) 210 | { 211 | ready = false; 212 | send_status("DONE"); 213 | } 214 | 215 | continue; 216 | } 217 | 218 | if(firstStep) 219 | { 220 | firstStep = false; 221 | send_status("MEASURING"); 222 | } 223 | 224 | total.push_back(totalWeight); 225 | send_weight(&total, calibrate); 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /web/public/source/scripts/controllers.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | (function() { 24 | 'use strict'; 25 | 26 | angular.module('app.controllers', []). 27 | 28 | controller('StartController', ['$scope', '$rootScope', 'socket', 'socketCommands', 'device', 'entries', function ($scope, $rootScope, socket, socketCommands, device, entries) { 29 | 30 | $scope.measuring = { 31 | count: 0, 32 | complete: 50, 33 | progress: 0, 34 | weight: 0 35 | }; 36 | 37 | $scope.status = { 38 | 39 | start: false, 40 | search: false, 41 | ready: false, 42 | measuring: false, 43 | done: false, 44 | disconnecting: false, 45 | warning: false, 46 | 47 | dismiss: function() { 48 | this.start = false; 49 | this.search = false; 50 | this.ready = false; 51 | this.measuring = false; 52 | this.done = false; 53 | this.disconnecting = false; 54 | this.warning = false; 55 | } 56 | }; 57 | 58 | $scope.controls = { 59 | connect: true, 60 | disconnect: false 61 | }; 62 | 63 | var init = function() { 64 | reset(); 65 | $scope.controls.connect = true; 66 | $scope.controls.disconnect = false; 67 | 68 | $scope.status.dismiss(); 69 | $scope.status.start = true; 70 | }; 71 | 72 | function reset() { 73 | $scope.measuring.count = 0; 74 | $scope.measuring.complete = 50; 75 | $scope.measuring.progress = 0; 76 | setProgress(); 77 | } 78 | 79 | function done() { 80 | return $scope.measuring.count >= $scope.measuring.complete; 81 | } 82 | 83 | function setProgress() { 84 | var progress = Math.round(($scope.measuring.count / $scope.measuring.complete) * 100); 85 | if(progress <= 100) { 86 | $scope.measuring.progress = progress; 87 | } 88 | } 89 | 90 | 91 | // Device 92 | 93 | $scope.connect = function() { 94 | device.connect(); 95 | }; 96 | 97 | $scope.disconnect = function() { 98 | device.disconnect(); 99 | 100 | $scope.status.dismiss(); 101 | $scope.status.disconnecting = true; 102 | }; 103 | 104 | 105 | // From wii-scale 106 | 107 | function weightReading(totalWeight) { 108 | if(!done()) { 109 | $scope.measuring.weight = totalWeight; 110 | } else if ($scope.measuring.count === $scope.measuring.complete) { 111 | $scope.measuring.weight = totalWeight; 112 | 113 | entries.add($rootScope.selectedUser, totalWeight); 114 | 115 | $scope.status.dismiss(); 116 | $scope.status.done = true; 117 | } 118 | 119 | setProgress(); 120 | $scope.measuring.count++; 121 | } 122 | 123 | 124 | // Socket 125 | 126 | socket.on(socketCommands.ENTRIES_RECEIVE_LIST, function(data) { 127 | if(data !== null && data !== undefined) { 128 | $scope.entries = {}; 129 | $scope.entries.list = data; 130 | } 131 | }); 132 | 133 | socket.on(socketCommands.WIISCALE_WEIGHT, function(data){ 134 | weightReading(data.totalWeight.toFixed(1)); 135 | }); 136 | 137 | socket.on(socketCommands.WIISCALE_STATUS, function(data) { 138 | switch(data.status) { 139 | case "CONNECTING": 140 | $scope.status.dismiss(); 141 | $scope.status.search = true; 142 | 143 | $scope.controls.connect = false; 144 | $scope.controls.disconnect = true; 145 | break; 146 | 147 | case "NO DEVICE FOUND": 148 | $scope.status.dismiss(); 149 | $scope.status.warning = true; 150 | 151 | $scope.controls.connect = true; 152 | $scope.controls.disconnect = false; 153 | break; 154 | 155 | case "CONNECTED": 156 | reset(); 157 | $scope.status.dismiss(); 158 | $scope.status.ready = true; 159 | 160 | $scope.controls.connect = false; 161 | $scope.controls.disconnect = true; 162 | break; 163 | 164 | case "DISCONNECTED": 165 | $scope.status.dismiss(); 166 | $scope.status.start = true; 167 | 168 | $scope.controls.connect = true; 169 | $scope.controls.disconnect = false; 170 | break; 171 | 172 | case "READY": 173 | $scope.status.dismiss(); 174 | $scope.status.ready = true; 175 | 176 | $scope.controls.connect = false; 177 | $scope.controls.disconnect = true; 178 | break; 179 | 180 | case "MEASURING": 181 | $scope.status.dismiss(); 182 | $scope.status.measuring = true; 183 | 184 | $scope.controls.connect = false; 185 | $scope.controls.disconnect = true; 186 | break; 187 | 188 | case "DONE": 189 | reset(); 190 | break; 191 | 192 | case "NO PREVIOUS STATUS": 193 | init(); 194 | break; 195 | } 196 | }); 197 | 198 | }]). 199 | 200 | controller('UserController', ['$scope', '$rootScope', 'socket', 'socketCommands', 'users', 'entries', function ($scope, $rootScope, socket, socketCommands, users, entries){ 201 | 202 | $scope.users = {}; 203 | 204 | $scope.users.create = function() { 205 | if($scope.users.name !== undefined && $scope.users.name !== "") { 206 | 207 | var user = { 208 | name: $scope.users.name 209 | }; 210 | users.add(user); 211 | 212 | // Clear form 213 | $scope.users.name = ""; 214 | $scope.users.select(user); 215 | 216 | } 217 | }; 218 | 219 | $scope.users.remove = function(user) { 220 | $scope.users.removeUser = user; 221 | }; 222 | 223 | $scope.users.select = function(user) { 224 | $rootScope.selectedUser = user; 225 | entries.getUserEntries(user); 226 | }; 227 | 228 | 229 | // Socket 230 | 231 | socket.on(socketCommands.USERS_RECEIVE_LIST, function(data) { 232 | $scope.users.list = data; 233 | }); 234 | 235 | }]); 236 | 237 | })(); 238 | -------------------------------------------------------------------------------- /web/public/source/less/app.less: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | 24 | // App 25 | body { 26 | background-color: #fdfdfd; 27 | font-family: 'Open Sans', sans-serif; 28 | font-weight: lighter; 29 | } 30 | 31 | h1.promotion { 32 | font-size: 5em; 33 | margin: 80px 0 120px; 34 | } 35 | 36 | h1, h2, h3, h4, h5, h6 { 37 | font-family: 'Open Sans', sans-serif; 38 | font-weight: lighter; 39 | } 40 | 41 | .clearfix { 42 | &:after { 43 | content:""; 44 | display:table; 45 | clear:both; 46 | } 47 | } 48 | 49 | /* Animations */ 50 | .animate-ng-repeat { 51 | 52 | &.ng-enter, 53 | &.ng-leave, 54 | &.ng-move { 55 | -webkit-transition: all linear 0.5s; 56 | transition: all linear 0.5s; 57 | } 58 | 59 | &.ng-enter-stagger, 60 | &.ng-leave-stagger, 61 | &.ng-move-stagger { 62 | /* 50ms between each item being animated after the other */ 63 | -webkit-transition-delay:50ms; 64 | transition-delay:50ms; 65 | 66 | /* this is required here to prevent any CSS inheritance issues */ 67 | -webkit-transition-duration:0; 68 | transition-duration:0; 69 | } 70 | 71 | &.ng-enter { 72 | opacity: 0; 73 | 74 | &.ng-enter-active { 75 | opacity: 1; 76 | } 77 | } 78 | 79 | &.ng-move { 80 | opacity: 0; 81 | 82 | &.ng-move-active { 83 | opacity: 1; 84 | } 85 | } 86 | 87 | &.ng-leave { 88 | opacity: 1; 89 | 90 | &.ng-leave-active { 91 | opacity: 0; 92 | } 93 | } 94 | } 95 | 96 | .animate-ng-show { 97 | opacity: 1; 98 | -webkit-transition: all linear 0.5s; 99 | transition: all linear 0.5s; 100 | 101 | &.animate-fast { 102 | -webkit-transition: all linear 0.2s; 103 | transition: all linear 0.2s; 104 | } 105 | 106 | &.ng-hide-add { 107 | -webkit-transition: none; 108 | transition: none; 109 | } 110 | 111 | &.ng-hide { 112 | opacity: 0; 113 | } 114 | } 115 | 116 | /* Styles */ 117 | .navbar { 118 | border: 0; 119 | margin-bottom: 0; 120 | background: @bg-bar-color; 121 | 122 | .navbar-header { 123 | float: left; 124 | margin-left: 0; 125 | margin-right: 0; 126 | 127 | .navbar-brand:hover { 128 | color: #fff; 129 | } 130 | } 131 | 132 | .navbar-nav.nav-controls { 133 | margin: 0; 134 | float: left; 135 | 136 | li { 137 | float: left; 138 | a { 139 | padding: 16px 15px 15px; 140 | } 141 | } 142 | 143 | &.navbar-right { 144 | float: right !important; 145 | margin-right: -15px; 146 | } 147 | 148 | a { 149 | display: block; 150 | color: #fff !important; 151 | 152 | .fa { 153 | top: 1px; 154 | position: relative; 155 | font-size: 20px; 156 | margin-right: 5px; 157 | } 158 | 159 | &.danger { 160 | background-color: @brand-danger; 161 | &:hover, 162 | &:active, 163 | &:focus, 164 | &:visited { 165 | background-color: darken(@brand-danger, 10%) !important; 166 | } 167 | } 168 | 169 | &.success { 170 | background-color: @brand-success; 171 | &:hover, 172 | &:active, 173 | &:focus, 174 | &:visited { 175 | background-color: darken(@brand-success, 10%) !important; 176 | } 177 | } 178 | } 179 | } 180 | 181 | .navbar-nav.nav-users { 182 | margin: 0; 183 | float: left; 184 | display: inline-block; 185 | 186 | .dropdown { 187 | float: left; 188 | 189 | .dropdown-icon { 190 | top: 1px; 191 | position: relative; 192 | font-size: 17px; 193 | margin-right: 5px; 194 | } 195 | 196 | .dropdown-arrow { 197 | margin-left: 8px; 198 | } 199 | 200 | .dropdown-toggle { 201 | color: #fff; 202 | font-size: 0.9em; 203 | font-weight: bold; 204 | padding: 18px 15px 14px; 205 | 206 | @media (max-width: 767px) { 207 | margin-left: -15px; 208 | } 209 | } 210 | 211 | .dropdown-menu { 212 | li { 213 | position: relative; 214 | 215 | a { 216 | span, i { 217 | padding-top: 13px; 218 | padding-bottom: 13px; 219 | } 220 | 221 | span { 222 | display: block; 223 | margin-right: 40px; 224 | } 225 | 226 | i.fa { 227 | float: right; 228 | position: absolute; 229 | right: 0; 230 | padding-left: 15px; 231 | padding-right: 15px; 232 | 233 | &:hover { 234 | color: @link-hover-color; 235 | } 236 | } 237 | } 238 | 239 | &:hover { 240 | background-color: @bg-complement; 241 | } 242 | 243 | &:hover.dropdown-header, 244 | &:hover:last-child { 245 | background-color: #fff; 246 | } 247 | } 248 | 249 | .divider { 250 | margin-top: 0; 251 | } 252 | 253 | .input-group { 254 | padding: 5px 15px 7px; 255 | .form-control { 256 | height: auto; 257 | font-weight: normal; 258 | } 259 | } 260 | } 261 | 262 | &.open { 263 | .dropdown-toggle { 264 | background-color: #222; 265 | 266 | @media (max-width: 767px) { 267 | display: block; 268 | float: left; 269 | margin-top: -53px; 270 | color: #fff; 271 | background-color: @bg-bar-color; 272 | } 273 | } 274 | 275 | .dropdown-menu { 276 | min-width: 250px; 277 | 278 | @media (max-width: 767px) { 279 | margin: 0 -15px; 280 | background-color: @bg-complement; 281 | 282 | a, 283 | .dropdown-header { 284 | padding-left: 15px; 285 | } 286 | } 287 | } 288 | } 289 | } 290 | } 291 | } 292 | 293 | .status-bar { 294 | min-height: 70px; 295 | padding-top: 30px; 296 | padding-bottom: 20px; 297 | margin-bottom: 0; 298 | text-align: center; 299 | background-color: @bg-complement; 300 | 301 | .status { 302 | i, p { 303 | display: inline-block; 304 | } 305 | 306 | p { 307 | margin-left: 5px; 308 | font-weight: normal; 309 | } 310 | 311 | &.success { 312 | color: darken(@brand-success, 20%); 313 | } 314 | 315 | &.info { 316 | //color: darken(@brand-primary, 10%); 317 | } 318 | 319 | &.warning { 320 | color: darken(@brand-warning, 20%); 321 | } 322 | 323 | &.danger { 324 | color: darken(@brand-danger, 10%); 325 | } 326 | } 327 | } 328 | 329 | .progress { 330 | height: 2px; 331 | margin-bottom: 40px; 332 | } 333 | 334 | .weight { 335 | margin-top: 30px; 336 | text-align: center; 337 | 338 | .value { 339 | font-size: 92px; 340 | 341 | @media (min-width: 768px) { 342 | font-size: 120px; 343 | } 344 | 345 | @media (min-width: 992px) { 346 | font-size: 140px; 347 | } 348 | } 349 | 350 | .unit { 351 | font-size: 32px; 352 | } 353 | 354 | @media (min-width: 768px) { 355 | margin-top: 0; 356 | } 357 | } 358 | 359 | .history { 360 | @media (min-width: 992px) { 361 | margin-top: 15px;//45px; 362 | } 363 | 364 | a.delete { 365 | float: right; 366 | color: #777; 367 | display: inline-block; 368 | margin-left: 10px; 369 | padding: 2px 0px 3px 10px; 370 | line-height: 1; 371 | vertical-align: middle; 372 | white-space: nowrap; 373 | text-align: center; 374 | border-left: 1px solid #ddd; 375 | 376 | &:focus { 377 | outline: none; 378 | } 379 | 380 | &:hover { 381 | color: @link-hover-color; 382 | } 383 | } 384 | 385 | a { 386 | text-decoration: none; 387 | 388 | &.reset, 389 | &.show-more { 390 | text-transform: uppercase; 391 | 392 | .fa { 393 | padding-right: 5px; 394 | } 395 | } 396 | 397 | &.reset { 398 | //float: right; 399 | display: block; 400 | } 401 | } 402 | } 403 | 404 | .icon-heading .fa { 405 | padding-right: 8px; 406 | } 407 | 408 | .label-complement { 409 | background-color: #777; 410 | } 411 | 412 | /* Graph */ 413 | .chart-wrapper { 414 | margin-top: 60px; 415 | } 416 | 417 | .ct-chart { 418 | 419 | .ct-chart-line { 420 | padding-top: 20px; 421 | } 422 | 423 | .ct-label { 424 | font-size: 12px; 425 | font-weight: normal; 426 | fill: rgba(51, 51, 51, 0); 427 | 428 | @media (min-width: 768px) { 429 | fill: rgba(51, 51, 51, 0.5); 430 | } 431 | } 432 | 433 | .ct-label.ct-horizontal.ct-end { 434 | padding-top: 15px; 435 | border-top: solid 1px #ddd; 436 | color: rgba(51, 51, 51, 1); 437 | } 438 | 439 | .ct-series-a .ct-line, .ct-series-a .ct-point { 440 | stroke: @brand-success; 441 | } 442 | 443 | .ct-point { 444 | cursor: pointer; 445 | border: solid 10px transparent; 446 | 447 | &:hover { 448 | stroke: lighten(@brand-success, 10%); 449 | } 450 | } 451 | 452 | } 453 | 454 | .tooltip { 455 | color: #fff; 456 | padding: 3px 8px; 457 | position: absolute; 458 | background-color: rgba(0,0,0,0.5); 459 | border-radius: 3px; 460 | } -------------------------------------------------------------------------------- /web/public/source/scripts/directives.js: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | (function() { 24 | 'use strict'; 25 | 26 | angular.module('app.directives', []). 27 | 28 | directive('progressBar', function(){ 29 | return { 30 | scope: { 31 | progress: '=' 32 | }, 33 | restrict: 'E', 34 | templateUrl: '/directives/progress-bar', 35 | replace: true 36 | }; 37 | }). 38 | 39 | directive('status', function(){ 40 | return { 41 | scope: { 42 | type: '@' 43 | }, 44 | restrict: 'E', 45 | templateUrl: '/directives/status', 46 | replace: true, 47 | transclude: true 48 | }; 49 | }). 50 | 51 | directive('history', ['entries', function (entries){ 52 | return { 53 | scope: { 54 | entries: '=' 55 | }, 56 | restrict: 'E', 57 | templateUrl: '/directives/history', 58 | replace: true, 59 | link: function($scope, iElm, iAttrs, controller) { 60 | 61 | var defaultQuantity = 3; 62 | $scope.quantity = defaultQuantity; 63 | $scope.controls = {}; 64 | $scope.controls.showMore = false; 65 | $scope.controls.showReset = false; 66 | 67 | function controlsHandler() { 68 | if($scope.entries !== undefined) { 69 | if($scope.entries.list.length <= $scope.quantity || $scope.entries.list.length <= defaultQuantity) { 70 | $scope.controls.showMore = false; 71 | } else { 72 | $scope.controls.showMore = true; 73 | } 74 | 75 | if($scope.quantity <= defaultQuantity) { 76 | $scope.controls.showReset = false; 77 | } else { 78 | $scope.controls.showReset = true; 79 | } 80 | } 81 | 82 | if($scope.entries.list.length < defaultQuantity) { 83 | $scope.quantity = defaultQuantity; 84 | } 85 | } 86 | 87 | $scope.controls.more = function() { 88 | $scope.quantity += defaultQuantity; 89 | controlsHandler(); 90 | }; 91 | 92 | $scope.controls.reset = function() { 93 | $scope.quantity = defaultQuantity; 94 | controlsHandler(); 95 | }; 96 | 97 | $scope.controls.remove = function(entry) { 98 | $scope.removeEntry = entry; 99 | }; 100 | 101 | $scope.$watch('entries.list.length', function(newValue, oldValue) { 102 | if(newValue === oldValue) { 103 | return; 104 | } 105 | controlsHandler(); 106 | }); 107 | } 108 | }; 109 | }]). 110 | 111 | directive('deleteUserModal', ['$rootScope', 'entries', 'users', function ($rootScope, entries, users){ 112 | return { 113 | scope: { 114 | user: '=', 115 | }, 116 | restrict: 'E', 117 | templateUrl: '/directives/delete-user-modal', 118 | link: function($scope, iElm, iAttrs, controller) { 119 | 120 | $scope.deleteUser = function(user) { 121 | users.remove(user); 122 | 123 | $rootScope.selectedUser = $rootScope.defaultUser; 124 | entries.getUserEntries($rootScope.defaultUser); 125 | }; 126 | 127 | $scope.$watch(iAttrs.visible, function(value){ 128 | if(value === true) { 129 | $(iElm).modal('show'); 130 | } else { 131 | $(iElm).modal('hide'); 132 | } 133 | }); 134 | 135 | $(iElm).on('shown.bs.modal', function(){ 136 | $scope.$apply(function(){ 137 | $scope.$parent[iAttrs.visible] = true; 138 | }); 139 | }); 140 | 141 | $(iElm).on('hidden.bs.modal', function(){ 142 | $scope.$apply(function(){ 143 | $scope.$parent[iAttrs.visible] = false; 144 | }); 145 | }); 146 | } 147 | }; 148 | }]). 149 | 150 | directive('deleteEntryModal', ['$rootScope', 'entries', 'users', function ($rootScope, entries, users){ 151 | return { 152 | scope: { 153 | entry: '=', 154 | }, 155 | restrict: 'E', 156 | templateUrl: '/directives/delete-entry-modal', 157 | link: function($scope, iElm, iAttrs, controller) { 158 | 159 | $scope.deleteEntry = function(entry) { 160 | entries.remove(entry); 161 | }; 162 | 163 | $scope.$watch(iAttrs.visible, function(value){ 164 | if(value === true) { 165 | $(iElm).modal('show'); 166 | } else { 167 | $(iElm).modal('hide'); 168 | } 169 | }); 170 | 171 | $(iElm).on('shown.bs.modal', function(){ 172 | $scope.$apply(function(){ 173 | $scope.$parent[iAttrs.visible] = true; 174 | }); 175 | }); 176 | 177 | $(iElm).on('hidden.bs.modal', function(){ 178 | $scope.$apply(function(){ 179 | $scope.$parent[iAttrs.visible] = false; 180 | }); 181 | }); 182 | } 183 | }; 184 | }]). 185 | 186 | directive('lineChart', ['$filter', '$rootScope', function ($filter, $rootScope){ 187 | return { 188 | scope: { 189 | entries: '=' 190 | }, 191 | restrict: 'E', 192 | template: '
', 193 | link: function($scope, iElm, iAttrs, controller) { 194 | 195 | function formatDate(date) { 196 | return $filter('date')(date, 'dd/MM'); 197 | } 198 | 199 | var options = { 200 | showPoint: true, 201 | fullWidth: true, 202 | chartPadding: { 203 | bottom: 50, 204 | right: 40, 205 | left: 0 206 | }, 207 | height: 180, 208 | axisX: { 209 | showLabel: true, 210 | labelOffset: { 211 | x: -16, 212 | y: 20 213 | }, 214 | showGrid: false 215 | }, 216 | axisY: { 217 | showLabel: false, 218 | showGrid: false, 219 | }, 220 | }; 221 | 222 | var responsiveOptions = [ 223 | ['screen and (max-width: 767px)', { 224 | axisX: { 225 | showLabel: false 226 | }, 227 | }], 228 | ['screen and (min-width: 768px)', { 229 | axisX: { 230 | showLabel: true 231 | }, 232 | }], 233 | ]; 234 | 235 | 236 | var loadData = function() { 237 | var set = 0; 238 | var data = { 239 | labels: [], 240 | series: [[]] 241 | }; 242 | 243 | var graphStart = Math.min($scope.entries.list.length, 14); 244 | 245 | for (var i = graphStart - 1; i >= 0; i--) { 246 | data.labels.push(formatDate($scope.entries.list[i].dateTime)); 247 | data.series[set].push($scope.entries.list[i].weight); 248 | } 249 | 250 | return data; 251 | }; 252 | 253 | function drawChart(data) { 254 | 255 | // Chart 256 | var chart = new Chartist.Line('.ct-chart', data, options, responsiveOptions); 257 | 258 | // Animation 259 | chart.on('draw', function(data) { 260 | if(data.type === 'line' || data.type === 'area') { 261 | data.element.animate({ 262 | d: { 263 | begin: 2000 * data.index, 264 | dur: 2000, 265 | from: data.path.clone().scale(1, 0).translate(0, data.chartRect.height()).stringify(), 266 | to: data.path.clone().stringify(), 267 | easing: Chartist.Svg.Easing.easeOutQuint 268 | } 269 | }); 270 | } 271 | }); 272 | 273 | // Tooltip 274 | var element = angular.element(chart.container); 275 | var $toolTip = element 276 | .append('
') 277 | .find('.tooltip') 278 | .hide(); 279 | 280 | element.on('mouseenter', '.ct-point', function() { 281 | var $point = $(this); 282 | var value = $point.attr('ct:value'); 283 | 284 | $toolTip.html(value + ' kg').show(); 285 | $toolTip.css({ 286 | left: $point.offset().left - (($toolTip.width() / 2) + 8), 287 | top: $point.offset().top - 40 288 | }); 289 | }); 290 | 291 | element.on('mouseleave', '.ct-point', function() { 292 | $toolTip.hide(); 293 | }); 294 | } 295 | 296 | function removeGraph() { 297 | var chart = angular.element('.ct-chart'); 298 | if(chart !== undefined) { 299 | chart.children().remove(); 300 | } 301 | } 302 | 303 | function updateGraph() { 304 | if($scope.entries.list.length > 1) { 305 | drawChart(loadData()); 306 | } else { 307 | removeGraph(); 308 | } 309 | } 310 | 311 | $scope.$watch('entries.list', function(newValue, oldValue) { 312 | if(newValue === undefined) { 313 | return; 314 | } 315 | 316 | updateGraph(); 317 | }); 318 | 319 | $scope.$watch('$rootScope.selectedUser', function(newValue, oldValue) { 320 | if(newValue === oldValue) { 321 | return; 322 | } 323 | 324 | updateGraph(); 325 | }); 326 | 327 | } 328 | }; 329 | }]); 330 | 331 | })(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /web/public/source/less/variables.less: -------------------------------------------------------------------------------- 1 | /* 2 | Author: Andreas Älveborn 3 | URL: https://github.com/aelveborn/Wii-Scale 4 | 5 | This file is part of Wii-Scale 6 | Copyright (C) 2015 Andreas Älveborn 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 20 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | */ 22 | 23 | // Custom 24 | @bg-complement: #f5f5f5; 25 | @bg-bar-color: #333333; 26 | 27 | // // 28 | // // Variables 29 | // // -------------------------------------------------- 30 | 31 | 32 | // //== Colors 33 | // // 34 | // //## Gray and brand colors for use across Bootstrap. 35 | 36 | // @gray-base: #000; 37 | // @gray-darker: lighten(@gray-base, 13.5%); // #222 38 | // @gray-dark: lighten(@gray-base, 20%); // #333 39 | // @gray: lighten(@gray-base, 33.5%); // #555 40 | // @gray-light: lighten(@gray-base, 46.7%); // #777 41 | // @gray-lighter: lighten(@gray-base, 93.5%); // #eee 42 | 43 | // @brand-primary: darken(#428bca, 6.5%); // #337ab7 44 | // @brand-success: #5cb85c; 45 | // @brand-info: #5bc0de; 46 | // @brand-warning: #f0ad4e; 47 | // @brand-danger: #d9534f; 48 | 49 | 50 | // //== Scaffolding 51 | // // 52 | // //## Settings for some of the most global styles. 53 | 54 | // //** Background color for ``. 55 | // @body-bg: #fff; 56 | // //** Global text color on ``. 57 | // @text-color: @gray-dark; 58 | 59 | // //** Global textual link color. 60 | // @link-color: @brand-primary; 61 | // //** Link hover color set via `darken()` function. 62 | // @link-hover-color: darken(@link-color, 15%); 63 | // //** Link hover decoration. 64 | // @link-hover-decoration: underline; 65 | 66 | 67 | // //== Typography 68 | // // 69 | // //## Font, line-height, and color for body text, headings, and more. 70 | 71 | // @font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; 72 | // @font-family-serif: Georgia, "Times New Roman", Times, serif; 73 | // //** Default monospace fonts for ``, ``, and `
`.
 74 | // @font-family-monospace:   Menlo, Monaco, Consolas, "Courier New", monospace;
 75 | // @font-family-base:        @font-family-sans-serif;
 76 | 
 77 | @font-size-base:          14px;
 78 | // @font-size-large:         ceil((@font-size-base * 1.25)); // ~18px
 79 | // @font-size-small:         ceil((@font-size-base * 0.85)); // ~12px
 80 | 
 81 | // @font-size-h1:            floor((@font-size-base * 2.6)); // ~36px
 82 | // @font-size-h2:            floor((@font-size-base * 2.15)); // ~30px
 83 | // @font-size-h3:            ceil((@font-size-base * 1.7)); // ~24px
 84 | // @font-size-h4:            ceil((@font-size-base * 1.25)); // ~18px
 85 | // @font-size-h5:            @font-size-base;
 86 | // @font-size-h6:            ceil((@font-size-base * 0.85)); // ~12px
 87 | 
 88 | // //** Unit-less `line-height` for use in components like buttons.
 89 | // @line-height-base:        1.428571429; // 20/14
 90 | // //** Computed "line-height" (`font-size` * `line-height`) for use with `margin`, `padding`, etc.
 91 | // @line-height-computed:    floor((@font-size-base * @line-height-base)); // ~20px
 92 | 
 93 | // //** By default, this inherits from the ``.
 94 | // @headings-font-family:    inherit;
 95 | // @headings-font-weight:    500;
 96 | // @headings-line-height:    1.1;
 97 | // @headings-color:          inherit;
 98 | 
 99 | 
100 | // //== Iconography
101 | // //
102 | // //## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower.
103 | 
104 | // //** Load fonts from this directory.
105 | // @icon-font-path:          "../fonts/";
106 | // //** File name for all font files.
107 | // @icon-font-name:          "glyphicons-halflings-regular";
108 | // //** Element ID within SVG icon file.
109 | // @icon-font-svg-id:        "glyphicons_halflingsregular";
110 | 
111 | 
112 | // //== Components
113 | // //
114 | // //## Define common padding and border radius sizes and more. Values based on 14px text and 1.428 line-height (~20px to start).
115 | 
116 | // @padding-base-vertical:     6px;
117 | // @padding-base-horizontal:   12px;
118 | 
119 | // @padding-large-vertical:    10px;
120 | // @padding-large-horizontal:  16px;
121 | 
122 | // @padding-small-vertical:    5px;
123 | // @padding-small-horizontal:  10px;
124 | 
125 | // @padding-xs-vertical:       1px;
126 | // @padding-xs-horizontal:     5px;
127 | 
128 | // @line-height-large:         1.3333333; // extra decimals for Win 8.1 Chrome
129 | // @line-height-small:         1.5;
130 | 
131 | @border-radius-base:        0px;
132 | @border-radius-large:       0px;
133 | @border-radius-small:       0px;
134 | 
135 | // //** Global color for active items (e.g., navs or dropdowns).
136 | // @component-active-color:    #fff;
137 | // //** Global background color for active items (e.g., navs or dropdowns).
138 | // @component-active-bg:       @brand-primary;
139 | 
140 | // //** Width of the `border` for generating carets that indicator dropdowns.
141 | // @caret-width-base:          4px;
142 | // //** Carets increase slightly in size for larger components.
143 | // @caret-width-large:         5px;
144 | 
145 | 
146 | // //== Tables
147 | // //
148 | // //## Customizes the `.table` component with basic values, each used across all table variations.
149 | 
150 | // //** Padding for ``s and ``s.
151 | // @table-cell-padding:            8px;
152 | // //** Padding for cells in `.table-condensed`.
153 | // @table-condensed-cell-padding:  5px;
154 | 
155 | // //** Default background color used for all tables.
156 | // @table-bg:                      transparent;
157 | // //** Background color used for `.table-striped`.
158 | // @table-bg-accent:               #f9f9f9;
159 | // //** Background color used for `.table-hover`.
160 | // @table-bg-hover:                #f5f5f5;
161 | // @table-bg-active:               @table-bg-hover;
162 | 
163 | // //** Border color for table and cell borders.
164 | // @table-border-color:            #ddd;
165 | 
166 | 
167 | // //== Buttons
168 | // //
169 | // //## For each of Bootstrap's buttons, define text, background and border color.
170 | 
171 | // @btn-font-weight:                normal;
172 | 
173 | // @btn-default-color:              #333;
174 | // @btn-default-bg:                 #fff;
175 | // @btn-default-border:             #ccc;
176 | 
177 | // @btn-primary-color:              #fff;
178 | // @btn-primary-bg:                 @brand-primary;
179 | // @btn-primary-border:             darken(@btn-primary-bg, 5%);
180 | 
181 | // @btn-success-color:              #fff;
182 | // @btn-success-bg:                 @brand-success;
183 | // @btn-success-border:             darken(@btn-success-bg, 5%);
184 | 
185 | // @btn-info-color:                 #fff;
186 | // @btn-info-bg:                    @brand-info;
187 | // @btn-info-border:                darken(@btn-info-bg, 5%);
188 | 
189 | // @btn-warning-color:              #fff;
190 | // @btn-warning-bg:                 @brand-warning;
191 | // @btn-warning-border:             darken(@btn-warning-bg, 5%);
192 | 
193 | // @btn-danger-color:               #fff;
194 | // @btn-danger-bg:                  @brand-danger;
195 | // @btn-danger-border:              darken(@btn-danger-bg, 5%);
196 | 
197 | // @btn-link-disabled-color:        @gray-light;
198 | 
199 | // // Allows for customizing button radius independently from global border radius
200 | // @btn-border-radius-base:         @border-radius-base;
201 | // @btn-border-radius-large:        @border-radius-large;
202 | // @btn-border-radius-small:        @border-radius-small;
203 | 
204 | 
205 | // //== Forms
206 | // //
207 | // //##
208 | 
209 | // //** `` background color
210 | // @input-bg:                       #fff;
211 | // //** `` background color
212 | // @input-bg-disabled:              @gray-lighter;
213 | 
214 | // //** Text color for ``s
215 | // @input-color:                    @gray;
216 | // //** `` border color
217 | // @input-border:                   #ccc;
218 | 
219 | // // TODO: Rename `@input-border-radius` to `@input-border-radius-base` in v4
220 | // //** Default `.form-control` border radius
221 | // // This has no effect on ``s in CSS.
222 | // @input-border-radius:            @border-radius-base;
223 | // //** Large `.form-control` border radius
224 | // @input-border-radius-large:      @border-radius-large;
225 | // //** Small `.form-control` border radius
226 | // @input-border-radius-small:      @border-radius-small;
227 | 
228 | // //** Border color for inputs on focus
229 | // @input-border-focus:             #66afe9;
230 | 
231 | // //** Placeholder text color
232 | // @input-color-placeholder:        #999;
233 | 
234 | // //** Default `.form-control` height
235 | // @input-height-base:              (@line-height-computed + (@padding-base-vertical * 2) + 2);
236 | // //** Large `.form-control` height
237 | // @input-height-large:             (ceil(@font-size-large * @line-height-large) + (@padding-large-vertical * 2) + 2);
238 | // //** Small `.form-control` height
239 | // @input-height-small:             (floor(@font-size-small * @line-height-small) + (@padding-small-vertical * 2) + 2);
240 | 
241 | // //** `.form-group` margin
242 | // @form-group-margin-bottom:       15px;
243 | 
244 | // @legend-color:                   @gray-dark;
245 | // @legend-border-color:            #e5e5e5;
246 | 
247 | // //** Background color for textual input addons
248 | // @input-group-addon-bg:           @gray-lighter;
249 | // //** Border color for textual input addons
250 | // @input-group-addon-border-color: @input-border;
251 | 
252 | // //** Disabled cursor for form controls and buttons.
253 | // @cursor-disabled:                not-allowed;
254 | 
255 | 
256 | // //== Dropdowns
257 | // //
258 | // //## Dropdown menu container and contents.
259 | 
260 | // //** Background for the dropdown menu.
261 | // @dropdown-bg:                    #fff;
262 | // //** Dropdown menu `border-color`.
263 | // @dropdown-border:                rgba(0,0,0,.15);
264 | // //** Dropdown menu `border-color` **for IE8**.
265 | // @dropdown-fallback-border:       #ccc;
266 | // //** Divider color for between dropdown items.
267 | // @dropdown-divider-bg:            #e5e5e5;
268 | 
269 | // //** Dropdown link text color.
270 | // @dropdown-link-color:            @gray-dark;
271 | // //** Hover color for dropdown links.
272 | // @dropdown-link-hover-color:      darken(@gray-dark, 5%);
273 | // //** Hover background for dropdown links.
274 | // @dropdown-link-hover-bg:         #f5f5f5;
275 | 
276 | // //** Active dropdown menu item text color.
277 | // @dropdown-link-active-color:     @component-active-color;
278 | // //** Active dropdown menu item background color.
279 | // @dropdown-link-active-bg:        @component-active-bg;
280 | 
281 | // //** Disabled dropdown menu item background color.
282 | // @dropdown-link-disabled-color:   @gray-light;
283 | 
284 | // //** Text color for headers within dropdown menus.
285 | // @dropdown-header-color:          @gray-light;
286 | 
287 | // //** Deprecated `@dropdown-caret-color` as of v3.1.0
288 | // @dropdown-caret-color:           #000;
289 | 
290 | 
291 | // //-- Z-index master list
292 | // //
293 | // // Warning: Avoid customizing these values. They're used for a bird's eye view
294 | // // of components dependent on the z-axis and are designed to all work together.
295 | // //
296 | // // Note: These variables are not generated into the Customizer.
297 | 
298 | // @zindex-navbar:            1000;
299 | // @zindex-dropdown:          1000;
300 | // @zindex-popover:           1060;
301 | // @zindex-tooltip:           1070;
302 | // @zindex-navbar-fixed:      1030;
303 | // @zindex-modal-background:  1040;
304 | // @zindex-modal:             1050;
305 | 
306 | 
307 | // //== Media queries breakpoints
308 | // //
309 | // //## Define the breakpoints at which your layout will change, adapting to different screen sizes.
310 | 
311 | // // Extra small screen / phone
312 | // //** Deprecated `@screen-xs` as of v3.0.1
313 | // @screen-xs:                  480px;
314 | // //** Deprecated `@screen-xs-min` as of v3.2.0
315 | // @screen-xs-min:              @screen-xs;
316 | // //** Deprecated `@screen-phone` as of v3.0.1
317 | // @screen-phone:               @screen-xs-min;
318 | 
319 | // // Small screen / tablet
320 | // //** Deprecated `@screen-sm` as of v3.0.1
321 | // @screen-sm:                  768px;
322 | // @screen-sm-min:              @screen-sm;
323 | // //** Deprecated `@screen-tablet` as of v3.0.1
324 | // @screen-tablet:              @screen-sm-min;
325 | 
326 | // // Medium screen / desktop
327 | // //** Deprecated `@screen-md` as of v3.0.1
328 | // @screen-md:                  992px;
329 | // @screen-md-min:              @screen-md;
330 | // //** Deprecated `@screen-desktop` as of v3.0.1
331 | // @screen-desktop:             @screen-md-min;
332 | 
333 | // // Large screen / wide desktop
334 | // //** Deprecated `@screen-lg` as of v3.0.1
335 | // @screen-lg:                  1200px;
336 | // @screen-lg-min:              @screen-lg;
337 | // //** Deprecated `@screen-lg-desktop` as of v3.0.1
338 | // @screen-lg-desktop:          @screen-lg-min;
339 | 
340 | // // So media queries don't overlap when required, provide a maximum
341 | // @screen-xs-max:              (@screen-sm-min - 1);
342 | // @screen-sm-max:              (@screen-md-min - 1);
343 | // @screen-md-max:              (@screen-lg-min - 1);
344 | 
345 | 
346 | // //== Grid system
347 | // //
348 | // //## Define your custom responsive grid.
349 | 
350 | // //** Number of columns in the grid.
351 | // @grid-columns:              12;
352 | // //** Padding between columns. Gets divided in half for the left and right.
353 | // @grid-gutter-width:         30px;
354 | // // Navbar collapse
355 | // //** Point at which the navbar becomes uncollapsed.
356 | // @grid-float-breakpoint:     @screen-sm-min;
357 | // //** Point at which the navbar begins collapsing.
358 | // @grid-float-breakpoint-max: (@grid-float-breakpoint - 1);
359 | 
360 | 
361 | // //== Container sizes
362 | // //
363 | // //## Define the maximum width of `.container` for different screen sizes.
364 | 
365 | // // Small screen / tablet
366 | // @container-tablet:             (720px + @grid-gutter-width);
367 | // //** For `@screen-sm-min` and up.
368 | // @container-sm:                 @container-tablet;
369 | 
370 | // // Medium screen / desktop
371 | // @container-desktop:            (940px + @grid-gutter-width);
372 | // //** For `@screen-md-min` and up.
373 | // @container-md:                 @container-desktop;
374 | 
375 | // // Large screen / wide desktop
376 | // @container-large-desktop:      (1140px + @grid-gutter-width);
377 | // //** For `@screen-lg-min` and up.
378 | // @container-lg:                 @container-large-desktop;
379 | 
380 | 
381 | // //== Navbar
382 | // //
383 | // //##
384 | 
385 | // // Basics of a navbar
386 | // @navbar-height:                    50px;
387 | // @navbar-margin-bottom:             @line-height-computed;
388 | // @navbar-border-radius:             @border-radius-base;
389 | // @navbar-padding-horizontal:        floor((@grid-gutter-width / 2));
390 | // @navbar-padding-vertical:          ((@navbar-height - @line-height-computed) / 2);
391 | // @navbar-collapse-max-height:       340px;
392 | 
393 | // @navbar-default-color:             #777;
394 | // @navbar-default-bg:                #f8f8f8;
395 | // @navbar-default-border:            darken(@navbar-default-bg, 6.5%);
396 | 
397 | // // Navbar links
398 | // @navbar-default-link-color:                #777;
399 | // @navbar-default-link-hover-color:          #333;
400 | // @navbar-default-link-hover-bg:             transparent;
401 | // @navbar-default-link-active-color:         #555;
402 | // @navbar-default-link-active-bg:            darken(@navbar-default-bg, 6.5%);
403 | // @navbar-default-link-disabled-color:       #ccc;
404 | // @navbar-default-link-disabled-bg:          transparent;
405 | 
406 | // // Navbar brand label
407 | // @navbar-default-brand-color:               @navbar-default-link-color;
408 | // @navbar-default-brand-hover-color:         darken(@navbar-default-brand-color, 10%);
409 | // @navbar-default-brand-hover-bg:            transparent;
410 | 
411 | // // Navbar toggle
412 | // @navbar-default-toggle-hover-bg:           #ddd;
413 | // @navbar-default-toggle-icon-bar-bg:        #888;
414 | // @navbar-default-toggle-border-color:       #ddd;
415 | 
416 | 
417 | // //=== Inverted navbar
418 | // // Reset inverted navbar basics
419 | // @navbar-inverse-color:                      lighten(@gray-light, 15%);
420 | // @navbar-inverse-bg:                         #222;
421 | // @navbar-inverse-border:                     darken(@navbar-inverse-bg, 10%);
422 | 
423 | // // Inverted navbar links
424 | // @navbar-inverse-link-color:                 lighten(@gray-light, 15%);
425 | // @navbar-inverse-link-hover-color:           #fff;
426 | // @navbar-inverse-link-hover-bg:              transparent;
427 | // @navbar-inverse-link-active-color:          @navbar-inverse-link-hover-color;
428 | // @navbar-inverse-link-active-bg:             darken(@navbar-inverse-bg, 10%);
429 | // @navbar-inverse-link-disabled-color:        #444;
430 | // @navbar-inverse-link-disabled-bg:           transparent;
431 | 
432 | // // Inverted navbar brand label
433 | // @navbar-inverse-brand-color:                @navbar-inverse-link-color;
434 | // @navbar-inverse-brand-hover-color:          #fff;
435 | // @navbar-inverse-brand-hover-bg:             transparent;
436 | 
437 | // // Inverted navbar toggle
438 | // @navbar-inverse-toggle-hover-bg:            #333;
439 | // @navbar-inverse-toggle-icon-bar-bg:         #fff;
440 | // @navbar-inverse-toggle-border-color:        #333;
441 | 
442 | 
443 | // //== Navs
444 | // //
445 | // //##
446 | 
447 | // //=== Shared nav styles
448 | // @nav-link-padding:                          10px 15px;
449 | // @nav-link-hover-bg:                         @gray-lighter;
450 | 
451 | // @nav-disabled-link-color:                   @gray-light;
452 | // @nav-disabled-link-hover-color:             @gray-light;
453 | 
454 | // //== Tabs
455 | // @nav-tabs-border-color:                     #ddd;
456 | 
457 | // @nav-tabs-link-hover-border-color:          @gray-lighter;
458 | 
459 | // @nav-tabs-active-link-hover-bg:             @body-bg;
460 | // @nav-tabs-active-link-hover-color:          @gray;
461 | // @nav-tabs-active-link-hover-border-color:   #ddd;
462 | 
463 | // @nav-tabs-justified-link-border-color:            #ddd;
464 | // @nav-tabs-justified-active-link-border-color:     @body-bg;
465 | 
466 | // //== Pills
467 | // @nav-pills-border-radius:                   @border-radius-base;
468 | // @nav-pills-active-link-hover-bg:            @component-active-bg;
469 | // @nav-pills-active-link-hover-color:         @component-active-color;
470 | 
471 | 
472 | // //== Pagination
473 | // //
474 | // //##
475 | 
476 | // @pagination-color:                     @link-color;
477 | // @pagination-bg:                        #fff;
478 | // @pagination-border:                    #ddd;
479 | 
480 | // @pagination-hover-color:               @link-hover-color;
481 | // @pagination-hover-bg:                  @gray-lighter;
482 | // @pagination-hover-border:              #ddd;
483 | 
484 | // @pagination-active-color:              #fff;
485 | // @pagination-active-bg:                 @brand-primary;
486 | // @pagination-active-border:             @brand-primary;
487 | 
488 | // @pagination-disabled-color:            @gray-light;
489 | // @pagination-disabled-bg:               #fff;
490 | // @pagination-disabled-border:           #ddd;
491 | 
492 | 
493 | // //== Pager
494 | // //
495 | // //##
496 | 
497 | // @pager-bg:                             @pagination-bg;
498 | // @pager-border:                         @pagination-border;
499 | // @pager-border-radius:                  15px;
500 | 
501 | // @pager-hover-bg:                       @pagination-hover-bg;
502 | 
503 | // @pager-active-bg:                      @pagination-active-bg;
504 | // @pager-active-color:                   @pagination-active-color;
505 | 
506 | // @pager-disabled-color:                 @pagination-disabled-color;
507 | 
508 | 
509 | // //== Jumbotron
510 | // //
511 | // //##
512 | 
513 | // @jumbotron-padding:              30px;
514 | // @jumbotron-color:                inherit;
515 | // @jumbotron-bg:                   @gray-lighter;
516 | // @jumbotron-heading-color:        inherit;
517 | // @jumbotron-font-size:            ceil((@font-size-base * 1.5));
518 | // @jumbotron-heading-font-size:    ceil((@font-size-base * 4.5));
519 | 
520 | 
521 | // //== Form states and alerts
522 | // //
523 | // //## Define colors for form feedback states and, by default, alerts.
524 | 
525 | // @state-success-text:             #3c763d;
526 | // @state-success-bg:               #dff0d8;
527 | // @state-success-border:           darken(spin(@state-success-bg, -10), 5%);
528 | 
529 | // @state-info-text:                #31708f;
530 | // @state-info-bg:                  #d9edf7;
531 | // @state-info-border:              darken(spin(@state-info-bg, -10), 7%);
532 | 
533 | // @state-warning-text:             #8a6d3b;
534 | // @state-warning-bg:               #fcf8e3;
535 | // @state-warning-border:           darken(spin(@state-warning-bg, -10), 5%);
536 | 
537 | // @state-danger-text:              #a94442;
538 | // @state-danger-bg:                #f2dede;
539 | // @state-danger-border:            darken(spin(@state-danger-bg, -10), 5%);
540 | 
541 | 
542 | // //== Tooltips
543 | // //
544 | // //##
545 | 
546 | // //** Tooltip max width
547 | // @tooltip-max-width:           200px;
548 | // //** Tooltip text color
549 | // @tooltip-color:               #fff;
550 | // //** Tooltip background color
551 | // @tooltip-bg:                  #000;
552 | // @tooltip-opacity:             .9;
553 | 
554 | // //** Tooltip arrow width
555 | // @tooltip-arrow-width:         5px;
556 | // //** Tooltip arrow color
557 | // @tooltip-arrow-color:         @tooltip-bg;
558 | 
559 | 
560 | // //== Popovers
561 | // //
562 | // //##
563 | 
564 | // //** Popover body background color
565 | // @popover-bg:                          #fff;
566 | // //** Popover maximum width
567 | // @popover-max-width:                   276px;
568 | // //** Popover border color
569 | // @popover-border-color:                rgba(0,0,0,.2);
570 | // //** Popover fallback border color
571 | // @popover-fallback-border-color:       #ccc;
572 | 
573 | // //** Popover title background color
574 | // @popover-title-bg:                    darken(@popover-bg, 3%);
575 | 
576 | // //** Popover arrow width
577 | // @popover-arrow-width:                 10px;
578 | // //** Popover arrow color
579 | // @popover-arrow-color:                 @popover-bg;
580 | 
581 | // //** Popover outer arrow width
582 | // @popover-arrow-outer-width:           (@popover-arrow-width + 1);
583 | // //** Popover outer arrow color
584 | // @popover-arrow-outer-color:           fadein(@popover-border-color, 5%);
585 | // //** Popover outer arrow fallback color
586 | // @popover-arrow-outer-fallback-color:  darken(@popover-fallback-border-color, 20%);
587 | 
588 | 
589 | // //== Labels
590 | // //
591 | // //##
592 | 
593 | // //** Default label background color
594 | // @label-default-bg:            @gray-light;
595 | // //** Primary label background color
596 | // @label-primary-bg:            @brand-primary;
597 | // //** Success label background color
598 | // @label-success-bg:            @brand-success;
599 | // //** Info label background color
600 | // @label-info-bg:               @brand-info;
601 | // //** Warning label background color
602 | // @label-warning-bg:            @brand-warning;
603 | // //** Danger label background color
604 | // @label-danger-bg:             @brand-danger;
605 | 
606 | // //** Default label text color
607 | // @label-color:                 #fff;
608 | // //** Default text color of a linked label
609 | // @label-link-hover-color:      #fff;
610 | 
611 | 
612 | // //== Modals
613 | // //
614 | // //##
615 | 
616 | // //** Padding applied to the modal body
617 | // @modal-inner-padding:         15px;
618 | 
619 | // //** Padding applied to the modal title
620 | // @modal-title-padding:         15px;
621 | // //** Modal title line-height
622 | // @modal-title-line-height:     @line-height-base;
623 | 
624 | // //** Background color of modal content area
625 | // @modal-content-bg:                             #fff;
626 | // //** Modal content border color
627 | // @modal-content-border-color:                   rgba(0,0,0,.2);
628 | // //** Modal content border color **for IE8**
629 | // @modal-content-fallback-border-color:          #999;
630 | 
631 | // //** Modal backdrop background color
632 | // @modal-backdrop-bg:           #000;
633 | // //** Modal backdrop opacity
634 | // @modal-backdrop-opacity:      .5;
635 | // //** Modal header border color
636 | // @modal-header-border-color:   #e5e5e5;
637 | // //** Modal footer border color
638 | // @modal-footer-border-color:   @modal-header-border-color;
639 | 
640 | // @modal-lg:                    900px;
641 | // @modal-md:                    600px;
642 | // @modal-sm:                    300px;
643 | 
644 | 
645 | // //== Alerts
646 | // //
647 | // //## Define alert colors, border radius, and padding.
648 | 
649 | // @alert-padding:               15px;
650 | // @alert-border-radius:         @border-radius-base;
651 | // @alert-link-font-weight:      bold;
652 | 
653 | // @alert-success-bg:            @state-success-bg;
654 | // @alert-success-text:          @state-success-text;
655 | // @alert-success-border:        @state-success-border;
656 | 
657 | // @alert-info-bg:               @state-info-bg;
658 | // @alert-info-text:             @state-info-text;
659 | // @alert-info-border:           @state-info-border;
660 | 
661 | // @alert-warning-bg:            @state-warning-bg;
662 | // @alert-warning-text:          @state-warning-text;
663 | // @alert-warning-border:        @state-warning-border;
664 | 
665 | // @alert-danger-bg:             @state-danger-bg;
666 | // @alert-danger-text:           @state-danger-text;
667 | // @alert-danger-border:         @state-danger-border;
668 | 
669 | 
670 | // //== Progress bars
671 | // //
672 | // //##
673 | 
674 | // //** Background color of the whole progress component
675 | @progress-bg:                 	 @bg-complement;
676 | // //** Progress bar text color
677 | // @progress-bar-color:          #fff;
678 | // //** Variable for setting rounded corners on progress bar.
679 | // @progress-border-radius:      @border-radius-base;
680 | 
681 | // //** Default progress bar color
682 | // @progress-bar-bg:             @brand-primary;
683 | // //** Success progress bar color
684 | // @progress-bar-success-bg:     @brand-success;
685 | // //** Warning progress bar color
686 | // @progress-bar-warning-bg:     @brand-warning;
687 | // //** Danger progress bar color
688 | // @progress-bar-danger-bg:      @brand-danger;
689 | // //** Info progress bar color
690 | // @progress-bar-info-bg:        @brand-info;
691 | 
692 | 
693 | // //== List group
694 | // //
695 | // //##
696 | 
697 | // //** Background color on `.list-group-item`
698 | // @list-group-bg:                 #fff;
699 | // //** `.list-group-item` border color
700 | // @list-group-border:             #ddd;
701 | // //** List group border radius
702 | // @list-group-border-radius:      @border-radius-base;
703 | 
704 | // //** Background color of single list items on hover
705 | // @list-group-hover-bg:           #f5f5f5;
706 | // //** Text color of active list items
707 | // @list-group-active-color:       @component-active-color;
708 | // //** Background color of active list items
709 | // @list-group-active-bg:          @component-active-bg;
710 | // //** Border color of active list elements
711 | // @list-group-active-border:      @list-group-active-bg;
712 | // //** Text color for content within active list items
713 | // @list-group-active-text-color:  lighten(@list-group-active-bg, 40%);
714 | 
715 | // //** Text color of disabled list items
716 | // @list-group-disabled-color:      @gray-light;
717 | // //** Background color of disabled list items
718 | // @list-group-disabled-bg:         @gray-lighter;
719 | // //** Text color for content within disabled list items
720 | // @list-group-disabled-text-color: @list-group-disabled-color;
721 | 
722 | // @list-group-link-color:         #555;
723 | // @list-group-link-hover-color:   @list-group-link-color;
724 | // @list-group-link-heading-color: #333;
725 | 
726 | 
727 | // //== Panels
728 | // //
729 | // //##
730 | 
731 | // @panel-bg:                    #fff;
732 | // @panel-body-padding:          15px;
733 | // @panel-heading-padding:       10px 15px;
734 | // @panel-footer-padding:        @panel-heading-padding;
735 | // @panel-border-radius:         @border-radius-base;
736 | 
737 | // //** Border color for elements within panels
738 | // @panel-inner-border:          #ddd;
739 | // @panel-footer-bg:             #f5f5f5;
740 | 
741 | // @panel-default-text:          @gray-dark;
742 | // @panel-default-border:        #ddd;
743 | // @panel-default-heading-bg:    #f5f5f5;
744 | 
745 | // @panel-primary-text:          #fff;
746 | // @panel-primary-border:        @brand-primary;
747 | // @panel-primary-heading-bg:    @brand-primary;
748 | 
749 | // @panel-success-text:          @state-success-text;
750 | // @panel-success-border:        @state-success-border;
751 | // @panel-success-heading-bg:    @state-success-bg;
752 | 
753 | // @panel-info-text:             @state-info-text;
754 | // @panel-info-border:           @state-info-border;
755 | // @panel-info-heading-bg:       @state-info-bg;
756 | 
757 | // @panel-warning-text:          @state-warning-text;
758 | // @panel-warning-border:        @state-warning-border;
759 | // @panel-warning-heading-bg:    @state-warning-bg;
760 | 
761 | // @panel-danger-text:           @state-danger-text;
762 | // @panel-danger-border:         @state-danger-border;
763 | // @panel-danger-heading-bg:     @state-danger-bg;
764 | 
765 | 
766 | // //== Thumbnails
767 | // //
768 | // //##
769 | 
770 | // //** Padding around the thumbnail image
771 | // @thumbnail-padding:           4px;
772 | // //** Thumbnail background color
773 | // @thumbnail-bg:                @body-bg;
774 | // //** Thumbnail border color
775 | // @thumbnail-border:            #ddd;
776 | // //** Thumbnail border radius
777 | // @thumbnail-border-radius:     @border-radius-base;
778 | 
779 | // //** Custom text color for thumbnail captions
780 | // @thumbnail-caption-color:     @text-color;
781 | // //** Padding around the thumbnail caption
782 | // @thumbnail-caption-padding:   9px;
783 | 
784 | 
785 | // //== Wells
786 | // //
787 | // //##
788 | 
789 | // @well-bg:                     #f5f5f5;
790 | // @well-border:                 darken(@well-bg, 7%);
791 | 
792 | 
793 | // //== Badges
794 | // //
795 | // //##
796 | 
797 | // @badge-color:                 #fff;
798 | // //** Linked badge text color on hover
799 | // @badge-link-hover-color:      #fff;
800 | // @badge-bg:                    @gray-light;
801 | 
802 | // //** Badge text color in active nav link
803 | // @badge-active-color:          @link-color;
804 | // //** Badge background color in active nav link
805 | // @badge-active-bg:             #fff;
806 | 
807 | // @badge-font-weight:           bold;
808 | // @badge-line-height:           1;
809 | // @badge-border-radius:         10px;
810 | 
811 | 
812 | // //== Breadcrumbs
813 | // //
814 | // //##
815 | 
816 | // @breadcrumb-padding-vertical:   8px;
817 | // @breadcrumb-padding-horizontal: 15px;
818 | // //** Breadcrumb background color
819 | // @breadcrumb-bg:                 #f5f5f5;
820 | // //** Breadcrumb text color
821 | // @breadcrumb-color:              #ccc;
822 | // //** Text color of current page in the breadcrumb
823 | // @breadcrumb-active-color:       @gray-light;
824 | // //** Textual separator for between breadcrumb elements
825 | // @breadcrumb-separator:          "/";
826 | 
827 | 
828 | // //== Carousel
829 | // //
830 | // //##
831 | 
832 | // @carousel-text-shadow:                        0 1px 2px rgba(0,0,0,.6);
833 | 
834 | // @carousel-control-color:                      #fff;
835 | // @carousel-control-width:                      15%;
836 | // @carousel-control-opacity:                    .5;
837 | // @carousel-control-font-size:                  20px;
838 | 
839 | // @carousel-indicator-active-bg:                #fff;
840 | // @carousel-indicator-border-color:             #fff;
841 | 
842 | // @carousel-caption-color:                      #fff;
843 | 
844 | 
845 | // //== Close
846 | // //
847 | // //##
848 | 
849 | // @close-font-weight:           bold;
850 | // @close-color:                 #000;
851 | // @close-text-shadow:           0 1px 0 #fff;
852 | 
853 | 
854 | // //== Code
855 | // //
856 | // //##
857 | 
858 | // @code-color:                  #c7254e;
859 | // @code-bg:                     #f9f2f4;
860 | 
861 | // @kbd-color:                   #fff;
862 | // @kbd-bg:                      #333;
863 | 
864 | // @pre-bg:                      #f5f5f5;
865 | // @pre-color:                   @gray-dark;
866 | // @pre-border-color:            #ccc;
867 | // @pre-scrollable-max-height:   340px;
868 | 
869 | 
870 | // //== Type
871 | // //
872 | // //##
873 | 
874 | // //** Horizontal offset for forms and lists.
875 | // @component-offset-horizontal: 180px;
876 | // //** Text muted color
877 | // @text-muted:                  @gray-light;
878 | // //** Abbreviations and acronyms border color
879 | // @abbr-border-color:           @gray-light;
880 | // //** Headings small color
881 | // @headings-small-color:        @gray-light;
882 | // //** Blockquote small color
883 | // @blockquote-small-color:      @gray-light;
884 | // //** Blockquote font size
885 | // @blockquote-font-size:        (@font-size-base * 1.25);
886 | // //** Blockquote border color
887 | // @blockquote-border-color:     @gray-lighter;
888 | // //** Page header border color
889 | // @page-header-border-color:    @gray-lighter;
890 | // //** Width of horizontal description list titles
891 | // @dl-horizontal-offset:        @component-offset-horizontal;
892 | // //** Horizontal line color.
893 | // @hr-border:                   @gray-lighter;
894 | 


--------------------------------------------------------------------------------