Skip to content

Instantly share code, notes, and snippets.

View christoohey's full-sized avatar

Chris Toohey christoohey

View GitHub Profile
@christoohey
christoohey / messageHandler.jss
Last active August 13, 2020 18:17
XPages Snackbar messageHandler SSJS
var messageHandler = {
severityInfo : javax.faces.application.FacesMessage.SEVERITY_INFO,
severityWarning : javax.faces.application.FacesMessage.SEVERITY_WARN,
severityError : javax.faces.application.FacesMessage.SEVERITY_ERROR,
severityFatal : javax.faces.application.FacesMessage.SEVERITY_FATAL,
addMessage : function(summary, detail, severity, control, setInvalid) {
try {
var _clientId = null;
if(control && control != null) {
_clientId = control.getClientId(facesContext);
@christoohey
christoohey / xpages_addMessage.jss
Last active August 11, 2020 05:25
XPages facesContext.addMessage() Example
var _boundControlOrNull = getComponent("title");
var _summary = "Error - Missing Title";
var _detail = "Looks like you didn't fill out the Title properly on the form...";
var _messageObject = new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_WARN, _summary, _detail );
facesContext.addMessage(_boundControlOrNull, _messageObject);
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>dominoGuru.com Web Storage Demo</title>
<meta name="description" content="Simple Demo of localStorage and sessionStorage Browser Web Storage">
<meta name="author" content="Chris Toohey">
@christoohey
christoohey / deleteThis_example2.xsp
Last active October 22, 2018 15:55
deleteThis() Example 2
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xp:this.resources>
<xp:script
src="/application.jss"
clientSide="false">
</xp:script>
@christoohey
christoohey / validation_submission_javascript_pseudocode_3.js
Created May 23, 2018 15:00
Pseudocode - validation/submission JavaScript 3
<button onclick="
if(validateForm(thisFormObject,"a")) {
submitForm(arguments);
}
">Submit Changes to Form A</button>
@christoohey
christoohey / argumentsAlert,js
Created May 23, 2018 14:45
argumentsAlert() Interactive Demo Function
function argumentsAlert() {
alert(arguments.length + " Arguments");
for(i=0; i < arguments.length; i++) {
alert("Argument " + i + ": " + arguments[i]);
}
}
@christoohey
christoohey / validation_submission_javascript_pseudocode_2.js
Created May 23, 2018 14:02
Pseudocode - validation/submission JavaScript 2
function validateForm(thisForm,key) {
var returnBoolean = false;
switch(key) {
case "a" :
//check values for Form A
returnBoolean = true; //if conditions met
break
case "b" :
//check values for Form B
returnBoolean = true; //if conditions met
@christoohey
christoohey / validation_submission_javascript_pseudocode_1.js
Last active May 23, 2018 14:01
Pseudocode - validation/submission JavaScript 1
function validateForm() {
//check some field values to confirm you have what you need to successfully submit
return Boolean; // based on pass/fail
}
function submitForm() {
//Create or Update the UI submission
}
<button onclick="
@christoohey
christoohey / simpledateformat_ssjs_complete.js
Created May 21, 2018 15:50
SimpleDateFormat SSJS Complete
var timeFormat = new java.text.SimpleDateFormat("hh:mm aa");
var dateFormat = new java.text.SimpleDateFormat("MM/dd/yyyy");
var datetimeFormat = new java.text.SimpleDateFormat("MM/dd/yyyy hh:mm aa");
function getFirstOfYear() {
var dt:java.util.Date = @Now();
dt.setMonth(0);
dt.setDate(0);
return dateFormat.format(dt);
}
@christoohey
christoohey / simpledateformat_ssjs_getfirstofyear_hack2.js
Created May 21, 2018 15:24
SimpleDateFormat SSJS getFirstOfYear() Hack 2 Function
function getFirstOfYear() {
return "01/01/" + @RightBack(@Left(@Now(), " "), "/")
}