antisback
Head Gardener
- Joined
- Dec 14, 2007
- Messages
- 429
soooo i'm trying to make my toolkit parse a spy report and label how many ticks have passed since the news happened
it parses the report counts the ticks adds it in fine but when it comes to putting it all back together the tables get mixed up - no matter what i do the stupid thing won't work, so you're all clever people, if anyone can help me solve it, i'll owe you many a sexual favour and my gratitude
And attached is the screenshot of how it turns out
as i say any help will be much appreciated so i can finally finish the toolkit once and for all
it parses the report counts the ticks adds it in fine but when it comes to putting it all back together the tables get mixed up - no matter what i do the stupid thing won't work, so you're all clever people, if anyone can help me solve it, i'll owe you many a sexual favour and my gratitude
Code:
function spyticks(){
var season = getseason();
var curtick = gettick();
if (season == "Summer"){
if(curtick == "Evening"){
tick = 6;
}else if(curtick == "Earlyhours"){
tick = 1;
}else if(curtick == "Dawn"){
tick = 2;
}else if(curtick == "Morning"){
tick = 3;
}else if(curtick == "Noon"){
tick = 4;
}else if(curtick == "Afternoon"){
tick = 5;
}
}else if (season == "Winter"){
if(curtick == "Evening"){
tick = 5;
}else if(curtick == "Earlyhours"){
tick = 1;
}else if(curtick == "Midnight"){
tick = 6;
}else if(curtick == "Morning"){
tick = 2;
}else if(curtick == "Afternoon"){
tick = 3;
}else if(curtick == "Dusk"){
tick = 4;
}
}else{
if(curtick == "Evening"){
tick = 5;
}else if(curtick == "Earlyhours"){
tick = 1;
}else if(curtick == "Midnight"){
tick = 6;
}else if(curtick == "Morning"){
tick = 2;
}else if(curtick == "Afternoon"){
tick = 4;
}else if(curtick == "Noon"){
tick = 3;
}
}
report = content.document.getElementById('main-page-data').innerHTML;
content.document.getElementById('main-page-data').innerHTML = report;
//alert (report);
var trs = report.split("</tr>");
//alert (trs);
xtotal = trs.length;
var x = 0;
for (x=0;x<=xtotal;x++){
var str = trs[x];
//alert (str);
var patt1 = new RegExp("\<span title=");
var result = patt1.test(str);
if (result == true) {
//get date
document.getElementById('randomstoragebox').value = trs[x].match(/\<span\>(.)*\<span title=/g);
var datews = document.getElementById('randomstoragebox').value;
var date = datews.replace(/\,(.)*\<span title=/g,"").replace(/\<span\>/g,"").replace(/st/g,"").replace(/nd/g,"").replace(/rd/g,"").replace(/th/g,"");
var dates = date.split(" ");
if (dates[2]=="Dec") {
var seas2 = "Winter";
var month2 = "12";
} else if (dates[2]=="Jan") {
var seas2 = "Winter";
var month2 = "1";
} else if (dates[2]=="Feb") {
var seas2 = "Winter";
var month2 = "2";
} else if (dates[2]=="Mar") {
var seas2 = "Spring";
var month2 = "3";
} else if (dates[2]=="Apr") {
var seas2 = "Spring";
var month2 = "4";
} else if (dates[2]=="May") {
var seas2 = "Winter";
var month2 = "5";
} else if (dates[2]=="Jun") {
var seas2 = "Summer";
var month2 = "6";
} else if (dates[2]=="Jul") {
var seas2 = "Summer";
var month2 = "7";
} else if (dates[2]=="Aug") {
var seas2 = "Summer";
var month2 = "8";
} else if (dates[2]=="Sept") {
var seas2 = "Autumn";
var month2 = "9";
} else if (dates[2]=="Oct") {
var seas2 = "Autumn";
var month2 = "10";
} else if (dates[2]=="Nov") {
var seas2 = "Autumn";
var month2 = "11";
}
//get time of day
document.getElementById('randomstoragebox').value = trs[x].match(/\<span title=(.)*\<\/span\>/g);
var todws = document.getElementById('randomstoragebox').value;
var tod = todws.replace(/\<span title=(.)*\"\>/g,"").replace(/\<\/span\>/g,"");
//Set Tick
if (seas2 == "Summer"){
if(tod == "Evening"){
spytick = 6;
} else if(tod == "Earlyhours"){
spytick = 1;
} else if(tod == "Dawn"){
spytick = 2;
} else if(tod == "Morning"){
spytick = 3;
} else if(tod == "Noon"){
spytick = 4;
} else if(tod == "Afternoon"){
spytick = 5;
}
} else if (seas2 == "Winter"){
if(tod == "Evening"){
spytick = 5;
} else if(tod == "Earlyhours"){
spytick = 1;
} else if(tod == "Midnight"){
spytick = 6;
} else if(tod == "Morning"){
spytick = 2;
} else if(tod == "Afternoon"){
spytick = 3;
} else if(tod == "Dusk"){
spytick = 4;
}
} else {
if(tod == "Evening"){
spytick = 5;
} else if(tod == "Earlyhours"){
spytick = 1;
} else if(tod == "Midnight"){
spytick = 6;
} else if(tod == "Morning"){
spytick = 2;
} else if(tod == "Afternoon"){
spytick = 4;
} else if(tod == "Noon"){
spytick = 3;
}
}
//get and set currentmonth
var curmonth = getmonth();
if (curmonth=="Dec"){
var month = "12";
} else if (curmonth=="Jan") {
var month = "1";
} else if (curmonth=="Feb") {
var month = "2";
} else if (curmonth=="Mar") {
var month = "3";
} else if (curmonth=="Apr") {
var month = "4";
} else if (curmonth=="May") {
var month = "5";
} else if (curmonth=="Jun") {
var month = "6";
} else if (curmonth=="Jul") {
var month = "7";
} else if (curmonth=="Aug") {
var month = "8";
} else if (curmonth=="Sept") {
var month = "9";
} else if (curmonth=="Oct") {
var month = "10";
} else if (curmonth=="Nov") {
var month = "11";
}
//begin adding up the ticks
var tickscount = parseInt(getdate()) * 6;
var datescount = parseInt(dates[1]) * 6;
var tickcount = parseInt(tickscount) - parseInt(datescount);
var i=0;
while (i != 1){
if(month2 != month){
if(month2 == 1){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
} else if(month2 == 2){
tickcount2 = parseInt(tickcount) + 168;
tickcount = tickcount2;
} else if(month2 == 3){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
} else if(month2 == 4){
tickcount2 = parseInt(tickcount) + 180;
tickcount = tickcount2;
} else if(month2 == 5){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
} else if(month2 == 6){
tickcount2 = parseInt(tickcount) + 180;
tickcount = tickcount2;
} else if(month2 == 7){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
} else if(month2 == 8){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
} else if(month2 == 9){
tickcount2 = parseInt(tickcount) + 180;
tickcount = tickcount2;
} else if(month2 == 10){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
} else if(month2 == 11){
tickcount2 = parseInt(tickcount) + 180;
tickcount = tickcount2;
} else if(month2 == 12){
tickcount2 = parseInt(tickcount) + 186;
tickcount = tickcount2;
}
month3 = parseInt(month2) + 1;
month2 = month3;
if (month2 == 13){
month2 = 1;
}
} else {
i=1;
}
}
var tickmod = tick - spytick;
var tickcounter = tickcount + tickmod;
if(tickcounter == 0){
var newtr = trs[x].replace(/\<\/span\>\<\/span\>/g,"</span></span> <span class=\"friendly\">This Tick</span>");
} else {
var newtr = trs[x].replace(/\<\/span\>\<\/span\>/g,"</span></span> <span class=\"friendly\">"+tickcounter+" Ticks Ago</span>");
}
} else {
var newtr = trs[x];
}
//put back together
if(x == 0){
content.document.getElementById('main-page-data').innerHTML = newtr;
} else {
var olddata = content.document.getElementById('main-page-data').innerHTML;
//alert (olddata);
var newdata = olddata +"</tr>"+ newtr;
//alert (newdata);
content.document.getElementById('main-page-data').innerHTML = newdata;
}
}
}
And attached is the screenshot of how it turns out
as i say any help will be much appreciated so i can finally finish the toolkit once and for all