Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame^] | 1 | requirejs.config({ |
| 2 | baseUrl: '../js/src', |
| 3 | paths : { |
| 4 | 'lib': '../lib' |
| 5 | } |
| 6 | }); |
| 7 | |
| 8 | var cookey; |
| 9 | |
| 10 | function add (val) { |
| 11 | var list = document.getElementById('number'); |
| 12 | list.textContent += '-' + val; |
| 13 | cookey.set('n', list.textContent); |
| 14 | }; |
| 15 | |
| 16 | function removeCookie () { |
| 17 | cookey.clear(); |
| 18 | }; |
| 19 | |
| 20 | define(['session', 'lib/domReady'], function (sessionClass, domReady) { |
| 21 | domReady(function () { |
| 22 | cookey = sessionClass.create('peter'); |
| 23 | document.getElementById('number').textContent = cookey.get('n') || ''; |
| 24 | |
| 25 | var elements = document.getElementsByClassName('num'); |
| 26 | for (var i = 0; i < elements.length; i++) { |
| 27 | elements[i].addEventListener( |
| 28 | 'click', |
| 29 | function (e) { |
| 30 | add(this.textContent); |
| 31 | } |
| 32 | ); |
| 33 | }; |
| 34 | }); |
| 35 | }) |