diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2016-01-19 01:06:57 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2016-01-19 01:09:13 +0100 |
commit | 7963d41a8bef65205e7507b36c11383ce68298ed (patch) | |
tree | af456b859cdc5279a8d4cfc75470a857d85066b6 /static/js/kosten.ls | |
parent | a6489752e2151aab72ce814a3a5652dbdfe22b1a (diff) | |
download | kosten-7963d41a8bef65205e7507b36c11383ce68298ed.tar.gz kosten-7963d41a8bef65205e7507b36c11383ce68298ed.tar.bz2 kosten-7963d41a8bef65205e7507b36c11383ce68298ed.zip |
Allow to put in the date in short format
Diffstat (limited to '')
-rw-r--r-- | static/js/kosten.ls | 33 |
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 !-> |