Personal tools
Navigation
 

Building Blocks from Stanley Hurwitz March 2015

From Stanley Hurwitz - "a txt file with some GM code snippets that I use as building blocks in my scripts."

Plain Text icon GreaseMonkey Scripts CheatSheet.txt — Plain Text, 4 kB (4301 bytes)

File contents

//============Format==================
// ==UserScript==
// @name        Invoice Screen

// @namespace   Stanscripts


// @description Create multiline statements
// @include     *billing/CA/BC/billStatus.jsp?lastName=*
 // @include             *billing/CA/BC/billStatus.jsp*
// @require   http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js
// @grant       none

// ==/UserScript==
//****************************************************



//========Buttons============
var input1=document.createElement("input");
input1.type="button";
input1.value="BUTTON NAME";
input1.onclick = ButtonFunction1;
input1.setAttribute("style", "font-size:12px;position:fixed;top:15px;right:520px;");
document.body.appendChild(input1); 
function ButtonFunction1(){
alert("Hello World!")
}
//*************************************************************


//=========Option List Default============
var theDefault='Hurwitz, Stanley D';
var theOptions = document.getElementsByName('xml_provider')[0].options;

for each (var theOption in theOptions)
{for (var i=0; i<3; i++) {}
	if(typeof(theOption)=='object'){
//alert(theOption.text)
		if(theOption.text==theDefault){
			theOption.selected=true;
			break;
		}
	}
}
//*****************************************************************


//========Get Path============
var elements = (window.location.pathname.split('/', 2))
firstElement = (elements.slice(1) )
//alert(firstElement)
vPath = ("https://" + location.host + "/"  + firstElement + "/")
//alert(vPath)
//*****************************************************************


//=====Get Parameters============
var params = {};
if (location.search) {
    var parts = location.search.substring(1).split('&');
    for (var i = 0; i < parts.length; i++) {
        var nv = parts[i].split('=');
        if (!nv[0]) continue;
        params[nv[0]] = nv[1] || true;
    }
}
//alert(params.segmentID)

//=======Key Shortcuts============
window.addEventListener('keypress', function(theEvent) {
	//theEvent.stopPropagation();
	//theEvent.preventDefault();
	var theKeyCode = theEvent.charCode;// || event.which;
	var theKey = String.fromCharCode(theKeyCode);
	var theAltKey =theEvent.altKey;
	var theCtrlKey = theEvent.ctrlKey;
	var theShiftKey= theEvent.shiftKey;
	//var theDownKey= theEvent.PgDnKey;

	switch(true){
		case theAltKey && theKey=='e': //save, sign and bill
			//var theTarget = document.evaluate("id('save')/span/input[contains(@src,'dollar-sign-icon.png')]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;
			//theTarget.click();
 		                $('#save > span:nth-child(1) > input:nth-child(5)').click()
			break;

        		case theAltKey && theKey=='v': //sign & exit
       			 $('#signSaveImg').click()
			break;

		case theAltKey && theKey=='z'://open BP Pulse Weight Height measurements
			window.open(vPath  + '/oscarEncounter/oscarMeasurements/SetupMeasurements.do?groupName=Vitals','VitalsWindow','width=1000,height=500')
			break;
        
		/*
		case theAltKey && theCtrlKey && theShiftKey && theKey=='':
			//TO DO: The action to be performed for the above keyboard shortcut
			break;
		*/
	}
}, true);
//**********************************************************************


//===========Cookies===============
function setCookie(cname,cvalue,exdays,cpath)
{
var d = new Date();
 //d.setTime(d.getTime()+(exdays*24*60*60*1000));
 d.setTime(d.getTime()+(exdays*5000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires +  "; " + cpath
 }
//setCookie("homephone",qqhomephone,360,"path=/");

function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) 
  {
  var c = ca[i].trim();
  if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
//*****************************************************************


//====Lookup and change  input values==================
//by name:
$("input[name='value(FieldName)']").val();
//by Id or Unique Selector
$('#txt_name').val();

//***********************************



Document Actions

 

Download button

DOWNLOAD OSCAR FOR TESTING

 

eForms button

DOWNLOAD SHARED E-FORMS


 Customize button

FIND PLUG-INS AND TWEAKS
FOR YOUR OSCAR EMR

 

Subscribe Button

SUBSCRIBE TO DISCUSSION LIST 
(SEE ALL LISTS)

  

Help button

ACCESS THE ONLINE MANUALS
(PAID SUPPORT)