by taoski on July 25, 2007
The Helpdesk system we use here is far from great. In fact, its slow, crashy and down right bad. Unless you add new columns to the screen layout and monitor the contents every refresh, you cannot even see that a call has been updated 20 times when the customer calls for an update! Especially when the people taking those irate calls from the aforementioned customer don’t tell you they are chasing either..
Greasemonkey is a Firefox extension that allows you to change web pages by executing Javascript code after they have loaded. A simple explanation would be that you can force Google, for example to have larger fonts for the links and no pictures. You can pretty much change webpages to suit your whims.
All I needed to do was to get the script to parse a table of information, identify the time that a record on the screen was updated and if it had been updated in the last 30 minutes, make the update time turn red or green if it had been updated within the last hour.
After learning XPath statements and getting through the security models behind XPCNativeWrapper, I came up with this:
-
function $x(p, context) {
-
if (!context) context = document;
-
var i, arr = [], xpr = document.evaluate(p, context, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
-
for (i = 0; item = xpr.snapshotItem(i); i++) arr.push(item);
-
return arr;
-
}
-
-
function do_rows(r) {
-
var headings = document.evaluate(“id(’rltr_”+r+“‘)/td[3]“, document, null, XPathResult.ANY_TYPE,null);
-
var thisHeading = headings.iterateNext();
-
var row_hours = thisHeading.textContent.substr(9,2);
-
var row_mins = thisHeading.textContent.substr(12,2);
-
var row_day = thisHeading.textContent.substr(0,2);
-
var current_date = new Date()
-
var current_day = current_date.getDate();
-
var current_mins = current_date.getMinutes();
-
var current_hour = current_date.getHours();
-
var time_diff = (current_hour*60 + current_mins) - (parseInt(row_hours)*60 + parseInt(row_mins))
-
-
if (time_diff <= 30 && (current_day == row_day))
-
{
-
var paragraphs = $x(“id(’rltr_”+r+“‘)/td[3]“);
-
paragraphs.forEach(function(paragraph)
-
{ // Loop over every paragraph
-
paragraph.innerHTML = ““ + thisHeading.textContent + ” “ + time_diff + ““;
-
});
-
}
-
-
if ((current_hour == row_hours) && ((current_mins - row_mins)<=60) && ((current_mins - row_mins)>=31) && (current_day == row_day))
-
{
-
var paragraphs = $x(“id(’rltr_”+r+“‘)/td[3]“);
-
paragraphs.forEach(function(paragraph)
-
{ // Loop over every paragraph
-
paragraph.innerHTML = ““ + thisHeading.textContent + ” “ + time_diff + ““;
-
});
-
}
-
-
}
-
-
// do the main loop for each row
-
var i=0
-
for (i=0;i<=30;i++)
-
{
-
do_rows(i)
-
}
For the technical gimps out there, it reads the XPath data from the table into a variable called headings and then grabs the data into another variable called thisHeading. A few calculations later, it rewrites the data with bold tags either side if it meets certain criteria.
Not the prettiest code in the world, but it works!
by taoski on July 21, 2007
I had a rude awakening this morning from the nice lady from Royal Mail carrying a large bag of items similar to this one.The “potter books” are pretty much the only thing I have read in the last 7 years!And 5 of them I did as audiobook whilst travelling back from Birmingham on the train each day (so they don’t really count). And the last one I read on my laptop as a downloaded OCR’ed document…
“All Computer and no real work make eyes go ouch ouch!”
by taoski on July 11, 2007
It’s great to read that as a person who is covered in moles, that my “7 signs of aging” may be slower to take effect than that of a person who is mole free.
The flip side to this discovery is the common knowledge that people with a lot of moles have an increased risk of skin cancer. This does not bother me too much though as I am not a sun lover, never have been and never will be! Give me a rainy trudge up a hillside in the Lake District any day - you can keep your holiday to Barbados!
The only other down side to having moles is the increased risk that they will be
- Knocked off during play fights with children
- Scratched off during sex
- Cut by the hairdresser
- Grow hairs so thick and wiry that the US military want to use them for secret projects
I did once ask my GP about having my larger moles removed but he told me they may leave a scar if I did. A homeopathic doctor once told my father,
Just cut it off with a pair of scissors and put your finger on it…
Advice not to be followed I think!
by taoski on July 10, 2007
Whilst you would be forgiven for thinking that either my blog has died, I have or your RSS feed reader is not working properly, I will admit that I have not been hanging out here for some time.
This is due to several things:
- the Forza2 effect
- the Pokemon effect
- the too much work and not enough play effect
- the Facebook effect.
I would probably not be lying if I said that Facebook is currently the most popular and respected social network out there. Myspace, in my opinion, went downhill a long time ago and has disolved into a “widget-hell” patrolled by the latest pop wannabees rather than people who want to meet others and develop a community.
I signed up to Facebook a while ago but never used it at all until recently someone where I work was talking about it. So I logged in, allowed it access to my Gmail address book and off it went and found quite a few people already registered on there.
Over the last 2 weeks I have been steadily adding friends, people have come out of the blue and found me and I have found other people through other friends. Its quite amazing.
Once you are “friends” with people, you also get to see their updates, who they become friends with, new photos they have posted or updates to their “status” tagline. This is the feature that I find most alluring. Its almost like a story evolving over time that you can watch and participate in. YOu can drill through the updates and see the details of each one, leave a comment or perform an action and then return to your profile.
It got me thinking that the ability to follow other “friends” blog posts and comments they leave at other sites would a nice web application to have access to, but a quick search through Google does not reveal much Taoski related information that I could use to follow my comments left on sites or forums.
I am working on relaunching Megatao soon with a new design and a few new ideas in the pot too. I just paid for another years web hosting, so I had better make use of it!
by taoski on July 2, 2007
Leave me some birthday love in the comments… I deserve it!
Best comment gets a special prize…