Last active
December 1, 2019 15:22
-
-
Save ewized/339643fd86f631103864d80638f70da7 to your computer and use it in GitHub Desktop.
Script that will install base_elements from the latest release version
This file contains 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
'use strict' | |
// Import the script from the url | |
function importScript(url) { | |
const request = new XMLHttpRequest() | |
request.onload = () => eval(request.responseText) | |
request.open('GET', url, true) | |
request.send() | |
} | |
// Change XMLHttpRequest to include origin header | |
// https://github.com/Rob--W/cors-anywhere/#documentation | |
(function() { | |
const cors_api_host = 'cors-anywhere.herokuapp.com' | |
const cors_api_url = 'https://' + cors_api_host + '/' | |
const slice = [].slice | |
const origin = window.location.protocol + '//' + window.location.host | |
const open = XMLHttpRequest.prototype.open | |
XMLHttpRequest.prototype.open = function() { | |
const args = slice.call(arguments) | |
let targetOrigin = /^https?:\/\/([^\/]+)/i.exec(args[1]) | |
if (targetOrigin && targetOrigin[0].toLowerCase() !== origin && targetOrigin[1] !== cors_api_host) { | |
args[1] = cors_api_url + args[1] | |
} | |
return open.apply(this, args) | |
} | |
})() | |
// Set the font aweseome url prefix to a cdn | |
window.BASE_ELEMENTS_FONT_PREFIX = 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/fonts' | |
// Import the bundle that is generated from GitHub Releases | |
importScript('https://github.com/ewized/base-elements/releases/latest/download/base_elements.bundle.js') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment