Skip to content

Instantly share code, notes, and snippets.

View anvilation's full-sized avatar
🤖
Workie workie

Matthew Barben anvilation

🤖
Workie workie
View GitHub Profile
@anvilation
anvilation / Form.html
Last active August 30, 2021 12:22
Sample HTML from Form Template Object - Generated by Content Server
<!DOCTYPE html>
<HTML LANG="en-US">
<HEAD>
<META http-equiv="content-type" content="text/html; charset=UTF-8">
<script>var csThemeSupportPath = "/img/style/images/";</script>
<LINK REL="stylesheet" TYPE="text/css" HREF="/img/style/screen.css?v=1404.0" id="primaryCSS">
@anvilation
anvilation / SmartViewForm.html
Last active August 30, 2021 12:21
Form Updated to use the Smart CSS.html
<!DOCTYPE html>
<HTML LANG="en-US">
<HEAD>
<meta charset="utf-8">
<!-- What I am adding to make it more Smart View -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/img/csui/themes/carbonfiber/init.css">
<link rel="stylesheet" href="/img/csui/themes/carbonfiber/theme.css">
@anvilation
anvilation / parseFuncValues.js
Last active August 30, 2021 12:21
Parse LL_FUNC_VALUES values
function parseFuncValues() {
// LL_FUNC_VALUES
let values = document.getElementById('WorkflowValues').getAttribute('value');
let funcValues = {};
values = values.replace('A<1,?,', '');
values = values.substring(0, values.length - 1);
values = values.split(',')
values = values.map((value) => {
value = value.split('=');
funcValues[value[0].replace(/\'/g, '')] = value[1].replace(/\'/g, '')
@anvilation
anvilation / httpRequest.js
Last active August 30, 2021 12:21
You might not need WebReports: Workflow Attachments: Basic CS HTTP Request handler
// HTTP Requests
function httpRequest(method, url, ticket, body, options) {
return new Promise((ok, fail) => {
if (options === 'undefined' || options === null) {
options = {
fileupload: false
}
}
let request = new XMLHttpRequest();
request.open(method, url);
@anvilation
anvilation / workflow.js
Last active August 30, 2021 12:21
You might not need WebReports: Workflow Attachments: Workflow Page Load Function
function ready(fn) {
if (document.readyState != 'loading') {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
ready(() => {
const workflowSettings = parseFuncValues();
@anvilation
anvilation / fileupload.js
Last active August 30, 2021 12:21
You might not need WebReports: Workflow Attachments: Content Server File Upload
// File Upload Functions
function uploadFileClick() {
const fileControl = document.getElementById('attachDocument').click();
}
async function processAttachments(files, attachmentid, otcsticket) {
// Async Function to wrap the asynchronous actions
try {
@anvilation
anvilation / displayAttachments.js
Last active August 30, 2021 12:21
You might not need WebReports: Workflow Attachments: Display Attachments
async function displayAttachments(attachmentid, otcsticket) {
const url = `/otcs/cs.exe/api/v2/nodes/${attachmentid}/nodes?fields=properties{id,name, mime_type}`;
const noAttachments = document.getElementById('noAttachments');
const displayAttachments = document.getElementById('displayAttachments');
const loading = document.getElementById('loadingAttachments');
// Set Initiatial State
loading.style.display = '';
noAttachments.style.display = 'none';
displayAttachments.style.display = 'none';
@anvilation
anvilation / submit.js
Last active August 30, 2021 12:21
You might not need WebReports: Workflow Attachments: Validate and Submit Form
// Interactive Validation
function validateField(event) {
const value = event.target.value;
const errorValue = `${event.target.getAttribute('id')}Validate`;
const errorMessage = document.getElementById(errorValue);
if (!value) {
// Trigger Error (this would be easier with something like Angular)
errorMessage.style.display = '';
} else {
errorMessage.style.display = 'none';
@anvilation
anvilation / MsalConfig.ts
Created March 28, 2021 23:22
SharePoint on MS Graph: MsalConfig Interface
export interface MsalConfig {
auth: {
clientId: string;
authority: string;
clientSecret: string;
graphendpoint: string;
}
}
@anvilation
anvilation / dlAuthenticationProvider.ts
Last active March 29, 2021 03:52
SharePoint on MS Graph: Authentication Provider
export class DLAuthenticationProvider implements AuthenticationProvider {
config: MsalConfig = {
auth: {
clientId: '',
authority: '',
clientSecret: '',
graphendpoint: '',
}
};
tokenrequest: any;