]> asedeno.scripts.mit.edu Git - bluechips.git/blob - bluechips/public/js/admin.js
ripped out toscawidgets, replaced with formencode, put split editing on main expendit...
[bluechips.git] / bluechips / public / js / admin.js
1 try {
2     console.log("init");
3 } catch(e) {
4     console = { log: function() {} };
5 }
6
7 $(function() {
8     console.log("ready()");
9    
10     /* Update date_input plugin so that MM/DD/YYYY format is used. */
11     $.extend(DateInput.DEFAULT_OPTS, {
12         stringToDate: function(string) {
13             var matches;
14             if(matches = string.match(/^(\d{2,2})\/(\d{2,2})\/(\d{4,4})$/)) {
15                 return new Date(matches[3], matches[1] - 1, matches[2]);
16             } else {
17                 return null;
18             }
19         },
20         dateToString: function(date) {
21             var month = (date.getMonth() + 1).toString();
22             var dom = date.getDate().toString();
23             if(month.length == 1) month = "0" + month;
24             if(dom.length == 1) dom = "0" + dom;
25             return month + "/" + dom + "/" + date.getFullYear();
26         }
27     });
28
29     /* Attach datepickers to fields! */
30     $('input.datepicker').date_input();
31
32     console.log("ready() done");
33 });
34