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.

49 lines
1.1 KiB

  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 csv_to_array(val) {
  15. if(val.length > 0) {
  16. return val.split(/[, ]+/);
  17. } else {
  18. return [];
  19. }
  20. }
  21. $(function(){
  22. // Set the date from JS
  23. var d = new Date();
  24. $("#note_date").val(d.getFullYear()+"-"+zero_pad(d.getMonth()+1)+"-"+zero_pad(d.getDate()));
  25. $("#note_time").val(zero_pad(d.getHours())+":"+zero_pad(d.getMinutes())+":"+zero_pad(d.getSeconds()));
  26. $("#note_tzoffset").val(tz_seconds_to_offset(d.getTimezoneOffset() * 60 * -1));
  27. // ctrl-s to save
  28. $(window).on('keydown', function(e){
  29. if(e.keyCode == 83 && e.ctrlKey){
  30. $("#btn_post").click();
  31. }
  32. });
  33. })
  34. function auto_prefix_url_field(field) {
  35. var str = field.value;
  36. if(!/^https?:\/\//.test(str)) {
  37. str = "http://" + str;
  38. }
  39. field.value = str;
  40. }