diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-01-11 22:50:38 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-01-11 22:50:38 +0100 |
commit | c1c0602d583436b700a004d8c135cb9e2050d8fe (patch) | |
tree | e79820a180b688a9233d28a7004636d4576e9d20 /static/js/kosten.ls | |
parent | 1099ef3b95bc79c322008a05cda1b54668076bce (diff) | |
download | kosten-c1c0602d583436b700a004d8c135cb9e2050d8fe.tar.gz kosten-c1c0602d583436b700a004d8c135cb9e2050d8fe.tar.bz2 kosten-c1c0602d583436b700a004d8c135cb9e2050d8fe.zip |
Revert back to JS from LS (whose development stopped)
Diffstat (limited to 'static/js/kosten.ls')
-rw-r--r-- | static/js/kosten.ls | 224 |
1 files changed, 0 insertions, 224 deletions
diff --git a/static/js/kosten.ls b/static/js/kosten.ls deleted file mode 100644 index ea433a4..0000000 --- a/static/js/kosten.ls +++ /dev/null @@ -1,224 +0,0 @@ -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 -set-lang = !-> - Highcharts .set-options do - # old colors - colors: [\#2f7ed8 \#0d233a \#8bbc21 \#910000 \#1aadce \#492970 - \#f28f43 \#77a1e5 \#c42525 \#a6c96a] - lang: - months: [\Januar \Februar \März \April \Mai \Juni \Juli - \August \September \Oktober \November \Dezember] - short-months: [\Jan \Feb \Mär \Apr \Mai \Jun \Jul - \Aug \Sep \Okt \Nov \Dez] - weekdays: [\Sonntag \Montag \Dienstag \Mittwoch \Donnerstag - \Freitag \Samstag] - range-selector-from: \von - range-selector-to: \bis - range-selector-zoom: null - numeric-symbols: 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! - - $ \li.search .click !-> - $ \form.search - ..toggle! - $ \input.search .focus! if .. .is \:visible - - $ \input.search .focusout !-> - $ \form.search .hide! - -# Add -export addJS = jq !-> - $ 'input[name=date]' - .. .datepicker do - date-format: \dd.mm.yy - first-day: 1 - .. .blur !-> extend-date .. - -# Show -export showJS = jq !-> - set-lang! - - $ ".detail .heading" .click !-> - $ @ .closest \.detail .children \.mark:first .click! - - $ ".detail > .mark" .click !-> - if (@src.index-of \closed) isnt -1 - @src .= replace \closed \open - else - @src .= replace \open \closed - - $ @ .next-all \.details:first .toggle! - - $ \.details .hide! - - # draw the pies - <-! $ \.pie .each - $ @ - ..highcharts do - title: text: null - tooltip: - hide-delay: 200ms - formatter: -> - "#{@key}: <b>#{@y.toFixed 2} €</b> / #{@percentage.to-fixed 2}%" - chart: - background-color: null - plot-border-width: null - plot-shadow: off - spacing-top: 0 - credits: enabled: false - series: [ - type: \pie - size: \70% - states: hover: halo: null - allow-point-select: true - data-labels: - color: ..css \color - distance: 20px - data: [ {name: if v>0 then k else '' , y: v, visible: v > 0} \ - for k,v of ..data \pie ] - ] - -# Statistics -export statJS = jq !-> - set-lang! - - df = Highcharts.date-format - month = 30d * 24h * 60min * 60s * 1000ms - - const-dialog = !-> - time = @x - - data <-! $.get df '/stats/_const/%Y/%m' time - $ data .dialog do - title: df '%B %Y' time - - <-! $ \.stats .each - $ @ - ..highcharts \StockChart do - credits: enabled: false - range-selector: - buttons: [] - input-date-format: "%b %Y" - input-edit-date-format: "%m.%Y" - input-date-parser: (value) -> - value .= split /\./ - Date.UTC value[1], # year - value[0] - 1, # month ... 0-based -.- - 1, #day - 0,0,0,0 # time - plot-options: - series: - stacking: \normal - marker: - enabled: false - radius: 2 - chart: - events: - click: !-> - for p in @series.0.data - if p.state - const-dialog.apply p - break - x-axis: - min-tick-interval: month - min-range: month - y-axis: - reversed-stacks: false - labels: - x: 5 - align: \left - series: [ - # const - * data: ..data \consts - step: \left - name: \Konstant - point: events: click: const-dialog - # normal exps - * data: ..data \expenses - name: \Variabel - step: \left - ] - tooltip: - formatter: -> - header = "<span style=\"font-size: 10px\">#{df '%B %Y' @x}</span><br/>" - body = ["#{p.series.name}: <b>#{p.point.y} €</b><br/>" for p in @points] .join '' - footer = "<strong>Summe: #{@points.0.total}</strong>" - header + body + footer - -# Categories -export catsJS = jq !-> - counter = 0 - add-img = $ \img#add - new-input = $ \input#new - - new-image = (new-name) -> - # we need to copy the image to get the correct URL - add-img.copy! - ..attr \src -> @src.replace \add new-name - - $ "li > span" .click !-> - span = $ @ - input = span.next! - img = new-image \undo - ..click !-> - $ @ .remove! - - # reset text - input.val span.text! - - <-! input.fade-out \slow - span.toggle! - - span.toggle! - <-! input.fade-in \slow - img.insert-after input - - add-img.click !-> - input = new-input.copy! - img = new-image \minus - ..click !-> - <-! $ @ .parent!fade-out \slow - $ @ .remove! - - input.attr \name -> @name + counter - .remove-attr \style - .wrap "<li />" - .parent! # wrap does not return the li - .append img - .hide! - .insert-before add-img.parent! - .fade-in \slow !-> input.focus! - - counter++ |