Skip to content

Instantly share code, notes, and snippets.

Avatar

Olly Hodgson OllyHodgson

View GitHub Profile
@OllyHodgson
OllyHodgson / Icon.js
Created Jul 31, 2020
React component to use the Bootstrap 5 Icons in sprite form
View Icon.js
import React from "react";
import classnames from "classnames";
import Icons from "bootstrap-icons/bootstrap-icons.svg";
const Icon = ({
className,
iconName,
height = "1rem",
width = "1rem",
label,
@OllyHodgson
OllyHodgson / _LoadFromLiquidContentAPI.cshtml
Last active Nov 27, 2018
Load data from the DNN Evoq Liquid Content API using the DNN Razor Host module. Razor gives you a bit more control and flexibility than the built-in visualizers.
View _LoadFromLiquidContentAPI.cshtml
@using System
@using System.Net
@using System.Text
@using Newtonsoft.Json
@using Newtonsoft.Json.Linq
@{
// The API URL and your API Key
string url = "https://dnnapi.com/content/api/ContentItems?contentTypeId=7f0d48be-a6bf-4f3c-9fdf-ba895727e818";
string apikey = "**** INSERT YOUR API KEY HERE ****";
@OllyHodgson
OllyHodgson / jquery.offscreen.js
Created Nov 22, 2018
Simple jquery plugin to transition elements onto the page using CSS animations
View jquery.offscreen.js
// Custom selector to find if something is in the viewport
// Adapted from https://stackoverflow.com/a/8897628/13019
jQuery.expr.pseudos.offscreen = function (el) {
var rect = el.getBoundingClientRect();
return (
(rect.x + rect.width) < 0 || (rect.y + rect.height) < 0 || (rect.x > window.innerWidth || rect.y > window.innerHeight)
);
};
@OllyHodgson
OllyHodgson / index.html
Created Mar 20, 2018
CSS flexbox layout experiment - boxes breaking out of boxes. It later occurred to me that CSS Grid might have been the better tool. Hey ho.
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
<style>
html,
body {
@OllyHodgson
OllyHodgson / SP2010 ASP:Repeater-based navigation with current item selection.aspx
Last active Mar 8, 2019
SharePoint 2010 top level navigation code. Built with a nested ASP:Repeater control. Easier to style with Bootstrap or Flexbox than the ASP:Menu control. Includes highlighting of the current section.
View SP2010 ASP:Repeater-based navigation with current item selection.aspx
<!-- top navigation publishing data source -->
<PublishingNavigation:PortalSiteMapDataSource
id="topSiteMap"
runat="server"
EnableViewState="false"
SiteMapProvider="GlobalNavigation"
StartFromCurrentNode="false"
StartingNodeOffset="0"
ShowStartingNode="true"
TrimNonCurrentTypes="Heading"/>
@OllyHodgson
OllyHodgson / Strip out some spurious HTML.js
Last active Mar 14, 2016
Run this in the devtools console on a SharePoint 2010 page when in edit mode, to strip out some spurious crap from the HTML.
View Strip out some spurious HTML.js
/*
Run this in the devtools console on a SharePoint 2010 page when in edit mode, to strip out some spurious crap from the HTML.
*/
(function($, window, document) {
var $editables = $("[contenteditable], input[type='hidden'][id*='hiddenStorage'], input[type='hidden'][id*='hiddenDisplay'], input[type='hidden'][id^='ctl00'][id$='content']", ".edit-mode"),
originalHTML,
filterHTML,
$el,
$filterHTML,
@OllyHodgson
OllyHodgson / Strip out spurious HTML.js
Last active Mar 14, 2016
Run this in the devtools console on a SharePoint 2010 page when in edit mode, to strip out quite a lot of spurious crap from the HTML.
View Strip out spurious HTML.js
/*
Run this in the devtools console on a SharePoint 2010 page when in edit mode, to strip out quite a lot of spurious crap from the HTML.
*/
(function($, window, document) {
var $editables = $("[contenteditable], input[type='hidden'][id*='hiddenStorage'], input[type='hidden'][id*='hiddenDisplay'], input[type='hidden'][id^='ctl00'][id$='content']"),
originalHTML,
filterHTML,
$el,
$filterHTML,
@OllyHodgson
OllyHodgson / countCSSRules.js
Created Apr 9, 2015 — forked from krisbulman/countCSSRules.js
Run this in the dev tools console to ensure none of your stylesheets have too many rules / selectors for legacy IE (IE9 and below).
View countCSSRules.js
function countCSSRules() {
var results = '',
log = '',
slen = document.styleSheets.length;
if (!document.styleSheets) {
return;
}
for (var i = 0; i < slen; i++) {
countSheet(document.styleSheets[i]);
}
@OllyHodgson
OllyHodgson / devtools.responsiveUI.presets
Last active Aug 29, 2015
Presets for the Firefox devtools Responsive Design View. Includes presets for default Bootstrap 3 grid sizes and some iPhones. To use, navigate to about:config and then add or edit the devtools.responsiveUI.presets key.
View devtools.responsiveUI.presets
[{"key":"300x400","name":"Very small screen","width":300,"height":400},{"key":"320x480","name":"iPhone 4","width":320,"height":480},{"key":"320x568","name":"iPhone 5","width":320,"height":568},{"key":"360x640","name":"Nexus 4","width":360,"height":640},{"key":"375x667","name":"iPhone 6","width":375,"height":667},{"key":"414x736","name":"iPhone 6 Plus","width":414,"height":736},{"key":"767x1024","name":"@screen-xs-max","width":767,"height":1024},{"key":"768x1024","name":"@screen-sm-min","width":768,"height":1024},{"key":"991x1280","name":"@screen-sm-max","width":991,"height":1280},{"key":"992x1280","name":"@screen-md-min","width":992,"height":1280},{"key":"1199x801","name":"@screen-md-max","width":1199,"height":801},{"key":"1200x801","name":"@screen-lg-min","width":1200,"height":801},{"key":"1280x600","name":"Netbook","width":1280,"height":600}]
@OllyHodgson
OllyHodgson / jQuery.stripZWSP-1.0.js
Last active Nov 2, 2016
The Sharepoint Rich HTML editor leaves ZERO WIDTH SPACE chracters (&#8203; or \u200B) all over the place. This trawls through the HTML you pass in and strips out zero width space characters from text nodes within. Potentially a sledgehammer/nut solution...
View jQuery.stripZWSP-1.0.js
/*
* The Sharepoint Rich HTML editor leaves ZERO WIDTH SPACE chracters (&#8203;
* or \u200B) all over the place. This trawls through the HTML you pass in and
* strips out zero width space characters from text nodes within.
*
* http://blog.bugrapostaci.com/2014/02/02/publishing-field-encoding-extra-questionmark-charecters-actually-acsii-8203-zero-width-space/
*
* This trawls through the HTML you pass in and strips out zero width space
* characters from text nodes within.
*
You can’t perform that action at this time.