This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>WebKit bug workaround: outside click of inline or floated contentEditable-elements focuses the element</title> | |
<script> | |
if (/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)) { | |
document.addEventListener('DOMContentLoaded', function(){ | |
var fixEl = document.createElement('input'); | |
fixEl.style.cssText = 'width:1px;height:1px;border:none;margin:0;padding:0; position:fixed; top:0; left:0'; | |
fixEl.tabIndex = -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (var i=0, x; x = array[i++];) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
show: function(){ | |
$(document).on('keydown',this.keydownListener); | |
}, | |
keydownListener: function(e){ | |
if(e.which===27){ e.originalScope.hide(); } /// <----- originalScope | |
}, | |
hide: function(){ | |
$(document).off('keydown',this.keydownListener); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.q1Vibrate = function(){ | |
var native = navigator.vibrate || navigator.mozVibrate || navigator.wekbitVibrate; | |
if(native){ | |
return native; | |
} | |
var scripts = document.getElementsByTagName('script'); | |
var script = scripts[scripts.length-1]; | |
var path = script.src.replace(/vibrate.js/,''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (global) { | |
/* ... Code that defines MyModule ... */ | |
global.MyModule = (global.module || {}).exports = MyModule; | |
})(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ussage: | |
// - include this script | |
// - add the data-c1-ratio-attribute to your images | |
// <img src="big.jpg" data-c1-ratio="1.245" style="width:200px; max-width:100%"> | |
!function(){ | |
'use strict'; | |
var listener = function(e){ | |
this.removeEventListener('load',listener); | |
this.removeEventListener('error',listener); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Stirct types | |
function test(string $name, int $age, float $cuteness, bool $evil) { | |
//.... | |
} | |
// Convert types | |
function test((string)$name, (int)$age, (float)$cuteness, (bool)$evil) { | |
//.... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!(function(){ | |
var original = console; | |
Object.defineProperty(window, 'console', { | |
get:function(){ | |
return original; | |
}, | |
set:function(value){ | |
original.log(value) | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright (c) 2016 Tobias Buschor https://goo.gl/gl0mbf | MIT License https://goo.gl/HgajeK */ | |
// hacky fix of CSSRule.selectorText, edge, chrome, safari, https://bugs.chromium.org/p/chromium/issues/detail?id=681814 | |
var desc = Object.getOwnPropertyDescriptor(CSSStyleRule.prototype, 'selectorText'); | |
var getter = desc.get; | |
desc.get = function(){ | |
var str = getter.apply(this).replace(/\[([^\]]+[^\\\]]):([^\]]+)\]/g, '[$1\\:$2]'); | |
return str; | |
} | |
Object.defineProperty(CSSStyleRule.prototype, 'selectorText', desc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stringToFragment(html){ | |
var tmpl = document.createElement('template'); | |
tmpl.innerHTML = html; | |
if (tmpl.content == void 0){ // ie11 | |
var fragment = document.createDocumentFragment(); | |
var isTableEl = /^[^\S]*?<(t(?:head|body|foot|r|d|h))/i.test(html); | |
tmpl.innerHTML = isTableEl ? '<table>'+html : html; | |
var els = isTableEl ? tmpl.querySelector(RegExp.$1).parentNode.childNodes : tmpl.childNodes; | |
while(els[0]) fragment.appendChild(els[0]); |
OlderNewer