├── .gitattributes ├── .gitignore ├── build └── browserify.js ├── client.js ├── index.html └── package.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | 30 | # ========================= 31 | # Operating System Files 32 | # ========================= 33 | 34 | # OSX 35 | # ========================= 36 | 37 | .DS_Store 38 | .AppleDouble 39 | .LSOverride 40 | 41 | # Thumbnails 42 | ._* 43 | 44 | # Files that might appear on external disk 45 | .Spotlight-V100 46 | .Trashes 47 | 48 | # Directories potentially created on remote AFP share 49 | .AppleDB 50 | .AppleDesktop 51 | Network Trash Folder 52 | Temporary Items 53 | .apdisk 54 | 55 | # Windows 56 | # ========================= 57 | 58 | # Windows image file caches 59 | Thumbs.db 60 | ehthumbs.db 61 | 62 | # Folder config file 63 | Desktop.ini 64 | 65 | # Recycle Bin used on file shares 66 | $RECYCLE.BIN/ 67 | 68 | # Windows Installer files 69 | *.cab 70 | *.msi 71 | *.msm 72 | *.msp 73 | 74 | # Windows shortcuts 75 | *.lnk 76 | -------------------------------------------------------------------------------- /build/browserify.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var build = require("browserify")(); 4 | 5 | build.add("./client.js"); 6 | 7 | build.bundle(function(err, buf) { 8 | if(err) { 9 | throw new Error(err); 10 | } 11 | 12 | require("fs").writeFileSync("./output/scripts.js", buf); 13 | }); 14 | -------------------------------------------------------------------------------- /client.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var m = require("mithril"), 4 | redux = require("redux"), 5 | 6 | store; 7 | 8 | store = redux.createStore(function(state, action) { 9 | if(!state) { 10 | return { 11 | text : "ZZZ" 12 | }; 13 | } 14 | 15 | switch(action.type) { 16 | case "TEXT_CHANGE": 17 | return Object.assign({}, state, { text : action.text }); 18 | 19 | default: 20 | return state; 21 | } 22 | }); 23 | 24 | store.subscribe(m.redraw.bind(m)); 25 | 26 | m.mount(document.body, { 27 | controller : function() { 28 | this.clickText = function(e) { 29 | e.preventDefault(); 30 | 31 | store.dispatch({ 32 | type : "TEXT_CHANGE", 33 | text : "It's currently: " + (new Date()).toTimeString() 34 | }); 35 | }; 36 | }, 37 | 38 | view : function(ctrl) { 39 | var state = store.getState(); 40 | 41 | return m("div", 42 | m("p", state.text), 43 | m("button", { onclick : ctrl.clickText }, "What time is it?") 44 | ); 45 | } 46 | }); 47 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |