This script implements some of PHP's magic methods for JavaScript classes, using a Proxy.
You can use it like this:
const Foo = magicMethods(class Foo {
constructor () {
this.bar = 'Bar'
}| { | |
| "countries": [ | |
| { | |
| "country": "Afghanistan", | |
| "states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"] | |
| }, | |
| { | |
| "country": "Albania", | |
| "states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"] | |
| }, |
| /* | |
| ##Device = Desktops | |
| ##Screen = 1281px to higher resolution desktops | |
| */ | |
| @media (min-width: 1281px) { | |
| //CSS | |
This script implements some of PHP's magic methods for JavaScript classes, using a Proxy.
You can use it like this:
const Foo = magicMethods(class Foo {
constructor () {
this.bar = 'Bar'
}| (function (win, doc) { | |
| function getRangeAtCollapse(range, collapsed) { | |
| // get range as item | |
| if (range.item) { | |
| var rangeItem = range.item(0); | |
| // return the data | |
| return { node: rangeItem }; | |
| } | |
| // get range as text | |
| var |
| (function (window, screen, documentElement) { | |
| /* ====================================================================== | |
| Setup | |
| ====================================================================== */ | |
| var hasEventListener = ('addEventListener' in window); | |
| var hasOrientation = ('orientation' in window); | |
| var hasGetComputedStyle = ('getComputedStyle' in window); | |
| var regexpTrim = /^\s+|\s+$/g; |
| Object.getClass = function (object) { | |
| return object === undefined ? "Undefined" | |
| : object === null ? "Null" | |
| : (String.toString.call(object.constructor || object).match(/\s\w+/) || [" Function"])[0].slice(1); | |
| }; |
| this.CSSStyleDeclaration && function (CSSStyleDeclarationPrototype, defaultStyles, defaultProperty, specialProperty) { | |
| for (defaultProperty in defaultStyles) { | |
| specialProperty = defaultProperty.match(/^(O|Moz|ms|webkit)([A-Z])(.*)$/); | |
| specialProperty && function (defaultProperty, genericProperty) { | |
| Object.defineProperty(CSSStyleDeclarationPrototype, genericProperty, { | |
| get: function () { | |
| return this[defaultProperty]; | |
| }, | |
| set: function (value) { |
| { | |
| "audio/mp4": "m4a|f4a|f4b", | |
| "audio/ogg": "oga|ogg", | |
| "audio/&": "mid|midi|mp3|wav", | |
| "application/javascript": "js|jsonp", | |
| "application/json": "json", | |
| "application/msword": "doc|dot", | |
| "application/octet-stream": "bin", | |
| "application/postscript": "ai", | |
| "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx", |
| // Image.prototype.barcode | |
| (function () { | |
| 'use strict'; | |
| var UPC_SET = { | |
| '3211': '0', | |
| '2221': '1', | |
| '2122': '2', | |
| '1411': '3', | |
| '1132': '4', |
Match a variety of social media urls, detect their medium, and collect their single-most important ID.
{
dailymotion: /https?:\/\/(?:www\.)?dailymotion\.com\/(swf|video)\/([^\/?&]+)/,
googlemaps: /(^https?\:\/\/maps\.google\.com.+)/,
googleplus: /https?:\/\/(?:plus\.google\.com|gplus\.to)\/([^\/?&]+)/,
flickr: /https?:\/\/(?:www\.)?flickr\.com\/(?:people|photos)\/(\d+@N\d+)/,