Ok, I will be honest - my first javascript challenge is a little hard, but has been handed down to me from my uncle. He doesnt know how to do it, and thinks a fresh mind might be able to make sence of it. Fresh meaning fairly new to js... not his wisest move I would say.
I come here instead :)
Here's the deal - I believe that he intends to make a program to execute a function (in his case, a vote) when a timer reaches 1.
The timer is located somewhere in a javascript he has provided me with, and after some scouring, I think I have found the relevent area.
The script passes along the timer text to a webpage in the form of HH:MM:SS - but I need another way of geting that timer data out (to a program or script??).
1. Is there a way to extract the timer data in any way shape or form?
He would be rapt if I could solve his final programming challenge too, but this might be a bit (read: lot) more challenging.
2. What ways could I get that data into a local javascript (or anything else if easier) script to make it execute a function (not sure, but I believe just a url or mouse press) when the timer reaches 1 second. The original script in full and page with the timer will be located on his server and accessable to me through the web, so the script would need to be capable of running locally from me to him. Can that be done??
Please ask and I would be delighted to give you any other info you need.
Here is the part of the script where I believe the final condition for the timer is handled. As I am new to js, let me know if I have butchered anything before or after that is critical to you understanding the timer function.
// JavaScript Document (Part)
update: function (updateTime) {var id, pollId, i, count, item, amount_element, time_element, element, field, value;if ((typeof updateTime === "undefined" || updateTime === true) && this.serverTimeUpdated === null || new Date - this.serverTimeUpdated > 1000) {++this.serverTime;}this.updateServerTime();if (typeof this.data.pollList !== "undefined") {for (pollId in this.data.pollList.itemList) {item = this.data.pollList.itemList[pollId];if (item.status !== "online" && item.status !== "offline") {continue;}item.updated.push("time");id = "poll_" + pollId;i = 0;count = item.updated.length;if (typeof this.elementList[id] !== "undefined" && count > 0) {for (; i < count; ++i) {field = item.updated[i];if (field === "count_down_time") {if (this.ignoreNextTimeHighlight === pollId) {this.ignoreNextTimeHighlight = false;} else {this.highlight(this.elementList[id].time);}continue;}value = item[field];if (field === "amount") {this.needAdditionalDataUpdate = true;value = this.formatAmount(value);} else if (field === "time") {if (item.status === "offline") {value = "00:00:00";} else {timeRemaining = value - this.serverTime - 1;if (timeRemaining > 0) {if (item.status === "completed") {item.status = "online";this.setPollAsOnline(item);}value = this.formatTime(timeRemaining);} else {value = "00:00:00";if (item.status === "completed") {continue;}}if (typeof this.elementList[id][field] !== "undefined") {element = this.elementList[id][field];var className = this.getTimerColorClass(item.status, timeRemaining);element.className = element.className.replace(/ red| green| dark_gray/, "") + " " + className;}}}