Skip to content

Instantly share code, notes, and snippets.

View alexgibson's full-sized avatar
🍄
1UP

Alex Gibson alexgibson

🍄
1UP
View GitHub Profile
@alexgibson
alexgibson / pop-out.css
Created February 21, 2011 12:13
CSS popout animation for highlighting elements
.highlight {
-webkit-animation-name: popout;
-webkit-animation-duration: 0.3s;
-webkit-animation-iteration-count: 1;
-moz-animation-name: popout;
-moz-animation-duration: 0.3s;
-moz-animation-iteration-count: 1;
animation-name: popout;
animation-duration: 0.3s;
animation-iteration-count: 1;
@alexgibson
alexgibson / Touch-Event-Delegation.js
Created July 6, 2011 19:38
Event delegation for JavaScript 'tap' events
var tapArea, moved, startX, startY;
tapArea = document.querySelector('#list'); //the element to delegate
moved = false; //flags if the finger has moved
startX = 0; //starting x coordinate
startY = 0; //starting y coordinate
//touchstart
tapArea.ontouchstart = function(e) {
@alexgibson
alexgibson / getParameterFromUrl.js
Created January 30, 2012 13:54
JS 'get' from url
function getParameterFromUrl(param) {
var name = param.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'),
results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results === null) {
return null;
} else {
return decodeURIComponent(results[1].replace(/\+/g, ' '));
}
}
@alexgibson
alexgibson / stripHTML.js
Created January 30, 2012 13:55
return text content from HTML
//return text content from html
function stripHTML(html) {
var tmp = document.createElement('div');
tmp.innerHTML = html;
return tmp.textContent || tmp.innerText;
}
@alexgibson
alexgibson / specialChars.js
Created January 30, 2012 13:56
encode & decode special chars
//encodes special characters
function encodeString(str) {
return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g, '&#x2F;');
}
//decodes special characters
function decodeString(str) {
return str.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&#x27;/g, '\'').replace(/&#x2F;/g, '/');
}
@alexgibson
alexgibson / enableActivePseudoStyles.js
Created January 30, 2012 13:57
hack to enable active pseudo styles in mobile webkit
//enable active pseudo styles in mobile webkit. Only required if not already using touch events
function enableActivePseudoStyles() {
document.addEventListener("touchstart", function () {}, false);
}
<snippet>
<content><![CDATA[{{ _('$SELECTION') }}]]></content>
<description>Wrap string for l10n</description>
</snippet>
<script type="text/javascript">
// See MDN: https://developer.mozilla.org/en-US/docs/DOM/MutationObserver?redirectlocale=en-US&redirectslug=DOM%2FDOM_Mutation_Observers
(function(){
// select the target node
var target = document.querySelector('body');
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var i={};
// create an observer instance
var observer = new MutationObserver(function(mutations) {
@-moz-document domain("irccloud.com"), domain("irccloud.mozilla.com") {
/* Dark Matter Reloaded
* Version 2.3 - 03/02/2015
*
* Author: @xupisco - xupisco.net */
/* Square corners, pls */
* {
border-radius: 0 !important;
border-top-right-radius: 0 !important;