-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nigel.daniels
committed
Oct 24, 2016
0 parents
commit adab879
Showing
27 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Apple network share | ||
.AppleDouble/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Nigel Daniels | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* Magic Mirror Module: MMM-Fish | ||
* Version: 1.0.0 | ||
* | ||
* By Nigel Daniels https://github.com/nigel-daniels/ | ||
* MIT Licensed. | ||
*/ | ||
|
||
Module.register('MMM-Fish', { | ||
|
||
|
||
defaults: { | ||
fish: [ | ||
{'id':'anchovy','name':'Anchovy'}, | ||
{'id':'cod','name':'Cod'}, | ||
{'id':'dogfish','name':'Dogfish'}, | ||
{'id':'eel','name':'Eel'}, | ||
{'id':'haddock','name':'Haddock'}, | ||
{'id':'halibut','name':'Halibut'}, | ||
{'id':'herring','name':'Herring'}, | ||
{'id':'mackerel','name':'Mackerel'}, | ||
{'id':'monkfish','name':'Monkfish'}, | ||
{'id':'mullet','name':'Mullet'}, | ||
{'id':'plaice','name':'Plaice'}, | ||
{'id':'red_snapper','name':'Red Snapper'}, | ||
{'id':'salmon','name':'Salmon'}, | ||
{'id':'sardine','name':'Sardine'}, | ||
{'id':'sea_bass','name':'Sea Bass'}, | ||
{'id':'sea_bream','name':'Sea Bream'}, | ||
{'id':'skate','name':'Skate'}, | ||
{'id':'sole','name':'Sole'}, | ||
{'id':'swordfish','name':'Swordfish'}, | ||
{'id':'trout','name':'Trout'}, | ||
{'id':'tuna','name':'Tuna'}, | ||
{'id':'turbot','name':'Turbot'} | ||
], | ||
interval: 3600000 // Every 60 mins | ||
}, | ||
|
||
|
||
// Define required scripts. | ||
getScripts: function() { | ||
return ["moment.js"]; | ||
}, | ||
|
||
getStyles: function() { | ||
return ['fish.css', 'font-awesome.css']; | ||
}, | ||
|
||
// Define start sequence. | ||
start: function() { | ||
Log.info("Starting module: " + this.name); | ||
|
||
this.lastFish = -1; | ||
this.day = -1; | ||
|
||
// Schedule update timer. | ||
var that = this; | ||
setInterval(function() {that.fishOfTheDay();}, this.config.interval); | ||
}, | ||
|
||
|
||
randomFish: function() { | ||
var that = this; | ||
|
||
var generate = function() { | ||
return Math.floor(Math.random() * that.config.fish.length); | ||
}; | ||
|
||
var fishIndex = generate(); | ||
|
||
while (fishIndex === this.lastFish) { | ||
fishIndex = generate(); | ||
} | ||
|
||
this.lastFish = fishIndex; | ||
|
||
return this.config.fish[fishIndex]; | ||
}, | ||
|
||
|
||
fishOfTheDay: function(that) { | ||
var date = new Date; | ||
var day = date.getDay(); | ||
|
||
if (day != this.day) { | ||
this.day = day; | ||
this.updateDom(4000); | ||
} | ||
}, | ||
|
||
// Override dom generator. | ||
getDom: function() { | ||
|
||
var fish = this.randomFish(); | ||
|
||
var id = fish.id; | ||
var fishName = fish.name; | ||
|
||
var wrapper = document.createElement('div'); | ||
wrapper.className = "bright fish"; | ||
|
||
var image = document.createElement('img'); | ||
image.className = 'fishPic'; | ||
image.src = './modules/MMM-Fish/images/' + id + '.png'; | ||
|
||
var name = document.createElement('span'); | ||
name.className = 'fishName'; | ||
name.innerHTML = fishName; | ||
|
||
wrapper.appendChild(image); | ||
wrapper.appendChild(name); | ||
|
||
return wrapper; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# MMM-Fish | ||
This is a module for the [MagicMirror](https://github.com/MichMich/MagicMirror/tree/develop). This module shows the fish of the day. | ||
|
||
## Installation | ||
1. Navigate into your MagicMirror's `modules` folder and execute `git clone https://github.com/nigel-daniels/MMM-Fish`. A new folder `MMM-Fish` will appear. | ||
|
||
## Config | ||
The entry in `config.js` is simple and has no options. | ||
|
||
Here is an example of an entry in `config.js` | ||
``` | ||
{ | ||
module: 'MMM-Fish', | ||
header: 'Fish of the Day', | ||
position: 'top_left' | ||
}, | ||
``` | ||
|
||
## Notes | ||
I was asked if we could have a fish of the day ^_^ | ||
|
||
## Thanks To... | ||
- [Michael Teeuw](https://github.com/MichMich) for the [MagicMirror2](https://github.com/MichMich/MagicMirror/tree/develop) framework that made this module possible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.fishPic { | ||
margin-right: 10px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.