Skip to content

Instantly share code, notes, and snippets.

View frumbert's full-sized avatar

TIm St.Clair frumbert

  • Repton, Australia
View GitHub Profile
@frumbert
frumbert / survey.html
Created March 19, 2024 03:01
A text parser that turns fairly regular plain text into a series of form elements for use in a survey. There is no concept of numbered questions, only responses. Questions can be grouped by adding a 'page:' identifier, which results in subsequent questions being part of a new fieldset, and are only a visual change (does not appear in results). S…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Survey</title>
<style>
div{margin-block-start: 1rem;}
@frumbert
frumbert / get_activity_url.php
Created August 9, 2017 08:49
Moodle "next" and "previous" activity code
<?php
// you would probably use this within your theme or block - anywhere inside a course context.
// a moodle function for returning the url adjacent to the current page in a course
// tested in Moodle 3 and higher.
// sourced from within https://moodle.org/plugins/block_navbuttons then refactored a bit to my needs
// lets say you are on http://mymoodle.com/mod/page/view.php?id=302
// and you want to know what the activity immediately after this one is. You'd ask
@frumbert
frumbert / tab-title-marquee.html
Created October 27, 2017 00:05
Make a marquee on the browser title
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>argh!</title>
<script type="text/javascript">
message = "The quick brown 🦊 jumps over the lazy 🐶 ";
function step() {
message = message.substr(1) + message.substr(0,1);
document.title = message.substr(0,15);
@frumbert
frumbert / index.html
Created November 14, 2022 22:35
Randomise all-except-last dom input elements with labels
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>sort dom nodes</title>
</head>
<body>
<p>Some typical markup. Input + Label, then a break. Super responsive, super accessible. We want to present them in random order but can't change the source because it is being injected by a black-box process as a template. Vanilla javascript can help us.</p>
@frumbert
frumbert / function.js
Created August 9, 2017 09:18
blob to dataurl, because I keep forgetting how to do it!
function blobToDataURL(blob) {
return new Promise((fulfill, reject) => {
let reader = new FileReader();
reader.onerror = reject;
reader.onload = (e) => fulfill(reader.result);
reader.readAsDataURL(blob);
})
}
@frumbert
frumbert / columns2.mustache
Last active March 15, 2022 03:35
Sample theme template renderer for filter_units (https://github.com/frumbert/filter_units)
{{>theme_mytheme/inc_start}}
<div id="page" class="container-fluid">
{{{ output.full_header }}}
<div id="page-content" class="row">
<div id="region-main-box" class="col-12">
{{#hasregionmainsettingsmenu}}
<div id="region-main-settings-menu" class="d-print-none">
<div> {{{ output.region_main_settings_menu }}} </div>
@frumbert
frumbert / block.php
Last active September 11, 2020 12:58
Block code for hacking scorm and completion data in Moodle (incomplete file, just the important function bits)
<?php
// there's more to this file than this:
public function get_content()
{
global $CFG, $DB, $USER;
if (!is_siteadmin()) {
return null;
}
@frumbert
frumbert / index.html
Created May 4, 2020 04:28
xAPI Example - Send simple Statement to LRS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Send xAPI statement</title>
<script type="text/javascript" src="xAPIWrapper-master/lib/cryptojs_v3.1.2.js"></script>
<script type="text/javascript" src="xAPIWrapper-master/lib/utf8-text-encoding.js"></script>
<script type="text/javascript" src="xAPIWrapper-master/src/activitytypes.js"></script>
<script type="text/javascript" src="xAPIWrapper-master/src/verbs.js"></script>
@frumbert
frumbert / index.php
Created April 13, 2020 04:01
Sort and Link to markdown files in nested sub-folders in PHP (e.g. build documentation)
<?php
/*
You have markdown files in nested folders which comtain
--01.getting-started
| |
| +--02.finalisation
| | |
| | docs.md
| | picture.png
@frumbert
frumbert / jQuery.fillRemainingHeight()
Created September 22, 2014 11:32
For when you want an object in a container to fill the remaining height in a container object. Such as when you have a toolbar and want the content adjacent to it to fill the remaining height of the container div.
// e.g. $("#my-child-div").fillRemainingHeight();
(function( $ ){
$.fn.fillRemainingHeight = function( ) {
return this.each(function () {
var $this = $(this),
_h = $this.parent().height(),
_used = 0;
$this.siblings().each(function(){ _used+= $(this).outerHeight(); });
$this.css("height", _h - _used);
});