summaryrefslogtreecommitdiff
path: root/static/js/kosten.ls
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/kosten.ls')
-rw-r--r--static/js/kosten.ls33
1 files changed, 30 insertions, 3 deletions
diff --git a/static/js/kosten.ls b/static/js/kosten.ls
index e3a60d2..163d670 100644
--- a/static/js/kosten.ls
+++ b/static/js/kosten.ls
@@ -1,6 +1,12 @@
jQuery.fn.extend do
copy : -> @clone!remove-attr 'id class'
+String::splitAt = (pos) -> return
+ @slice 0 pos
+ @slice pos
+
+Date::format = -> $.datepicker.formatDate \dd.mm.yy @
+
jq = (f) -> !-> $ f
# Call this to localize Highcharts
@@ -20,6 +26,25 @@ set-lang = !->
range-selector-to: \bis
range-selector-zoom: null
+extend-date = (input) !->
+ if input.val! is //^
+ ([12][0-9]|3[01]|0?[1-9]) # day
+ (?:
+ (0?[1-9]|1[0-2]) # month
+ ((?:20)?[0-9][0-9])? # year
+ )?
+ $//
+ then
+ now = new Date!
+ [_, day, month, year] = that
+ year ?= now.get-full-year!
+ month ?= now.get-month! + 1
+
+ year = "20" + year unless year > 99
+
+ new Date year, month - 1, day .format! |> input.val
+
+
# The Search Stuff
$ !->
$ \form.search .hide!
@@ -34,9 +59,11 @@ $ !->
# Add
export addJS = jq !->
- $ 'input[name=date]' .datepicker do
- date-format: \dd.mm.yy
- first-day: 1
+ $ 'input[name=date]'
+ .. .datepicker do
+ date-format: \dd.mm.yy
+ first-day: 1
+ .. .blur !-> extend-date ..
# Show
export showJS = jq !->