diff options
author | Aaron Parecki <aaron@parecki.com> | 2016-02-11 02:47:04 +0000 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2016-02-11 02:47:04 +0000 |
commit | 76aa9c2bc9d31549e44bc0b10817eb6e252dbe11 (patch) | |
tree | e7820622820ca39424333c01ab2d238f56be1a11 /public/js | |
parent | 1fdf8feb67fd11f46811fe925537ab6bf3e4d626 (diff) | |
parent | 704241a3a4f3480eb87260aef9fca8f1ce00e638 (diff) |
Merge branch 'master' of github.com:aaronpk/IndiePost
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/script.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/public/js/script.js b/public/js/script.js new file mode 100644 index 0000000..399af05 --- /dev/null +++ b/public/js/script.js @@ -0,0 +1,32 @@ + + function tz_seconds_to_offset(seconds) { + var tz_offset = ''; + var hours = zero_pad(Math.abs(seconds / 60 / 60)); + var minutes = zero_pad(Math.floor(seconds / 60) % 60); + return (seconds < 0 ? '-' : '+') + hours + ":" + minutes; + } + function zero_pad(num) { + num = "" + num; + if(num.length == 1) { + num = "0" + num; + } + return num; + } + + +$(function(){ + + // Set the date from JS + var d = new Date(); + $("#note_date").val(d.getFullYear()+"-"+zero_pad(d.getMonth()+1)+"-"+zero_pad(d.getDate())); + $("#note_time").val(zero_pad(d.getHours())+":"+zero_pad(d.getMinutes())+":"+zero_pad(d.getSeconds())); + $("#note_tzoffset").val(tz_seconds_to_offset(d.getTimezoneOffset() * 60 * -1)); + + // ctrl-s to save + $(window).on('keydown', function(e){ + if(e.keyCode == 83 && e.ctrlKey){ + $("#btn_post").click(); + } + }); + +}) |