Skip to content

Instantly share code, notes, and snippets.

View englishextra's full-sized avatar
💜
the beat goes on

englishextra englishextra

💜
the beat goes on
View GitHub Profile
@englishextra
englishextra / fix-for-window-location-origin-in-ie.js
Created September 7, 2016 17:39
A fix for window.location.origin in Internet Explorer
/*!
* Internet Explorer does not have access to window.location.origin
* tosbourn.com/a-fix-for-window-location-origin-in-internet-explorer/
*/
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
@englishextra
englishextra / parseLink.js
Last active October 6, 2016 16:32
Unified URL parsing API in the browser and node
@englishextra
englishextra / uri.js
Created September 6, 2016 17:44 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@englishextra
englishextra / getDomainName.js
Created September 6, 2016 17:42 — forked from tahirm/getDomainName.js
Get complete domain name with protocol and port if available. #js #url From http://stackoverflow.com/questions/6941533/javascript-get-protocol-domain-and-port-from-url
var domain = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : '');
@englishextra
englishextra / ie.shims.js
Created August 29, 2016 13:46 — forked from dhm116/ie.shims.js
IE7/8 Javascript method shims
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@englishextra
englishextra / vanilla-js-cheatsheet.md
Created August 21, 2016 21:20 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@englishextra
englishextra / AJAXloadHTML.js
Last active September 14, 2016 12:41
Load .html file
/*!
* Load .html file
* modified JSON with JS.md
* gist.github.com/thiagodebastos/08ea551b97892d585f17
* gist.github.com/englishextra/d5ce0257afcdd9a7387d3eb26e9fdff5
*/
var AJAXloadHTML = function (u, cb, e) {
var w = window,
x = w.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
x.overrideMimeType("text/html;charset=utf-8");
@englishextra
englishextra / AJAXloadUnparsedJSON.js
Last active September 14, 2016 12:42
Load .json file, but don't JSON.parse it
/*!
* Load .json file, but don't JSON.parse it
* modified JSON with JS.md
* gist.github.com/thiagodebastos/08ea551b97892d585f17
* gist.github.com/englishextra/e2752e27761649479f044fd93a602312
*/
var AJAXloadUnparsedJSON = function (u, cb, e) {
var w = window,
x = w.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
x.overrideMimeType("application/json;charset=utf-8");
@englishextra
englishextra / doAsyncAjax.js
Created August 20, 2016 22:05
an async AJAX call without jQuery
/*!
* an async AJAX call without jQuery
* stackoverflow.com/questions/8567114/how-to-make-an-ajax-call-without-jquery
* gist.github.com/englishextra/79df33f0b9eb8828c12b2a760f74211c
*/
function doAsyncAjax(url, callback) {
var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
@englishextra
englishextra / zenscroll.fixed.min.js
Last active October 9, 2016 20:30
modified for babel Zenscroll 3.2.2
/*!
* modified for babel Zenscroll 3.2.2
* github.com/zengabor/zenscroll
* removed AMD, CommonJS support
* changed this or window to self as argument
* fixed IIFE enforcing
* added brackets in if / for
* Copyright 2015–2016 Gabor Lenard
* minified with closure-compiler.appspot.com/home
* github.com/zengabor/zenscroll/blob/dist/zenscroll.js