Script for easy edit

General questions about scripts and buttons should be asked here. Development scripts and buttons may also be posted for feedback.

Moderators: Support Staff², Support Staff, AvantGuard, Developer

Post Reply
jogelu
Newbie
Newbie
Posts: 2
Joined: Thu Aug 27, 2009 7:31 pm
Windows Version: XPSP3
Avant Version: 11.7 Build 36
IE Version: IE8

Script for easy edit

Post by jogelu » Thu Aug 27, 2009 7:41 pm

Hello Guys,

One of my colleagues created a script to post updates in the pages we use every day at work.

I don't have a clue on how to edit/create js scripts, so I hope you can help me creating one for Avant.

This script is originally created for Firefox (I don't like it) using greasemonkey.

The purpose is to have access to a small box on the webpage corner that edits and updates the pages we use to work. Basically sends updates to an Oracle database.

Can you help me?

Please excuse me if this is not the place to create this post.

Thanks is advance

User avatar
sulpherdragon
Contributor
Contributor
Posts: 222
Joined: Sat Dec 15, 2007 9:51 pm
Windows Version: Windows 7
Avant Version: 2013 Build 23
Default engine: Firefox
IE Version:
Skin:
Contact:

Re: Script for easy edit

Post by sulpherdragon » Thu Aug 27, 2009 11:59 pm

Almost all scripts that work in firefox can be converted to work in IE, can you give us the code so we can look at it? or at least tell us where we can find it?
Image

jogelu
Newbie
Newbie
Posts: 2
Joined: Thu Aug 27, 2009 7:31 pm
Windows Version: XPSP3
Avant Version: 11.7 Build 36
IE Version: IE8

Re: Script for easy edit

Post by jogelu » Fri Aug 28, 2009 5:58 pm

Sure, thank you.. this is the one.

Code: Select all

// ==UserScript==
// @name Workbench Buddy
// @namespace http://www-tac.cisco.com
// @description Adds workbench features to XML/CaseKwery
// @include http://www-tac.cisco.com/Teams/ks/c3/casekwery.php*
// @include http://www-tac.cisco.com/Teams/ks/c3/casekwery2.php*
// @include http://www-tac.cisco.com/Teams/ks/c3/xmlkwery2.php*
// @include http://www-tac.cisco.com/Teams/ks/c3/xmlkwery.php*
// @include http://www-tac.cisco.com/Teams/ks/c3/xmlpref.php*
// @include http://wwwin-tools.cisco.com/ServiceRequestTool/update/SrDetails.do*
// @include http://wwwin-tools.cisco.com/ServiceRequestTool/update/SrUpdate.do*
// @include http://wwwin-tools.cisco.com/ServiceRequestTool/update/CloseSr.do*
//Made By Magnus Mortensen
// ==/UserScript==

window.CheckForReload = function () {
// This function's goal is to check once per second to see if the workbench change request as posted or not.
// The post is successful when the "WB Post Pending" variable is set to the SR number with "posted" as a suffix
// When we find that the post has completed, we will refresh this page to reflect the change.
	if ( GM_getValue ("WB Post Pending", "NULL") == SR   "failed" ) {
		GM_setValue ("WB Post Pending", "");
		GM_setValue ("SR To Post", "");
		WBBuddySubmitButton.value = "Update!";
		}
	else if ( GM_getValue ("WB Post Pending", "NULL") == SR   "posted" ) {
		GM_setValue ("WB Post Pending", "");
		GM_setValue ("SR To Post", "");
		WBBuddySubmitButton.value = "Done!";
	if (GM_getValue("Enable AS", true))	clearautosaveWBbuddy();
	if (GM_getValue("Enable AS", true))	resetWBbuddy();
		var MyLocation = window.location.href;
		
		// Check for # in URL which breaks Java Refresh. This is a known issue with Javascript I think.
		var HashPoint = MyLocation.indexOf('#');
		if (HashPoint != -1 ) CleanUrl=MyLocation.substring(0,HashPoint);
		else CleanUrl= MyLocation.substring(0,MyLocation.length);
		
		if ( !(/[0-9]{9}/.test(CleanUrl) ) ) {
			CleanUrl  = "?Case="   SR;
			}
		window.location.href = CleanUrl;
		//window.location.hash = "#lastNote";
	}
	else {
	window.setTimeout( CheckForReload, 1000);
	}
}


resetWBbuddy = function () {

	var WBBstatusmenu=document.getElementById("WBBstatus");
	var WBBnotetypemenu=document.getElementById("WBBnotetype");
	var WBBnotestatusmenu=document.getElementById("WBBnotestatus");
	var WBBnotetext=document.getElementById("WBBnote");
	var WBBtitletext=document.getElementById("WBBtitle");
	var WBBtitleOrigtext=document.getElementById("WBBtitleOrig");
	var WBBbugtext=document.getElementById("WBBbug");
	var WBBseverity=document.getElementById("WBBseverity");
	
	WBBseverity.selectedIndex = 0;
	WBBstatusmenu.selectedIndex = 0;
	WBBnotetypemenu.selectedIndex = 0;
	WBBnotestatusmenu.selectedIndex = 0;
	WBBnotetext.value = "";	
	WBBbugtext.value = "";	
	WBBtitletext.value = WBBtitleOrigtext.value;
	
} 


autosaveWBbuddy = function () {

	
	var WBBstatusmenu=document.getElementById("WBBstatus");
	var WBBnotetypemenu=document.getElementById("WBBnotetype");
	var WBBnotestatusmenu=document.getElementById("WBBnotestatus");
	var WBBnotetext=document.getElementById("WBBnote");
	var WBBtitletext=document.getElementById("WBBtitle");
	var WBBtitleOrigtext=document.getElementById("WBBtitleOrig");
	var WBBbugtext=document.getElementById("WBBbug");
	var WBBseverity=document.getElementById("WBBseverity");
	if ( WBBnotetext.value == "") return;
	
	GM_setValue("AS Severity", WBBseverity.selectedIndex);
	GM_setValue("AS Status", WBBstatusmenu.selectedIndex);
	GM_setValue("AS Note Type", WBBnotetypemenu.selectedIndex);
	GM_setValue("AS Note Status", WBBnotestatusmenu.selectedIndex);
	GM_setValue("AS Note Text", WBBnotetext.value);	
	GM_setValue("AS Bug Text", WBBbugtext.value);	
	GM_setValue("AS Title Text", WBBtitletext.value);
	GM_setValue("AS SR Number", SR);
} 

restoreautosaveWBbuddy = function () {

	if (SR != GM_getValue("AS SR Number", "" ) ) return;
	if (confirm('I found a unposted note for this case. Shall I restore the note into Workbench Buddy?')) { 
	var WBBstatusmenu=document.getElementById("WBBstatus");
	var WBBnotetypemenu=document.getElementById("WBBnotetype");
	var WBBnotestatusmenu=document.getElementById("WBBnotestatus");
	var WBBnotetext=document.getElementById("WBBnote");
	var WBBtitletext=document.getElementById("WBBtitle");
	var WBBtitleOrigtext=document.getElementById("WBBtitleOrig");
	var WBBbugtext=document.getElementById("WBBbug");
	var WBBseverity=document.getElementById("WBBseverity");
	
	WBBseverity.selectedIndex = GM_getValue("AS Severity", "");
	WBBstatusmenu.selectedIndex = GM_getValue("AS Status", "");
	WBBnotetypemenu.selectedIndex = GM_getValue("AS Note Type", "");
	WBBnotestatusmenu.selectedIndex = GM_getValue("AS Note Status", "");
	WBBnotetext.value = GM_getValue("AS Note Text", "");	
	WBBbugtext.value = GM_getValue("AS Bug Text", "");	
	WBBtitletext.value = GM_getValue("AS Title Text", "");
	}
		clearautosaveWBbuddy();

} 

clearautosaveWBbuddy = function () {

	GM_setValue("AS Severity", "");
	GM_setValue("AS Status", "");
	GM_setValue("AS Note Type", "");
	GM_setValue("AS Note Status", "");
	GM_setValue("AS Note Text","");	
	GM_setValue("AS Bug Text","");	
	GM_setValue("AS Title Text", "");
	GM_setValue("AS SR Number", "");
} 

templateWBbuddy = function () {

	var WBBTemplates=document.getElementById("WBBTemplates");
	var WBBTEMP = WBBTemplates.options[WBBTemplates.selectedIndex].value;
	//find the index number
	if (WBBTEMP == "NULL TEMPLATE") {
	resetWBbuddy();
	return;
	}
	var indexnum;
	for ( var i = 0; i < templateID.length; i  )
	{
	if(templateID[i] == WBBTEMP) break;
	}
	if (i == templateID.length) return;
	
	if (templateNoteText[i] != "NULL" ) document.getElementById('WBBnote').value=templateNoteText[i];
	if (templateNoteType[i] != "NULL" ) document.getElementById('WBBnotetype').value=templateNoteType[i];
	if (templateNoteState[i] != "NULL" ) document.getElementById('WBBnotestatus').value=templateNoteState[i];
	if (templateState[i] != "NULL" ) document.getElementById('WBBstatus').value=templateState[i];
				
} 

saveWBbuddy = function () {

	var WBBTemplateURL = document.getElementById("WBBTemplateURL");
	GM_setValue("TemplateURL", WBBTemplateURL.value) ;
	
	var ShowInitialResponse = document.getElementById("ShowInitialResponse");
	GM_setValue("Show Initial Responses", ShowInitialResponse.checked) ;

	var ShowShortcutsOnWB = document.getElementById("ShowShortcutsOnWB");
	GM_setValue("Show Shortcuts on CSE Workbench", ShowShortcutsOnWB.checked) ;
	
	var EnableAS = document.getElementById("EnableAS");
	GM_setValue("Enable AS", EnableAS.checked) ;

	var ShowStateChanger = document.getElementById("ShowStateChanger");
	GM_setValue("Show State Changer", ShowStateChanger.checked) ;

	var ShowNotesDMM = document.getElementById("ShowNotesDMM");
	GM_setValue("Show Notes: DMM", ShowNotesDMM.checked) ;

	var ShowNotesKT = document.getElementById("ShowNotesKT");
	GM_setValue("Show Notes: KT", ShowNotesKT.checked) ;

//	var CloseConfirmationPages = document.getElementById("CloseConfirmationPages");
//	GM_setValue("Close Confirmation Pages", CloseConfirmationPages.checked) ;

	var setPref = document.getElementById('saveWBB');
	setPref.value="Preferences have been saved!";
					
} 

oneclickWBbuddy = function (OnceCLickID) {

	if (OnceCLickID == "LVM"){
	document.getElementById('WBBnote').value='Initial Response: Called the customer. Left a voice mail.';
	document.getElementById('WBBnotetype').value='CISCO_INIT_PHONE';
	document.getElementById('WBBnotestatus').value='I';
	submitWBbuddy();
	}
	else if (OnceCLickID == "OTP"){
	document.getElementById('WBBnote').value='Initial Response: On the phone with the customer now.';
	document.getElementById('WBBnotetype').value='CISCO_INIT_PHONE';
	document.getElementById('WBBnotestatus').value='I';
	submitWBbuddy();
	}
	else if (OnceCLickID == "SE"){
	document.getElementById('WBBnote').value='Initial Response: Sent the customer an email.';
	document.getElementById('WBBnotetype').value='CISCO_INIT_EMAIL';
	document.getElementById('WBBnotestatus').value='I';
	submitWBbuddy();
	}
	else if (OnceCLickID == "DEP"){
	document.getElementById('WBBstatus').value='115';
	submitWBbuddy();
	}
	else if (OnceCLickID == "DEPW"){
	document.getElementById('WBBstatus').value='116';
	submitWBbuddy();
	}
	else if (OnceCLickID == "CUP"){
	document.getElementById('WBBstatus').value='112';
	submitWBbuddy();
	}	
	else if (OnceCLickID == "CUPW"){
	document.getElementById('WBBstatus').value='113';
	submitWBbuddy();
	}	
	else if (OnceCLickID == "CEP"){
	document.getElementById('WBBstatus').value='105';
	submitWBbuddy();
	}	
	else if (OnceCLickID == "CEPW"){
	document.getElementById('WBBstatus').value='107';
	submitWBbuddy();
	}	
	else if (OnceCLickID == "CLP"){
	document.getElementById('WBBstatus').value='108';
	submitWBbuddy();
	}
	else if (OnceCLickID == "CLO"){
	document.getElementById('WBBstatus').value='2';
	submitWBbuddy();
	}
	else if (OnceCLickID == "SOL"){
	document.getElementById('WBBstatus').value='140';
	submitWBbuddy();
	}
	
} 


submitWBbuddy = function () {
// This function's purpose is to process the submission of a Workbench note or state change. 
// The variables in question include a Note Type, Note Status, and a Note Text. This must be sanity checked before proceeding to post
// the change. Data is carried between XML and Workbench via GM_setValue and GM_getValue.
	GM_setValue ("SR To Post", SR);
	
	// Find if we want to change case state
	var WBBstatusmenu=document.getElementById("WBBstatus");
	if (WBBstatusmenu.options[WBBstatusmenu.selectedIndex].value != "NULL CASE STATE") {
		GM_setValue ("Case Status", WBBstatusmenu.options[WBBstatusmenu.selectedIndex].value );
		GM_setValue ("Case State Change", true);
	}
	else GM_setValue ("Case State Change", false);
	
	var WBBseveritymenu=document.getElementById("WBBseverity");
	if (WBBseveritymenu.options[WBBseveritymenu.selectedIndex].value != "NULL") {
		GM_setValue ("Case Severity", WBBseveritymenu.options[WBBseveritymenu.selectedIndex].value );
		GM_setValue ("Case Severity Change", true);
	}
	else GM_setValue ("Case Severity Change", false);
	
	// Find if we want to change title
	var WBBtitletext=document.getElementById("WBBtitle");
	var WBBtitleOrigtext=document.getElementById("WBBtitleOrig");
	if (WBBtitletext.value != WBBtitleOrigtext.value) {
		GM_setValue ("Case Title", WBBtitletext.value );
		GM_setValue ("Case Title Change", true);
	}
	else GM_setValue ("Case Title Change", false);
	
// Find if we want to add a bug
	var WBBbugtext=document.getElementById("WBBbug");
	if (WBBbugtext.value != "") {
		GM_setValue ("Case Bug", WBBbugtext.value );
		GM_setValue ("Case Bug Change", true);
	}
	else GM_setValue ("Case Bug Change", false);
		
	var WBBnotetypemenu=document.getElementById("WBBnotetype");
	var WBBnotestatusmenu=document.getElementById("WBBnotestatus");
	var WBBnotetext=document.getElementById("WBBnote");
	
	// If the note field is empty I assume no note was to be posted.
	if (WBBnotetext.value != "") {
		GM_setValue ("Case Note Change", true);
		// Sanity check the note type		
		if ( WBBnotetypemenu.options[WBBnotetypemenu.selectedIndex].value == "NULL NOTE TYPE") {
			alert ("Please select a note type.");
			return;
		}
		else GM_setValue ("Note Type", WBBnotetypemenu.options[WBBnotetypemenu.selectedIndex].value );
		
		// Sanity check the note status		
		if (WBBnotestatusmenu.options[WBBnotestatusmenu.selectedIndex].value == "NULL NOTE STATUS" ) {
			alert ("Please select a note status");
			return;
		}
		else GM_setValue ("Note Status", WBBnotestatusmenu.options[WBBnotestatusmenu.selectedIndex].value );

		//Sanity check that the note text exists		
		if (WBBnotetext.value == "") {
			alert ("Please enter a note");
			return;
		}
		else GM_setValue ("Note Text", WBBnotetext.value );
	}
	else GM_setValue ("Case Note Change", false);
	
	if ( !(GM_getValue ("Case State Change", false) ) && !(GM_getValue ("Case Severity Change", false)) && !(GM_getValue ("Case Note Change", false)) && !(GM_getValue ("Case Title Change", false)) && !(GM_getValue ("Case Bug Change", false)) ) return;
	//All checks passed, flag the data as ready
	GM_setValue ("Data To Post", true);

	//Set post watcher variable to SR indicating a WB post is in progress
	GM_setValue ("WB Post Pending", SR);

	//Refresh internal Workbench causing it to post new data
	if (WBBstatusmenu.options[WBBstatusmenu.selectedIndex].value == 2 )	{
		WBBuddySubmitButton.value = "Closing...";
		window.open("http://wwwin-tools.cisco.com/ServiceRequestTool/update/SrDetails.do?srNumber="   SR,'_blank');
		window.setTimeout( window.CheckForReload, 1000);
	}
	else {
		WBBuddySubmitButton.value = "Posting...";
		var WBBhiddenFrame=document.getElementById("hiddenFrame");
		WBBhiddenFrame.src= "http://wwwin-tools.cisco.com/ServiceRequestTool/update/SrDetails.do?srNumber="   SR;
		var EmailNoteToOwner = document.getElementById("EmailNoteToOwner");
		if (OwnerEmail=="") EmailNoteToOwner.checked=false;
		if (EmailNoteToOwner.checked){
			var emailbody = WBBnotetext.value.replace('\n','
');
			for (var f=0; f<emailbody.length; f  )
				emailbody = emailbody.replace('\n','
');
			emailbody = "Case details: " CleanUrl "

"   emailbody;
			var mailto_link = 'mailto:' OwnerEmail '?subject=SR ' Title[0].innerHTML ' [' WBBnotetypemenu.options[WBBnotetypemenu.selectedIndex].innerHTML ']&body=' emailbody;
	
			win = window.open(mailto_link,'emailWindow');
			if (win && win.open &&!win.closed) win.close(); 
		}
		//Begin watching for post completetion
		window.setTimeout( window.CheckForReload, 1000);
	}
}

window.resizeWBbuddy = function () {
    // espereir: Changing the following line in order to work with css/boogieman.css	
    //var noteverticalspace = (window.innerHeight - document.getElementById('WBBnote').offsetTop) - 100;
    // espereir: Below is the new value
    var noteverticalspace = (window.innerHeight - document.getElementById('WBBnote').offsetTop) - 200;
	//alert (window.innerHeight   " - "   document.getElementById('WBBnote').offsetTop   " - 100 = "  noteverticalspace);
	if (noteverticalspace < 10) noteverticalspace = 10;
	document.getElementById('WBBnote').style.height=noteverticalspace "px";
	
	}

var WBBScriptVersion = 34;
var AreWeOnXML = /kwery/.test(window.location);
var AreWeOnWB = /SrDetails.do/.test(window.location);
var AreWeOnWBUpdate = /SrUpdate.do/.test(window.location);
var AreWeOnWBClose = /CloseSr.do/.test(window.location);
var AreWeOnXMLPref = /xmlpref.php/.test(window.location);



if (AreWeOnWB) {
	var allLinks, thisLink;
	allLinks = document.evaluate(
    "//span[@class='js']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);

	for (var i = 0; i < allLinks.snapshotLength; i  ) {
	    thisLink = allLinks.snapshotItem(i);
	    //thisLink.parentNode.removeChild(thisLink);
	    thisLink.innerHTML = "<input type='hidden' id=\"document.SRForm.notetext\"></input>";
	}

	var HTML = document.createElement("span");
	var TextArea = document.getElementById('notetext');
	
	//Pick out SR #
	var Title;
	var SR;
	Title = document.getElementsByTagName('title');
		
	if (Title[0].innerHTML.search ( "[0-9]{9}" ) != -1 )
	{
		SR = Title[0].innerHTML.substring(Title[0].innerHTML.search ( "[0-9]{9}" ) , Title[0].innerHTML.search ( "[0-9]{9}" )  9 );
	}
	else alert("I could not find the SR number of this case!");
	


	if ( !GM_getValue ("Data To Post", false) )
	{
		HTML.innerHTML = "";
		//alert ("I am being told to do nothing!!!");
		if (GM_getValue("Show Shortcuts on CSE Workbench", true)){
			HTML.innerHTML  = '<span style="border: 1px;font-size:small;">'  
			'<cexter>'  
			'<div>'  
			'<div><b>Initial Responses:</b></div>' 

			'<table style="width:350px;border:none;padding:2px;">'  
			'<tr><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'noteType\')[0].value=\'CISCO_INIT_PHONE\';' 
			'document.getElementsByName(\'noteStatus\')[0].value=\'I\';' 
			'document.getElementById(\'notetext\').value=\'Called customer. On the phone with customer now.\';' 
			'document.SRForm.submit();' 
			'">' 
			'On the Phone' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'noteType\')[0].value=\'CISCO_INIT_PHONE\';' 
			'document.getElementsByName(\'noteStatus\')[0].value=\'I\';' 
			'document.getElementById(\'notetext\').value=\'Called customer. Left a voice mail.\';' 
			'document.SRForm.submit();' 
			'">' 
			'Left a voicemail' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:150px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'noteType\')[0].value=\'CISCO_INIT_EMAIL\';' 
			'document.getElementsByName(\'noteStatus\')[0].value=\'I\';' 
			'document.getElementById(\'notetext\').value=\'Emailed the customer.\';' 
			'document.SRForm.submit();' 
			'">' 
			'Emailed the customer' 
			'</a>' 
			'</span>'  

			'</center></td></tr>' 
			'</table>' 
			'</div>'  
			'<div>'  
			'<div><b>Status Changes:</b></div>' 

			'<table style="width:300px;border:none;padding:2px;">'  
			'<tr><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'112\';' 
			'document.SRForm.submit();' 
			'">' 
			'CU-Pend' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'105\';' 
			'document.SRForm.submit();' 
			'">' 
			'CE-Pend' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'115\';' 
			'document.SRForm.submit();' 
			'">' 
			'DE-Pend' 
			'</a>' 
			'</span>'  

			'</center></td></tr>'  
			'<tr><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'113\';' 
			'document.SRForm.submit();' 
			'">' 
			'CU-Pend-W' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'107\';' 
			'document.SRForm.submit();' 
			'">' 
			'CE-Pend-W' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'116\';' 
			'document.SRForm.submit();' 
			'">' 
			'DE-Pend-W' 
			'</a>' 
			'</span>'  

			'</center></td></tr>'  
			'<tr><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'140\';' 
			'document.SRForm.submit();' 
			'">' 
			'Sol-Pro' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'108\';' 
			'document.SRForm.submit();' 
			'">' 
			'Clo-Pend' 
			'</a>' 
			'</span>'  

			'</center></td><td style="width:100px;"><center>'  

			'<span style="cursor:pointer">'  
			'<a onclick="' 
			'document.getElementsByName(\'status\')[0].value=\'2\';' 
			'document.SRForm.submit();' 
			'">' 
			'Close' 
			'</a>' 
			'</span>'  


			'</center></td></tr>'  
			'</table>'  

			'</cexter></td></tr>' 

			'</table>'  
			'</div>' 
			'</span>';
			}


		TextArea.parentNode.innerHTML  = HTML.innerHTML ;
		}
	
	else
	{
		HTML.innerHTML = '<img style="visibility: hidden;" src="http://www-tac.cisco.com/Teams/ks/counter/counter.php?name=WBBShortCutCountBeta" >';
		//Data to post.... Woot.
		TextArea.parentNode.innerHTML  = HTML.innerHTML ;
		if ( GM_getValue ("Data To Post", false) && ( 	GM_getValue ("SR To Post", "") == SR ) )
		{
		
			if ( GM_getValue ("Case State Change", false ) ) {
				GM_setValue ("Data To Post", false);

				GM_setValue ("Case State Change", false);
				
				var WBBToPostSR = GM_getValue ("SR To Post");
				GM_setValue ("SR To Post", "");

				var WBBToPostCaseStatus = GM_getValue ("Case Status");
				GM_setValue ("Case Status", "" );
				
				document.getElementsByName('status')[0].value=WBBToPostCaseStatus;
			}
			
			if ( GM_getValue ("Case Severity Change", false ) ) {
				GM_setValue ("Data To Post", false);

				GM_setValue ("Case Severity Change", false);
				
				var WBBToPostSR = GM_getValue ("SR To Post");
				GM_setValue ("SR To Post", "");

				var WBBToPostCaseSeverity = GM_getValue ("Case Severity");
				GM_setValue ("Case Severity", "" );
				
				document.getElementsByName('severity')[0].value=WBBToPostCaseSeverity;
			}
					
			if ( GM_getValue ("Case Title Change", false ) ) {
				GM_setValue ("Data To Post", false);

				GM_setValue ("Case Title Change", false);
				
				var WBBToPostSR = GM_getValue ("SR To Post");
				GM_setValue ("SR To Post", "");

				var WBBToPostCaseTitle = GM_getValue ("Case Title");
				GM_setValue ("Case Title", "" );
				
				document.getElementsByName('srTitle')[0].value=WBBToPostCaseTitle;
			}
								
			if ( GM_getValue ("Case Bug Change", false ) ) {
				GM_setValue ("Data To Post", false);

				GM_setValue ("Case Bug Change", false);
				
				var WBBToPostSR = GM_getValue ("SR To Post");
				GM_setValue ("SR To Post", "");

				var WBBToPostCaseBug = GM_getValue ("Case Bug");
				GM_setValue ("Case Bug", "" );
				
				document.getElementsByName('bugToLink')[0].value=WBBToPostCaseBug;
			}
			
			if ( GM_getValue ("Case Note Change", false ) ) {
				GM_setValue ("Data To Post", false);
				GM_setValue ("Case Note Change", false )

				var WBBToPostSR = GM_getValue ("SR To Post");
				GM_setValue ("SR To Post", "");

				var WBBToPostNoteType = GM_getValue ("Note Type");
				GM_setValue ("Note Type", "" );
			
				var WBBToPostNoteStatus = GM_getValue ("Note Status");
				GM_setValue ("Note Status", "" );			
			
				var WBBToPostNoteText = GM_getValue ("Note Text");
				GM_setValue ("Note Text", "" );
			
				document.getElementsByName('noteType')[0].value=WBBToPostNoteType;
				document.getElementsByName('noteStatus')[0].value=WBBToPostNoteStatus;
				document.getElementById('notetext').value=WBBToPostNoteText;
				
			//Set variables!			
			}
				document.getElementsByName('SRForm')[0].submit();
		}
	}
}

else if (AreWeOnXML) {

	var viewportwidth;
	var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
	if (typeof window.innerWidth != 'undefined')
	{
		viewportwidth = window.innerWidth,
		viewportheight = window.innerHeight
	}
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

	else if (typeof document.documentElement != 'undefined'
		&& typeof document.documentElement.clientWidth !=
		'undefined' && document.documentElement.clientWidth != 0)
	{
		viewportwidth = document.documentElement.clientWidth,
		viewportheight = document.documentElement.clientHeight
	}
 
 // older versions of IE
 
	else
	{
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
		viewportheight = document.getElementsByTagName('body')[0].clientHeight
	}

	if (viewportheight < 1000){
		var AllBugDiv;
		var thisBugDiv;
		AllBugDiv = document.evaluate( "//div[@class='bugs']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
		if (AllBugDiv.snapshotLength > 0)
		{
			thisBugDiv = AllBugDiv.snapshotItem(0);
			thisBugDiv.style.maxHeight="100px";
		}
	}
	
 
 //Find the  offset of the 'GCI link'
 
 	var AllGCISpan;
	var thisGCISpan;
	var curleft = curtop = 0;
	var obj;
	AllGCISpan = document.evaluate( "//span[@class='gci']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	if (AllGCISpan.snapshotLength > 0)
	{
		thisGCISpan = AllGCISpan.snapshotItem(0);
		obj = thisGCISpan;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft  = obj.offsetLeft
				curtop  = obj.offsetTop
			}
		}
	}

//Our vertical play pen is how big???
//Just using 40 for testing
var verticalspace = viewportheight - curtop - 110;
var noteverticalspace = viewportheight - curtop - 300;



//main vars
	var allDivs, thisDiv;
	var UpdateBlock;

//Pick out SR #
	var Title;
	var SR;
	var CleanTitle;
	
	Title = document.getElementsByTagName('title');
	
	
	if (Title[0].innerHTML.search ( "[0-9]{9}" ) != -1 )
	{
		SR = Title[0].innerHTML.substring(Title[0].innerHTML.search ( "[0-9]{9}" ) , Title[0].innerHTML.search ( "[0-9]{9}" )  9 );
		CleanTitle = Title[0].innerHTML.substring(10,Title[0].innerHTML.length);
	}
	else return;
	
	var EscapedCleanTitle = CleanTitle.replace(/\"/g, """);
	
//Build Template library
	GM_xmlhttpRequest({
		method: 'GET',
		url: "http://172.18.254.190/scripts/versions/wbbuddy.ver" ,
		headers: {
			'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
			'Accept': 'application/atom xml,application/xml,text/xml',
			},
		onload: function(responseDetailsVer){
		GM_setValue("Latest Version", responseDetailsVer.responseText);
		}
	});
	GM_xmlhttpRequest({
		method: 'GET',
		url: GM_getValue("TemplateURL", "http://172.18.254.190/scripts/includes/templates.txt") ,
		headers: {
			'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
			'Accept': 'application/atom xml,application/xml,text/xml',
			},
		onload: function(responseDetails){
		GM_setValue("Templates Data", responseDetails.responseText);
		}
	});
	var templateRaw = GM_getValue("Templates Data", "Templates Not Loaded");
	var templateStrings = new Array();
	var templateID = new Array();
	var templateName = new Array();
	var templateState = new Array();
	var templateNoteType = new Array();
	var templateNoteState = new Array();
	var templateNoteText  = new Array();
	
		templateStrings = templateRaw.split('\n');
	for (var z = 0; z < templateStrings.length; z  ) {
			if ( /###STARTTEMPLATE###/.test( templateStrings[z] ) ){
				//we started a template
				z  ; //Get the tamplate ID
				templateID.push(templateStrings[z].replace('\r', '', 'g') );
				z  ; //Get the tamplate name
				templateName.push(templateStrings[z].replace('\r', '', 'g') );
				z  ; //get the template state change
				templateState.push(templateStrings[z].replace('\r', '', 'g') );
				z  ; //get the template note type
				templateNoteType.push(templateStrings[z].replace('\r', '', 'g') );
				z  ; //get the template note state
				templateNoteState.push(templateStrings[z].replace('\r', '', 'g') );
				z  ; // Get the rest of the note text
				var tempNoteText = '';
				while ( z < templateStrings.length ){
					if (/###ENDTEMPLATE###/.test( templateStrings[z].replace('\n', '', 'g')  ) ) break;
					tempNoteText  = templateStrings[z]  '\n';
					z  ;
					}
				templateNoteText.push(tempNoteText);
				}
			}

//Find Owner
	var Owner, OwnerEmail;
	OwnerEmail = "";
	var allAs;
	var thisA;
	allAs = document.evaluate( "//a[@title='Owner']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	if (allAs.snapshotLength > 0){
		thisA = allAs.snapshotItem(0);
		Owner = thisA.innerHTML;
		OwnerEmail = Owner   "@cisco.com";
	}
	
	var MyLocation = window.location.href;
	var HashPoint = MyLocation.indexOf('#');

		
	if (HashPoint != -1 ){
	CleanUrl=MyLocation.substring(0,HashPoint);
	}
	else{
	CleanUrl=MyLocation.substring(0,MyLocation.length);
	}
	
	
	var prefEmail, prefPhone;
	var nullDiv, nullDivE;
	var InitialResponseCode;
	var OneClickCode;

//check to see if a null note is already there....
	nullDiv = document.evaluate( "//div[@class='note Internal null']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	nullDivE = document.evaluate( "//div[@class='note External null']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	//check to see if preferred is email
	prefEmail = document.evaluate( "//img[@title='customer prefers email']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	
	//check to see if preferred is phone
	prefPhone = document.evaluate( "//img[@title='customer prefers phone']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	
	OneClickCode = '<span id="InitialResponse" style="display:none;"><pre><div class="header">Initial Responses:</div>'  
// espereir: This is the one in order to change the width of the GCI box (previously set to 200, changed to 350
	'<div style="border:none;"><center><table style="width:350px;border:none;padding:2px;"><tr>'  
	'<td style="border:none;"><center><span id="WBBOneClickOTP" style="display:none;" onmouseover="this.style.cursor=\'pointer\';" >On the phone</span></center></td>'   
	'<td style="border:none;"><center><span id="WBBOneClickLVM" style="display:none;" onmouseover="this.style.cursor=\'pointer\';" >Left a voicemail</span></center></td>'  
	'<td style="border:none;"><center><span id="WBBOneClickSE" style="display:none;" onmouseover="this.style.cursor=\'pointer\';" >Emailed the customer</span></center></td>'  
	'<td style="border:none;"><center><span id="WBBOneClickRIC" style="display:none;" onmouseover="this.style.cursor=\'default\';" >Initial Response Note already in the case.</span></center></td>'  
	'</tr></table></center></div></pre></span>';
	
OneClickCode  = '<span id="StateChanger" style="display:none;" ><pre><div class="header">Case Status:</div>'  
	'<div  id="StateChanger" style="border:none;"><center><table style="width:250px;border:none;padding:2px;"><tr>'  
	'<td style="border:none;"><center><span id="WBBOneClickCUP" onmouseover="this.style.cursor=\'pointer\';" >CU-Pend</span></center></td>'   
	'<td style="border:none;"><center><span id="WBBOneClickCEP" onmouseover="this.style.cursor=\'pointer\';" >CE-Pend</span></center></td>'   
	'<td style="border:none;"><center><span id="WBBOneClickDEP" onmouseover="this.style.cursor=\'pointer\';" >DE-Pend</span></center></td>'   
	'</tr>'  
	
	'<tr>'  
	'<td style="border:none;"><center><span id="WBBOneClickCUPW" onmouseover="this.style.cursor=\'pointer\';" >CU-Pend-W</span></center></td>'  	
	'<td style="border:none;"><center><span id="WBBOneClickCEPW" onmouseover="this.style.cursor=\'pointer\';" >CE-Pend-W</span></center></td>'   
	'<td style="border:none;"><center><span id="WBBOneClickDEPW" onmouseover="this.style.cursor=\'pointer\';" >DE-Pend-W</span></center></td>'   
	'</tr>'  
	
	'<tr>'  
	'<td style="border:none;"><center><span id="WBBOneClickSOL" onmouseover="this.style.cursor=\'pointer\';" >Sol-Pro</span></center></td>'  
	'<td style="border:none;"><center><span id="WBBOneClickCLP" onmouseover="this.style.cursor=\'pointer\';" >Clo-Pend</span></center></td>'  
	'<td style="border:none;"><center><span id="WBBOneClickCLO" onmouseover="this.style.cursor=\'pointer\';" >Closed</span></center></td>'  
	'</tr>'  
	'</table></center></div></pre></span>';

	
	var allSpan = document.evaluate( "//span[@class='contact']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	for (var i = 0; i < allSpan.snapshotLength; i  ) {
			allSpan.snapshotItem(i).innerHTML =OneClickCode;
		}
if (GM_getValue("Show State Changer", false)){
	document.getElementById('StateChanger').style.display="";
	verticalspace -= 90;
	noteverticalspace -= 90;
	}
if (GM_getValue("Show Initial Responses", false)){
	document.getElementById('InitialResponse').style.display="";
	verticalspace -= 60;
	noteverticalspace -= 60;
	if (nullDiv.snapshotLength == 0 && nullDivE.snapshotLength == 0){
		if (prefEmail.snapshotLength==0){
			//call him
			document.getElementById('WBBOneClickOTP').style.display="";
			document.getElementById('WBBOneClickLVM').style.display="";
			}
		if (prefPhone.snapshotLength==0){
			document.getElementById('WBBOneClickSE').style.display="";
			}
		}
	else 		
	document.getElementById('WBBOneClickRIC').style.display="";
	}


//Hidden IFRAME for posting  display:none;visible:hidden;
UpdateBlock = '<div id="hiddenDiv"  style="display:none;visible:hidden;" ><iframe src="about:blank" height="100" width="300" border="0" scrolling="no" name="hiddenFrame" id="hiddenFrame"></iframe></div>';


 
 
//GCI Stuff
	UpdateBlock  = '<span id="WorkbenchBuddy" style="display: " ><div class="header action" style="overflow: auto;overflow-x: hidden;"  class="note Internal">'  
'<input type="hidden" name="srNumber" value="'   SR   '" hidden="true">'  

'<select style="width: 70%;"  name="WBBstatus" id="WBBstatus" class="skinme" >'  

'<option value="NULL CASE STATE" selected="selected">Change State to...</option>'  
'<option value="102">3rd Party Pending</option> '  
'<option value="105">CE Pending</option>'  
'<option value="160">CE Pending - Lab Recreate</option>'  
'<option value="106">CE Pending - No Contact</option>'  
'<option value="107">CE Pending Workaround</option>'  
'<option value="108">Close Pending</option>'  
'<option value="2">Closed</option>'  
'<option value="112">Customer Pending</option>'  
'<option value="113">Customer Pending Workaround</option>'  
'<option value="110">Customer Requested Closure</option>'  
'<option value="115">DE Pending</option>'  
'<option value="116">DE Pending Workaround</option>'  
'<option value="119">Release Pending</option>'  
'<option value="121">Restoration of Service</option>'  
'<option value="123">Service Order Pending</option>'  
'<option value="140">Solution Provided/Monitoring</option>'  
'</select>'  

'<select style="width: 29%;"  name="WBBseverity" id="WBBseverity" class="skinme" >'  
'<option value="NULL">Change Sev.</option>'  
'<option value="1">1</option>'  
'<option value="2">2</option>'  
'<option value="3">3</option>'  
'<option value="4">4</option>'  
'</select><br>'  

'<select  style="width: 99%;"  name="WBBTemplates" id="WBBTemplates" class="skinme" >';

	UpdateBlock  = '<option value="NULL TEMPLATE" selected="selected">Pick a template</option>';
if (templateID.length == 0)
{

	UpdateBlock  = '<option value="NULL" >No Templates Loaded (Refresh?)</option>' ;
}
else for (var f = 0; f < templateID.length; f  )	UpdateBlock  = '<option value="'   templateID[f]   '" >'   templateName[f]   '</option>';
		
 
	

UpdateBlock  = '</select><br>'  

'<select style="width: 70%;" name="WBBnotetype" id="WBBnotetype" class="skinme" >'  

'<option value="NULL NOTE TYPE" selected="selected">Note Type...</option>'  
'<option value="CISCO_INIT_PHONE">Initial Response - Phone</option>'  
'<option value="CISCO_INIT_EMAIL">Initial Response - Email</option>'  
'<option value="CISCO_EMAIL_IN">Email In</option>'  
'<option value="CISCO_PHONE_LOG">Phone Log</option>'  
'<option value="ASF_OTHER">Other</option>'  
'<option value="CISCO_REQUEUE_REASON">Requeue Reason</option>'  
'<option value="CISCO_WORKAROUND">Workaround</option>'  
'<option value="CS_PROBLEM">Problem Description</option>'  
'<option value="CISCO_RES_SUMMARY">Resolution Summary</option>'  
'<option value="CISCO_CASE_REVIEW">Case Review</option>';
if (GM_getValue("Show Notes: KT", false)) UpdateBlock  = '<option value="CISCO_KT_ACTION_PLAN">KT Action Plan</option>'  
'<option value="CISCO_KT_PROB_ANALYSIS">KT Problem Analysis</option>'  
'<option value="CISCO_KT_SIT_APPR">KT Situation Appraisal</option>'  
'<option value="CISCO_KT_THINK_BEYOND_FIX">KT Think Beyond The Fix</option>';
if (GM_getValue("Show Notes: DMM", false)) UpdateBlock  = '<option value="CISCO_MANAGER_REV">Manager Review</option>'   
'<option value="CISCO_DUTY_MNGR">Duty Manager Log</option>';
UpdateBlock  ='</select>'  

'<select style="width: 29%;" name="WBBnotestatus" id="WBBnotestatus" class="skinme" >'  

'<option value="NULL NOTE STATUS" selected="selected">Note Status...</option>'  
'<option value="E">External</option>'  
'<option value="I">Internal</option>'  
'<option value="P">Private</option>'  

'</select><br>'  

'<textarea name="WBBnote" id="WBBnote" class="skinme" wrap="soft" style="width: 99%; height: 100px;" value =""></textarea><br>'  
	'Add Bug: <input name="WBBbug" id="WBBbug" size=10 type="text">   Change Title:<br>' 
	'<input name="WBBtitle" id="WBBtitle" style="width: 99%;" maxlength = "80" type="text" value="'   EscapedCleanTitle   '"><br>' 
	'<input name="WBBtitleOrig" id="WBBtitleOrig" type="hidden" value="'   EscapedCleanTitle   '">' 
	'<input class="skinme" name="WBBuddySubmitButton" id="WBBuddySubmitButton" type="submit" value="Update!" style="width:100px;" hidefocus="true" > '  
	'<input class="skinme" name="WBBuddyResetButton" id="WBBuddyResetButton" type="reset" value="Reset" hidefocus="true" > '  
	'<input id="EmailNoteToOwner" type="checkbox"> Email Owner'  
	' <a id="WBBContact" href="mailto:mamorten@cisco.com?subject=Workbench Buddy version ' WBBScriptVersion '">?</a><br>';
	if ( GM_getValue("Latest Version", 0) > WBBScriptVersion)
	UpdateBlock  = '<div onmouseover="this.style.cursor=\'pointer\';" onClick="window.open(\'http://172.18.254.190/pmwiki/pmwiki.php?n=Scripts.WorkbenchBuddy\',\'_blank\')" style="color:white; background-color: #FF0000;"><center>Workbench Buddy update available. Click Here</center></div>';

	UpdateBlock  = '</div></span>'; 



	allDivs = document.evaluate( "//div[@class='dontmove']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

	for (var i = 0; i < allDivs.snapshotLength; i  ) 
	{
		allDivs.snapshotItem(i).innerHTML =UpdateBlock;
	}
		var WBBuddyResetButton = document.getElementById('WBBuddyResetButton');
WBBuddyResetButton.addEventListener("click", function(event) { resetWBbuddy ( Title[0].innerHTML ); } , true);
		var WBBuddySubmitButton = document.getElementById('WBBuddySubmitButton');
WBBuddySubmitButton.addEventListener("click", submitWBbuddy, true);
		var WBBTemplates = document.getElementById('WBBTemplates');
WBBTemplates.addEventListener("change", templateWBbuddy, true);		

//Init Resp.
		var WBBOneClickLVM = document.getElementById('WBBOneClickLVM');
WBBOneClickLVM.addEventListener("click", function(event) {oneclickWBbuddy('LVM');} , true);
		var WBBOneClickOTP = document.getElementById('WBBOneClickOTP');
WBBOneClickOTP.addEventListener("click", function(event) {oneclickWBbuddy('OTP');} , true);
		var WBBOneClickSE = document.getElementById('WBBOneClickSE');
WBBOneClickSE.addEventListener("click", function(event) {oneclickWBbuddy('SE');} , true);

// State Change
		var WBBOneClickCEP = document.getElementById('WBBOneClickCEP');
WBBOneClickCEP.addEventListener("click", function(event) {oneclickWBbuddy('CEP');} , true);
		var WBBOneClickCEPW = document.getElementById('WBBOneClickCEPW');
WBBOneClickCEPW.addEventListener("click", function(event) {oneclickWBbuddy('CEPW');} , true);

		var WBBOneClickCUP = document.getElementById('WBBOneClickCUP');
WBBOneClickCUP.addEventListener("click", function(event) {oneclickWBbuddy('CUP');} , true);
		var WBBOneClickCUPW = document.getElementById('WBBOneClickCUPW');
WBBOneClickCUPW.addEventListener("click", function(event) {oneclickWBbuddy('CUPW');} , true);

		var WBBOneClickDEP = document.getElementById('WBBOneClickDEP');
WBBOneClickDEP.addEventListener("click", function(event) {oneclickWBbuddy('DEP');} , true);
		var WBBOneClickDEPW = document.getElementById('WBBOneClickDEPW');
WBBOneClickDEPW.addEventListener("click", function(event) {oneclickWBbuddy('DEPW');} , true);


		var WBBOneClickSOL = document.getElementById('WBBOneClickSOL');
WBBOneClickSOL.addEventListener("click", function(event) {oneclickWBbuddy('SOL');} , true);
		var WBBOneClickCLP = document.getElementById('WBBOneClickCLP');
WBBOneClickCLP.addEventListener("click", function(event) {oneclickWBbuddy('CLP');} , true);
		var WBBOneClickCLO = document.getElementById('WBBOneClickCLO');
WBBOneClickCLO.addEventListener("click", function(event) {oneclickWBbuddy('CLO');} , true);

	if (GM_getValue("Enable AS", true))	window.addEventListener("unload", function(event) { autosaveWBbuddy(); } , true);

	var WBBnote = document.getElementById('WBBnote');


   // noteverticalspace = (viewportheight - document.getElementById('WBBnote').offsetTop) - 100;
	//document.getElementById('WBBnote').style.height=noteverticalspace "px";
	resizeWBbuddy();
	window.addEventListener("resize", function(event) {resizeWBbuddy();} , true);
	if (GM_getValue("Enable AS", true)) restoreautosaveWBbuddy();
}

else if (AreWeOnXMLPref) {
/*
Preferences include:
template url
show one click links in WB
show specialist tools
show one click IRs
*/
var Body = document.getElementsByTagName('body');

var PrefChunk;

PrefChunk = '<br>'  
	'<b>Work Bench Buddy Preferences:</b><br>'  
	'<input name="WBBTemplateURL" id="WBBTemplateURL" value="'   GM_getValue("TemplateURL", "http://172.18.254.190/scripts/includes/templates.txt")   '" title="Template URLs" size="40" type="text"> - URL for Templates (Default is: http://172.18.254.190/scripts/includes/templates.txt )<br>'  
	'<input id="ShowStateChanger" type="checkbox" ';
	if (GM_getValue("Show State Changer", false)) PrefChunk ='checked';
	PrefChunk = '> Show One-Click Case State Changer<br>'  
	'<input id="ShowInitialResponse" type="checkbox" ';
	if (GM_getValue("Show Initial Responses", false)) PrefChunk ='checked';
	PrefChunk = '> Show One-Click Initial Responses<br>'  
	'<input id="EnableAS" type="checkbox" ';
	if (GM_getValue("Enable AS", true)) PrefChunk ='checked';
	PrefChunk = '> Enable Auto-Save Functionality<br>'  
	'<input id="ShowShortcutsOnWB" type="checkbox" ';
	if (GM_getValue("Show Shortcuts on CSE Workbench", true)) PrefChunk ='checked';
	PrefChunk = '> Show Shortcuts on CSE Workbench<br>'  

	'Select note types to show:<br>'  
	'<input id="ShowNotesKT" type="checkbox" ';
	if (GM_getValue("Show Notes: KT", false)) PrefChunk ='checked';
	PrefChunk = '> KT Notes<br>'  
	'<input id="ShowNotesDMM" type="checkbox" ';
	if (GM_getValue("Show Notes: DMM", false)) PrefChunk ='checked';
	PrefChunk = '>  DM/Manager Notes<br>'  
	'<input name="saveWBB" id="saveWBB" type="submit" style="width: 250px;" value="Save Workbench Buddy Preferences" hidefocus="true" > ';
	
	 Body[0].innerHTML =PrefChunk;
	var setPref = document.getElementById('saveWBB');
	setPref.addEventListener("click", saveWBbuddy, true);
}

else if (AreWeOnWBUpdate || AreWeOnWBClose)
{

// Detect if the update is posted.
// If post is done for this case, say so....

//Check to see if a post change is needed First see if a post is pending, if it is, check to see is is for the page we just loaded

//Pick out SR #
	var Title;
	var SR;
	Title = document.getElementsByTagName('title');
		
	if (Title[0].innerHTML.search ( "[0-9]{9}" ) != -1 )
	{
		SR = Title[0].innerHTML.substring(Title[0].innerHTML.search ( "[0-9]{9}" ) , Title[0].innerHTML.search ( "[0-9]{9}" )  9 );
	}
	else alert("I could not find the SR number of this case!");

	if ( SR == GM_getValue ("WB Post Pending", "NULL") ) //We have a post pending for this SR
	{
		// Look for "back" and "Close" buttons
		
		var CloseButtons;
		CloseButtons = document.evaluate("//input[@value='Close']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
		var BackButtons;
		BackButtons = document.evaluate("//input[@value='Back']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
		var ErrorBlock;
		ErrorBlock = document.evaluate("//p[@class='error']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
		
		if (BackButtons.snapshotLength == 1 && CloseButtons.snapshotLength == 1)
		{
			GM_setValue ("WB Post Pending", SR   "posted")
		}
		if (ErrorBlock.snapshotLength == 1)
		{
		//	var thisError = ErrorBlock.snapshotItem(0);
		alert ("Update Failed:"   ErrorBlock.snapshotItem(0).innerHTML);
				GM_setValue ("WB Post Pending", SR   "failed");
		}		
	}

}

it also contains this as html file:

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<link rel=File-List href="./index_files/filelist.xml">
<title>Script</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author></o:Author>
  <o:LastAuthor></o:LastAuthor>
  <o:Revision>1</o:Revision>
  <o:TotalTime>0</o:TotalTime>
  <o:Created>2009-04-14T00:32:00Z</o:Created>
  <o:LastSaved>2009-04-14T00:32:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Company></o:Company>
  <o:Lines>1</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:Version>9.8961</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<style>
<!--
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;
	text-underline:single;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
</head>

<body lang=EN-US link=blue vlink=purple style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal><a href="workbench_buddy.user.js">Script</a></p>

</div>

</body>

</html>

Post Reply