From 13c75e73812927359ca8a1d606ed33bd6a75eea5 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Wed, 15 Jun 2011 21:12:26 +0100 Subject: Rejigged column names.. and javascript location. --HG-- rename : static/mauve_utils.js => static/javascript/mauve_utils.js --- static/javascript | 1 - static/javascript/mauve_utils.js | 56 +++++++++++ static/mauve.js | 211 --------------------------------------- static/mauve_utils.js | 56 ----------- 4 files changed, 56 insertions(+), 268 deletions(-) delete mode 120000 static/javascript create mode 100644 static/javascript/mauve_utils.js delete mode 100644 static/mauve.js delete mode 100644 static/mauve_utils.js (limited to 'static') diff --git a/static/javascript b/static/javascript deleted file mode 120000 index e3b95b4..0000000 --- a/static/javascript +++ /dev/null @@ -1 +0,0 @@ -/usr/share/javascript \ No newline at end of file diff --git a/static/javascript/mauve_utils.js b/static/javascript/mauve_utils.js new file mode 100644 index 0000000..3012ca3 --- /dev/null +++ b/static/javascript/mauve_utils.js @@ -0,0 +1,56 @@ + +function updateDate() { + // + // Date.getTime() returns *milliseconds* + // + var this_date = workoutDate( $('#n_hours').val(), $('#type_hours').val() ); + $('#ack_until_text').html("(until "+humanDate(this_date)+")"); + $('#ack_until').val(this_date.getTime()/1000); + + return false; +} + +function workoutDate(h, t) { + var new_date = null; + + // + // Use a synchronous ajax request to fetch the date. Note that + // Date.getTime() returns milliseconds.. + // + $.ajax({ + url: '/ajax/time_in_x_hours/'+h+"/"+t, + async: false, + success: function(data) { new_date = new Date ( new Number(data) * 1000 ); } + }); + + return new_date; +} + + +function humanDate(d) { + var new_date = null; + // + // Use a synchronous ajax convert a date to a human string. NB Date.getTime() + // returns *milliseconds* + // + $.ajax({ + url: '/ajax/time_to_s_human/'+d.getTime()/1000, + async: false, + success: function(data) { new_date = data; } + }); + + return new_date; +} + +function fetchDetail(a) { + // Use a synchronous ajax request to fetch the date. + $.get('/ajax/alerts_table_alert_detail/'+a, + function(data) { + $('#tr_summary_'+a).after(data); + // Only fetch the data once. + $('#a_detail_'+a).attr("onclick",null).click(function() { $('#tr_detail_'+a).toggle(); return false; }); + }); + + return false; +} + diff --git a/static/mauve.js b/static/mauve.js deleted file mode 100644 index 0cc32ec..0000000 --- a/static/mauve.js +++ /dev/null @@ -1,211 +0,0 @@ -/* - * This contains all the 'clever' javascript used on the page. - */ -var mouse_is_inside = false; - -/* -try { - $("#myselector").click (function () {}); //my jQuery code here -} catch (e) { - //this executes if jQuery isn't loaded - alert(e.message - + "\nCould be a network error leading to jquery not being loaded!\n" - + "Reloading the page."); - window.location.reload(true); -} -*/ - -//////////////////////////////////////////////////////////////////////////////// -// Treeview data. -$(document).ready(function(){ - $("#blackAck").treeview({ - control: "#treecontrolAck", - persist: "cookie", - cookieId: "treeview-black" - }); - -}); -$(document).ready(function(){ - $("#blackNew").treeview({ - control: "#treecontrolNew", - persist: "cookie", - cookieId: "treeview-black" - }); -}); - -$(document).ready(function(){ - - //////////////////////////////////////////////////////////////////////////////// - // This allows pop! to do its thing, used for details. - $.pop(); - - //////////////////////////////////////////////////////////////////////////////// - // Countdown code. - - /* - // This binds to the timer that reloads the page every 300 seconds via callback. - $('#reloadPage').countdown({until: +300, onExpiry: liftOff, format: 'MS'}); - - // This is the callback that reloads the page. - function liftOff() { - window.location.reload(true); - } - */ - - - //////////////////////////////////////////////////////////////////////////////// - // Mouse outside of changeStatus form. - // See url http://stackoverflow.com/questions/1403615/use-jquery-to-hide-div-when-click-outside-it - $('.updateAlertStatus').hover(function(){ - mouse_is_inside=true; - }, function(){ - mouse_is_inside=false; - }); - $('body').mouseup(function(){ - if(! mouse_is_inside) - { - //$(".updateAlertStatus").fadeOut(1000); - //$('.darkMask').fadeOut(1000); - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); - } - }); -}); - -//////////////////////////////////////////////////////////////////////////////// -// Acknowledge status functions. - - -//////////////////////////////////////////////////////////////////////////////// -// Standards are there to be violated... -function mouseX(evt) { - if (evt.pageX) return evt.pageX; - else if (evt.clientX) - return evt.clientX + (document.documentElement.scrollLeft ? - document.documentElement.scrollLeft : - document.body.scrollLeft); - else return null; -} - -//////////////////////////////////////////////////////////////////////////////// -// Standards are there to be violated... -function mouseY(evt) { - if (evt.pageY) return evt.pageY; - else if (evt.clientY) - return evt.clientY + (document.documentElement.scrollTop ? - document.documentElement.scrollTop : - document.body.scrollTop); - else return null; -} - -//////////////////////////////////////////////////////////////////////////////// -// Shows the updateAlertStatus div where the mouse clicked and mask the rest of -// page. -function showAcknowledgeStatus (e, id, ackTime) { - - // Build the form. - document.changeAlertStatusForm.AlertID.value = id; - document.changeAlertStatusForm.AlertDefaultAcknowledgeTime.value = ackTime; - var myselect=document.getElementById("sample"); - myselect.remove(0); - str = returnTimeString(ackTime); - myselect.add(new Option(str, ackTime, true, true), myselect.options[0]) - - // Show the form. - //leftVal = mouseX(e); - leftVal = 2 - topVal = mouseY(e); - $('.updateAlertStatus').css({left:leftVal,top:topVal}).fadeIn(500); - $('.darkMask').css({height:$(document).height()}).show(); -} - -// Returns the default time. -function returnTimeString (time) { - hrs = time / 3600 - if (1 == hrs) - { - str = "1 hour" - } - else if (24 > hrs && 1 > hrs) - { - str = hrs + " hours" - } - else if (24 == hrs) - { - str = "1 day" - } - else if (24 < hrs && 168 > hrs) - { - str = hrs / 24 + " days" - } - else if (168 == hrs) - { - str = "1 week" - } - else - { - str = hrs / 168 + " weeks" - } - return str + ", default." -} - -//////////////////////////////////////////////////////////////////////////////// -// Shows the updateAlertSatus div for group of alerts. -function showBulkAcknowledgeStatus(e, ids, ackTime) -{ - for (i in ids) - { - changeAcknowledgeStatusCall(ids[i], ackTime); - } - //window.location.reload(true); - tmp = $('#firstAlert'+ids[0]); - tmp.remove() -} - -function changeAcknowledgeStatusCall (id, acknowledgedUntil) { - $.post('/alert/acknowledge/'+id+'/'+acknowledgedUntil); - tmp = $('#alert'+id) - tmp.remove(); - tmp.appendTo('#blackAck'); -} - -//////////////////////////////////////////////////////////////////////////////// -// Actually gets the alert updated and moves it to the right list. -// Note that id is a numberical ID of the alert. -// Note that acknowledgedUntil is a number of seconds. -function changeAcknowledgeStatus (id, acknowledgedUntil) { - if (-1 != id) - { - changeAcknowledgeStatusCall(id, acknowledgedUntil); - } - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Clears (aka trash aka delete) an alert. -// THIS IS NOT WHAT YOU WANT -// url http://stackoverflow.com/questions/95600/jquery-error-option-in-ajax-utility -// url http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages -function clearAlert (id) { - $.post('/alert/'+id+'/clear'); - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); - tmp = $('#alert'+id) - tmp.remove(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Raises (aka unacknowledge) an alert. -function raiseAlert (id) { - $.post('/alert/'+id+'/raise'); - $(".updateAlertStatus").hide(); - $('.darkMask').hide(); - tmp = $('#alert'+id) - tmp.remove(); - tmp.appendTo('#blackNew'); -} - - -//////////////////////////////////////////////////////////////////////////////// -// EOF diff --git a/static/mauve_utils.js b/static/mauve_utils.js deleted file mode 100644 index 3012ca3..0000000 --- a/static/mauve_utils.js +++ /dev/null @@ -1,56 +0,0 @@ - -function updateDate() { - // - // Date.getTime() returns *milliseconds* - // - var this_date = workoutDate( $('#n_hours').val(), $('#type_hours').val() ); - $('#ack_until_text').html("(until "+humanDate(this_date)+")"); - $('#ack_until').val(this_date.getTime()/1000); - - return false; -} - -function workoutDate(h, t) { - var new_date = null; - - // - // Use a synchronous ajax request to fetch the date. Note that - // Date.getTime() returns milliseconds.. - // - $.ajax({ - url: '/ajax/time_in_x_hours/'+h+"/"+t, - async: false, - success: function(data) { new_date = new Date ( new Number(data) * 1000 ); } - }); - - return new_date; -} - - -function humanDate(d) { - var new_date = null; - // - // Use a synchronous ajax convert a date to a human string. NB Date.getTime() - // returns *milliseconds* - // - $.ajax({ - url: '/ajax/time_to_s_human/'+d.getTime()/1000, - async: false, - success: function(data) { new_date = data; } - }); - - return new_date; -} - -function fetchDetail(a) { - // Use a synchronous ajax request to fetch the date. - $.get('/ajax/alerts_table_alert_detail/'+a, - function(data) { - $('#tr_summary_'+a).after(data); - // Only fetch the data once. - $('#a_detail_'+a).attr("onclick",null).click(function() { $('#tr_detail_'+a).toggle(); return false; }); - }); - - return false; -} - -- cgit v1.2.1