utilities.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. var AIRTIME = (function(AIRTIME){
  2. var mod;
  3. if (AIRTIME.utilities === undefined) {
  4. AIRTIME.utilities = {};
  5. }
  6. mod = AIRTIME.utilities;
  7. mod.findViewportDimensions = function() {
  8. var viewportwidth,
  9. viewportheight;
  10. // the more standards compliant browsers (mozilla/netscape/opera/IE7) use
  11. // window.innerWidth and window.innerHeight
  12. if (typeof window.innerWidth != 'undefined') {
  13. viewportwidth = window.innerWidth, viewportheight = window.innerHeight;
  14. }
  15. // IE6 in standards compliant mode (i.e. with a valid doctype as the first
  16. // line in the document)
  17. else if (typeof document.documentElement != 'undefined'
  18. && typeof document.documentElement.clientWidth != 'undefined'
  19. && document.documentElement.clientWidth != 0) {
  20. viewportwidth = document.documentElement.clientWidth;
  21. viewportheight = document.documentElement.clientHeight;
  22. }
  23. // older versions of IE
  24. else {
  25. viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
  26. viewportheight = document.getElementsByTagName('body')[0].clientHeight;
  27. }
  28. return {
  29. width: viewportwidth,
  30. height: viewportheight
  31. };
  32. };
  33. /*
  34. * Returns an object containing a unix timestamp in seconds for the start/end range
  35. *
  36. * @return Object {"start", "end", "range"}
  37. */
  38. mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) {
  39. var start,
  40. end,
  41. time;
  42. start = $(dateStartId).val();
  43. start = start === "" ? null : start;
  44. time = $(timeStartId).val();
  45. time = time === "" ? "00:00" : time;
  46. if (start) {
  47. start = start + " " + time;
  48. }
  49. end = $(dateEndId).val();
  50. end = end === "" ? null : end;
  51. time = $(timeEndId).val();
  52. time = time === "" ? "00:00" : time;
  53. if (end) {
  54. end = end + " " + time;
  55. }
  56. return {
  57. start: start,
  58. end: end
  59. };
  60. };
  61. return AIRTIME;
  62. }(AIRTIME || {}));