Mirror of Quill
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
861 B

  1. function tz_seconds_to_offset(seconds) {
  2. var tz_offset = '';
  3. var hours = zero_pad(Math.abs(seconds / 60 / 60));
  4. var minutes = zero_pad(Math.floor(seconds / 60) % 60);
  5. return (seconds < 0 ? '-' : '+') + hours + ":" + minutes;
  6. }
  7. function zero_pad(num) {
  8. num = "" + num;
  9. if(num.length == 1) {
  10. num = "0" + num;
  11. }
  12. return num;
  13. }
  14. $(function(){
  15. // Set the date from JS
  16. var d = new Date();
  17. $("#note_date").val(d.getFullYear()+"-"+zero_pad(d.getMonth()+1)+"-"+zero_pad(d.getDate()));
  18. $("#note_time").val(zero_pad(d.getHours())+":"+zero_pad(d.getMinutes())+":"+zero_pad(d.getSeconds()));
  19. $("#note_tzoffset").val(tz_seconds_to_offset(d.getTimezoneOffset() * 60 * -1));
  20. // ctrl-s to save
  21. $(window).on('keydown', function(e){
  22. if(e.keyCode == 83 && e.ctrlKey){
  23. $("#btn_post").click();
  24. }
  25. });
  26. })