Skip to content

Instantly share code, notes, and snippets.

View JamesMGreene's full-sized avatar

James M. Greene JamesMGreene

View GitHub Profile
@JamesMGreene
JamesMGreene / jshint-docs-clarifier.js
Last active December 23, 2015 05:18
A jQuery-based bookmarklet to clarify the JSHint Options documentation. Only works in IE9+.
(function($) {
var nonBooleanOptions = ['indent', 'maxparams', 'maxdepth', 'maxstatements', 'maxcomplexity', 'maxlen'];
function clarifyDocs() {
var $ = window.jQuery;
var selectorExceptions = $.map(nonBooleanOptions, function(e) {
return ':not(:contains("' + e + '"))';
}).join('');
var selector = '.content > table tr:has(> td.name' + selectorExceptions+ ') > td.desc > p:first-child';
$(selector).each(function() {
@JamesMGreene
JamesMGreene / copy.md
Last active December 25, 2015 07:49
Design discussion about the JSON responses from ZeroClipboard's "complete" event

CURRENT:

{
  "flashVersion": "WIN 11,2,000",
  "text": "Blah blah blah"
}
@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/
@JamesMGreene
JamesMGreene / ZeroClipboard v2 API.md
Last active August 22, 2024 03:18
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 / 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 / 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!");
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 / 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) {
@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 / 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.
};