DeletedUser
Guest
Nå trippel posta du!
Men ellers bra script, bortsett fra at det ser ut som den bommer veldig på datoen :razz:
Ja, hørte noen sa det skal se på det når jeg får tid
Nå trippel posta du!
Men ellers bra script, bortsett fra at det ser ut som den bommer veldig på datoen :razz:
Etter enda en oppdatering har det sluttet å virke igjen.. NaN kommer opp.. igjen
Forrige oppdatering forrandret hvordan datoene blir skrevet i kommando siden for et enkelt angrep. Derfor vil ikke det forrige fungerende scriptet kunne tagge med ca "sent"-tid. Her er et som værtfall vil fungere ut august:Kode:javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mar.","march"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("okt.","october"); hop = hop.replace("aug.","october"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
Når jeg angriper meg selv (for å teste ut scriptet), så får jeg bare vite hvilke distanse det er mellom byene. Noen andre som har samme problem? Bruker safari
javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mar.","march"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("aug.","october"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mar.","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("nov.","november"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
Hva er det som gjør at scriptet har en utløpsdato?
EDIT: Og hvorfor fungerer det ikke hos meg? Opera. Casual.
Denne her skal fungere hele året.
[spoil][/spoil]Kode:javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mar.","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("nov.","november"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mars","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("nov.","november"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
Supert, den funket. Tusen takk!Denne skal funke:
[spoil][/spoil]Kode:javascript: hops = document.getElementById('edit').parentNode.parentNode.parentNode.getElementsByTagName('td'); hop = hops[11].innerText; hop = hop.slice(0, -4); hop = hop.replace("jan.","january"); hop = hop.replace("feb.","february"); hop = hop.replace("mars","march"); hop = hop.replace("apr.","april"); hop = hop.replace("mai","may"); hop = hop.replace("jun.","june"); hop = hop.replace("jul.","july"); hop = hop.replace("aug.","august"); hop = hop.replace("sep.","september"); hop = hop.replace("okt.","october"); hop = hop.replace("nov.","november"); hop = hop.replace("des.","december"); hops[11].innerText = hop;var doc=document; if(window.frames.length>0)doc=window.main.document; url = doc.URL; function myErrorSuppressor() { return true; } window.onerror = myErrorSuppressor; function labelAttack() { if (typeof (theFormat) == 'undefined') theFormat = '{unit} - {origin} - {player} - ID: {atkid} - Sent: {sent}'; arrUnitNames = ['Scout', 'LC', 'HC', 'Axe', 'Sword', 'Ram', '***Noble***']; arrReplace = ['unit', 'coords', 'player', 'distance', 'sent', 'duration', 'arrival', 'origin', 'destination', 'destinationxy', 'atkid']; arrHead = ['Unit', 'Sent', 'Duration', 'Name To']; arrValues = arrReplace; function fnReg(txtString) { return new RegExp("\{" + txtString + "\}", "ig"); } arrReplace = arrReplace.map(fnReg); function fnGetConfig() { var oRequest = new XMLHttpRequest(); var sURL = "http://" + window.location.hostname + "/interface.php?func=get_config"; oRequest.open("GET", sURL, 0); oRequest.send(null); if (oRequest.status == 200) return oRequest.responseXML; alert("Error executing XMLHttpRequest call to get Config!"); } var xmldocument = fnGetConfig(); theUnitSpeed = xmldocument.getElementsByTagName('unit_speed')[0].childNodes[0].nodeValue; theWorldSpeed = xmldocument.getElementsByTagName('speed')[0].childNodes[0].nodeValue; function myGetCoords(theString) { return /(.*?)\s\(((\d+)\|(\d+))\)\sK(\d+)/i.exec(theString); } function myZeroPad(theString) { theInt = parseInt(theString, 10); return (theInt > 9 ? theInt : '0' + theInt); } function myGetElementsByTagName(theObj, theString) { return theObj.getElementsByTagName(theString); } function myGetInner(theObj) { return theObj.innerHTML; } function myGetInnerofFirstLink(theObj) { return myGetInner(myGetElementsByTagName(theObj, 'a')[0]); } function myInsRow() { return theTable.insertRow(intRow++); } function fnAttackID() { var a = document.URL.match(/\d+/g); return document.URL.match(/\d+/g)[a.length - 1]; } function myInsCell(theInt) { return newRow.insertCell(theInt); } function mySetInner(theObj, theString) { theObj.innerHTML = theString; return theObj; } function myInsTH(theString) { newCell = newRow.appendChild(document.createElement('th')); return mySetInner(newCell, theString); } function myTime(theInt) { return myZeroPad(theInt / Const3600) + ':' + myZeroPad(theInt % (Const3600) / Const60) + ':' + myZeroPad(theInt % Const60); } function fnInt(txtInt) { return parseInt(txtInt, 10); } function fnDate(txtDate) { arrMs = txtDate.match(/:(\d{3})$/i); if (arrMs) txtDate = txtDate.replace(/:(\d{3})$/i, ''); var dtNew = new Date(txtDate); if (dtNew == 'Invalid Date') { var arrDate = txtDate.match(/\b(\d+)\b/ig); arrDate = arrDate.map(fnInt); if (arrDate[2] < 2000) arrDate[2] += 2000; dtNew = new Date(arrDate[2], arrDate[1] - 1, arrDate[0], arrDate[3], arrDate[4], arrDate[5]); } if (arrMs) dtNew.setMilliseconds(arrMs[1]); return dtNew; } Const3600 = 3600; Const60 = 60; ConstWidth = 'width'; theTable = document.getElementById('edit').parentNode.parentNode.parentNode.parentNode; theTable.removeAttribute(ConstWidth); var arrRows = theTable.rows; var intRows = arrRows.length; for (intRow = 0; intRow < intRows; intRow++) { theRow = arrRows[intRow]; theLength = (arrCells = theRow.cells) ? arrCells.length : 0; if (theLength) { arrCells[theLength - 1].colSpan = 5 - theLength; } } arrValues[2] = myGetInnerofFirstLink(arrRows[1].cells[2]); arrAttack = (arrRows[2].cells[1].textContent).match(/\d+\|\d+/ig); arrAttack = arrAttack[arrAttack.length - 1]; arrTarget = (arrRows[4].cells[1].textContent).match(/\d+\|\d+/ig); arrTarget = arrTarget[arrTarget.length - 1]; arrValues[1] = arrRows[2].cells[1].textContent; arrValues[7] = arrAttack; arrValues[8] = arrTarget; arrValues[9] = arrRows[4].cells[1].textContent; arrValues[10]=url.match(/id=(\d+)/)[1]; arrValues[6] = typeof (arrRows[5].cells[1].innerText) == 'undefined' ? arrRows[5].cells[1].textContent : arrRows[5].cells[1].innerText; dtArrival = fnDate(arrValues[6]); arrValues[6] = fnDateFormat(dtArrival); /*alert(fnDateFormat(dtArrival)); for (x = 0; x < arrRows.length - 1; x++) { // alert(x + " " + arrRows[x].cells.length); for (y = 0; y < arrRows[x].cells.length; y++) { alert("X: " + x + " Y: " + y + " --- " + arrRows[x].cells[y].textContent); } } alert(arrRows[intRows - 2].cells[1].innerHTML); */ /* alert(intRows); alert(arrRows[intRows - 1].cells[1]);*/ arrArrivalIn = myGetInner(arrRows[6].cells[1]).match(/\d+/ig); msecsArrivalIn = (arrArrivalIn[0] * Const3600 + arrArrivalIn[1] * Const60 + arrArrivalIn[2] * 1) * 1000; /*alert('txtAttacker :'+txtAttacker+'\narrAttack :'+arrAttack[2]+'|'+arrAttack[3]+'\narrTarget :'+arrTarget[2]+'|'+arrTarget[3]+'\ndtArrival :'+dtArrival+'\narrArrivalIn :'+arrArrivalIn[0]+':'+arrArrivalIn[1]+':'+arrArrivalIn[2]+':'+arrArrivalIn[3]+'\nsecsArrivalIn :'+secsArrivalIn);*/ theXdiff = parseInt(arrAttack.split("|")[0] - arrTarget.split("|")[0]); theYdiff = parseInt(arrAttack.split("|")[1] - arrTarget.split("|")[1]); dblDistance = Math.sqrt(theXdiff * theXdiff + theYdiff * theYdiff); arrValues[3] = dblDistance.toFixed(2); var intRow = intRows - 2; arrElements = myGetElementsByTagName(theTable, 'input'); theInputButton = arrElements[1]; theInputEdit = arrElements[0]; theInputEdit.size = Const60; newRow = myInsRow(); mySetInner(myInsCell(0), 'Distance:').colSpan = 2; mySetInner(myInsCell(1), arrValues[3] + ' Fields').colSpan = 2; newRow = myInsRow(); arrHead.forEach(myInsTH); function fnPreg(varValue, intIdx) { newInput.value = newInput.value.replace(arrReplace[intIdx], varValue); } function fnDateFormat(dtDate) { intMs = dtDate.getMilliseconds(); return myZeroPad(dtDate.getHours()) + ':' + myZeroPad(dtDate.getMinutes()) + ':' + myZeroPad(dtDate.getSeconds()) + '.' + (intMs > 99 ? intMs : '0' + myZeroPad(intMs)) + ' ' + myZeroPad(dtDate.getDate()) + '/' + myZeroPad(dtDate.getMonth() + 1); } for (theIndex in arrUnitNames) { msecsDuration = Math.round([9,10,11,18,22,30,35][theIndex] * Const60 * 1000 * dblDistance / theWorldSpeed / theUnitSpeed); secsDiff = (msecsDuration - msecsArrivalIn) / 1000; if (secsDiff > 0) { arrValues[0] = arrUnitNames[theIndex]; arrValues[5] = myTime(msecsDuration / 1000); dtSent = new Date(dtArrival - msecsDuration); arrValues[4] = fnDateFormat(dtSent); newRow = myInsRow(); mySetInner(myInsCell(0), arrUnitNames[theIndex]); mySetInner(myInsCell(1), secsDiff < Const60 && 'just now' || secsDiff < Const3600 && Math.floor(secsDiff / Const60) + ' mins ago' || myTime(secsDiff) + ' ago'); mySetInner(myInsCell(2), arrValues[5]); newCell = myInsCell(3); newButton = newCell.appendChild(theInputButton.cloneNode(true)); newInput = newCell.appendChild(theInputEdit.cloneNode(true)); newInput.id = 'I' + theIndex; newInput.value = theFormat; arrValues.forEach(fnPreg); newButton.onmousedown = new Function('theInputEdit.value=document.getElementById(\'I' + theIndex + '\').value;'); } } } labelAttack(); void (0);
Morthy skrev:In this update we changed all the places where you see the edit icon to easily rename something to all use the same standard system in an accessible way. Prior to this, each location was implemented differently and had a lot of problems. For example, if your session had expired or your internet connection / server had problems the renaming would just silently failing without telling you. While this will likely have broken some existing scripts, in the future it will be much easier for scripts to hook into renaming things because everything is done in the same way, so it shouldn't take long for script authors to update their scripts.
As a reminder, we do bring updates onto our Beta server before normal worlds, and even have a Sandbox world there to which scripters can apply to join and be granted some free villages and so on for testing. It is the responsibility of script authors to keep their scripts compatible with the game.