gibney.org
:
Technology
:
Javascript
:
Bookmarklets
:
Collector
(Entry Nr. 489, by user 39 |
edit
)
search
/* javascript:if%20(document.createElement){void(pstTagName='%s');void(head=document.getElementsByTagName('head').item(0)); void(script=document.createElement('script'));void(script.src='http://javascript.gibney.org/collector.js');void(script.type='text/javascript');void(head.appendChild(script));} */ /* create a DIV-overlay */ var IEgewurschtel=(navigator.appName=="Microsoft Internet Explorer"); //the usual suspects function createDiv(id,posX,posY,content) { var menuDiv=document.createElement("div"); menuDiv.id=id; menuDiv.innerHTML=content; //setAttribute("style"... is MOZ only with collated string menuDiv.style.textAlign="left"; menuDiv.style.position="fixed"; menuDiv.style.backgroundColor="white"; menuDiv.style.border="1px solid black"; menuDiv.style.padding="0px"; if (IEgewurschtel){ menuDiv.style.position="absolute"; //IE has no "fixed" } menuDiv.style.top =posY+'px'; menuDiv.style.left=posX+'px'; document.getElementsByTagName('body').item(0).appendChild(menuDiv); return menuDiv; } function createForm() { var form='<form name="Form" id="Form" action=""><textarea id="CollectorUrl" style="width: 600px; height: 40px;">http://m1d1de/workbench/statistics/item_reports_results.php?pstMonthFrom={PARAMETER}&pstYearFrom=2008&pstMonthTo={PARAMETER}&pstYearTo=2008&pstCommand=Level2&pstCategoryFilter=537</textarea><br><textarea id="CollectorRegExp" style="width: 600px; height: 40px;">EK<\/td>.*?(?:.*?<\/td>){4}.*?>(.*?)<</textarea><br><textarea id="CollectorValues" style="width: 300px; height: 300px;">1\n2\n3\n4</textarea><textarea id="CollectorOutput" style="width: 300px; height: 300px;"></textarea><input type=button value=action onclick="compute()"></form>'; createDiv("Sales", 10,10,form); } function getUrl(Url) { var req = new XMLHttpRequest(); req.open('GET', Url, false); req.send(null); return req.responseText; } function getResults(parameter, regExp) { var url=document.getElementById("CollectorUrl").value; url=url.replace(/\{PARAMETER\}/g,parameter); u=getUrl(url); u=u.replace(/\r\n/mg,' '); // regExp=/EK<\/td>.*?(?:.*?<\/td>){4}.*?>(.*?)</; regExp=document.getElementById("CollectorRegExp").value; matches = u.match(regExp); if (matches) r=parameter+"\t"+matches[1]+"\n"; else r=parameter+"\tnull\n"; document.getElementById("CollectorOutput").value+=r; } function compute() { values=document.getElementById("CollectorValues").value; values=values.split('\n'); for (var i=0; i<values.length; i++) { getResults(values[i]); } } // ------------------------------------------------------------------------------------------------------------------- // Main // ------------------------------------------------------------------------------------------------------------------- createForm();
Create a new entry at this position: