Skip to content

Instantly share code, notes, and snippets.

@sandrinodimattia
Created July 23, 2012 06:46
Show Gist options
  • Save sandrinodimattia/3162314 to your computer and use it in GitHub Desktop.
Save sandrinodimattia/3162314 to your computer and use it in GitHub Desktop.
Dynamics CRM 2011 eID Javascript
<html>
<head>
<title>eID: Read</title>
<script type="text/javascript" src="https://localhost:100/be_belgium_eid.js"></script>
<script language="javascript" type="text/javascript">
// Initialize the reader.
var cardReader = new be.belgium.eid.CardReader();
// Bind error events.
function noCardPresentHandler() { window.alert("No card present!"); }
cardReader.setNoCardPresentHandler(noCardPresentHandler);
function noReaderDetectedHandler() { window.alert("No reader detected!"); }
cardReader.setNoReaderDetectedHandler(noReaderDetectedHandler);
function appletNotFoundHandler() { window.alert("Applet not found!"); }
cardReader.setAppletNotFoundHandler(appletNotFoundHandler);
function appletExceptionHandler(e) { window.alert("Error reading card!\r\nException: " + e + "\r\nPlease try again."); }
cardReader.setAppletExceptionHandler(appletExceptionHandler);
// Read the card.
function readCard() {
document.getElementById("content").value = "Please wait ...";
window.card = cardReader.read();
if (window.card != null) {
document.getElementById("content").value = window.card.toString();
} else {
document.getElementById("content").value = "No card returned.";
}
}
// Save the card to contact.
function saveCard() {
var data = { firstName: card.getFirstName1().toString(),
lastName: card.getSurname().toString(),
street: card.getStreet().toString(),
streetNumber: card.getStreetNumber().toString(),
zipCode: card.getZipCode().toString(),
country: card.getCountry().toString(),
municipality: card.getMunicipality().toString()
};
self.opener.onUpdateContact(data);
self.close();
}
</script>
</head>
<body style='background-color: rgb(233, 237, 241)'>
<table>
<tr>
<td valign='top'>
<applet code="org.jdesktop.applet.util.JNLPAppletLauncher" codebase="https://localhost:100"
width="140" height="200" name="BEIDAppletLauncher" id="BEIDAppletLauncher" archive="applet-launcher.jar,beid35libJava.jar,BEID_Applet.jar">
<param name="codebase_lookup" value="false">
<param name="subapplet.classname" value="be.belgium.beid.BEID_Applet">
<param name="progressbar" value="true">
<param name="jnlpNumExtensions" value="1">
<param name="jnlpExtension1" value= "https://localhost:100/beid.jnlp">
<param name="debug" value="false"/>
<param name="Reader" value=""/>
<param name="OCSP" value="-1"/>
<param name="CRL" value="-1"/>
<param name="jnlp_href" value="https://localhost:100/beid_java_plugin.jnlp" />
</applet>
</td>
<td valign='top'>
<textarea id='content' wrap='virtual' cols='80' rows='20'> </textarea>
<br>
<input title="Read Card" onclick=javascript:readCard() value="Read Card" type=button>
<input title="Save" onclick=javascript:saveCard() value="Save" type=button>
</td>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment