Skip to content

Instantly share code, notes, and snippets.

View JamesMGreene's full-sized avatar

James M. Greene JamesMGreene

View GitHub Profile
@JamesMGreene
JamesMGreene / interface-for-reporters.js
Last active August 29, 2015 13:57
QUnit's WIP proposal for a standardized reporter interface and data structure among JS testing frameworks. The goal is to be able to reuse existing/new reporters in any of the major JS test frameworks.
var reporterInterface = {
"start": function(data) {
/*
data: {
}
*/
},
@JamesMGreene
JamesMGreene / clipboard.md
Last active August 29, 2015 13:56
HTML5 Clipboard API enhancements
@JamesMGreene
JamesMGreene / window.onerror.md
Last active March 31, 2017 15:07
HTML5 `window.onerror` enhancement: getting a reference to the actual `Error` object! Also, test suites for `onerror` and `ErrorEvent`.

Original Proposal

https://gist.github.com/JamesMGreene/3ded0f6e7f0a658b9394

Final Outcome

window.onerror = function(msg, url, lineno, colno, error) {
  // `window.onerror` handlers now have a 5th argument: the `Error` object itself (or `null`).
  // This can then be used to get stack info, error type/name, etc.
};
@JamesMGreene
JamesMGreene / ZeroClipboard "Core" v2 API.md
Last active June 3, 2020 16:17
ZeroClipboard "Core" v2.0.0 API

ZeroClipboard v2.0.0 "Core" API Draft

Working draft of the API for the new ZeroClipboard "Core" sub-module in v2.0.0. This sub-module only provides the core Flash and clipboard injection facilities but none of the DOM, "Client", resizing, repositioning, etc. logic/code.

NOTE: A checked checkbox means that line item has already been implemented in the latest ZeroClipboard master branch.

API

@JamesMGreene
JamesMGreene / qunit.pending.js
Last active January 4, 2016 11:49 — forked from Potherca/qunit.testSkip.js
Duck-punch the `QUnit.test` method to support Mocha-style "pending" tests. UPDATE: As of QUnit v1.16.0, `QUnit.skip` will be a core part of the framework.
/*global QUnit, window, global */
(function (QUnit, global) {
'use strict';
var document = global && global.document;
var pendingTestIds = [];
var QUnit_test = QUnit.test;
QUnit.test = function(testName, expected, callback, async) {
var btn = document.getElementById("copy-button");
btn.addEventListener("click", clickHandler, false);
function clickHandler(e) {
var clip = new ClipboardEvent("copy");
clip.clipboardData.setData("text/plain", "foo");
clip.clipboardData.setData("text/html", "<b>foo</b>");
// CRITICAL: Must call `preventDefault();` to get this data into the system/desktop clipboard!!!
clip.preventDefault();
@JamesMGreene
JamesMGreene / clipboard.js
Last active November 5, 2019 07:47
HTML Clipboard API clarification example
var btn = document.getElementById("copy-button");
btn.addEventListener("click", clickHandler, false);
btn.addEventListener("copy", copyHandler, false);
function clickHandler(e) {
e.target.dispatchEvent(new ClipboardEvent("copy"));
}
function copyHandler(e) {
e.clipboardData.setData("text/plain", "Simulated copy. Yay!");
@JamesMGreene
JamesMGreene / findText.js
Created January 13, 2014 14:49
Showing Phantom supporting searching for text using the normal browser DOM APIs.
var page = require("webpage").create();
page.onConsoleMessage = function(msg) {
console.log('[PAGE] Message: ' + msg);
};
page.open("http://google.com/", function(status) {
if (status !== "success") {
console.error("Failed to load the page. Usually this means some resource failed to load.");
phantom.exit(1);
@JamesMGreene
JamesMGreene / ZeroClipboard v2 API.md
Last active December 30, 2015 21:19
ZeroClipboard v2.0.0 API Draft

ZeroClipboard v2.0.0 API Draft

Working draft of the new API for ZeroClipboard v2.0.0.

NOTE: A checked checkbox means that line item has already been implemented in the latest ZeroClipboard master branch.

API

@JamesMGreene
JamesMGreene / SubGruntfileExplanation.md
Created October 29, 2013 19:24
Sub-Gruntfile explanation

Picture a [non-modular] folder structure like this:

root/
 - Gruntfile.js
 - node_modules/
 - Platform/
    - Gruntfile.js
    - ...
 - Products/