Skip to content

Instantly share code, notes, and snippets.

SPFX Folder Structure

src
└── spfx
    └── spfx-solution-01
    └── spfx-solution-02
@precyx
precyx / include.html
Created January 14, 2020 08:15
# Inject Javascript component into Classic Script Editor
<div id="documentTreeInjection"></div>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script>
// change path to app url
$.getScript("/sites/00053/Privat/DokumentBaum/DocumentTree/components/DocumentTree.js").then(function () {
injectDocumentTreeComponent(
"documentTreeInjection", {
@precyx
precyx / render_documentree.js
Created January 14, 2020 08:13
# Render Components in Script Editor
/**
* UI
*/
function renderDocumentTree(treeData) {
var html = "";
html += "<div class='document-tree'>";
html += renderItems(treeData.children);
html += "</div>";
@precyx
precyx / list_to_tree.js
Created January 14, 2020 08:11
# Tree structure data handling
/**
* Converts a list to tree structure
* @param {Array} list - list of items with [id], [parentId], [children]
*/
function list_to_tree(list) {
var map = {}, node, roots = [], i;
for (i = 0; i < list.length; i += 1) {
map[list[i].id] = i; // initialize the map
list[i].children = []; // initialize the children
}
@precyx
precyx / generic_http.js
Created January 14, 2020 08:05
# Sharepoint API examples
function _httpGet(url) {
return $.ajax({
type: "GET",
url: url,
crossDomain: true,
contentType: "application/json;odata=verbose",
dataType: "json",
success: function (data) {
return data;
},
/* sort by folder and name */
_merged.sort(function (a, b) {
if (a.type == "Folder" && b.type != "Folder") return -1;
if (a.type != "Folder" && b.type == "Folder") return 1;
return a.name.localeCompare(b.name);
return 0;
});
@precyx
precyx / standard.md
Created January 9, 2020 10:32
# Ecmascript Standard
@precyx
precyx / links.md
Last active January 9, 2020 07:36
# Sharepoint Links
@precyx
precyx / linkinnewtab.html
Created January 7, 2020 13:30
# Sharepoint Online: Open Link in new Tab
<!-- data-interception="off" -->
<Link href={someLinkUrl} target="_blank" data-interception="off">Link</Link>
@precyx
precyx / Validation.tsx
Last active January 3, 2020 11:38
# Basic Validation of fields in React files - form.tsx - Validation.tsx
interface IField {
type: string;
message: string;
}
/**
* Fields - with validation type and message
*/
export const Fields: { [key: string]: IField } = {