As easy as 1, 2, 3!
Updated:
- Aug, 08, 2022 update
config
docs for npm 8+ - Jul 27, 2021 add private scopes
- Jul 22, 2021 add dist tags
- Jun 20, 2021 update for
--access=public
- Sep 07, 2020 update docs for
npm version
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () { | |
var Storage = function (type) { | |
function createCookie(name, value, days) { | |
var date, expires; | |
if (days) { | |
date = new Date(); | |
date.setTime(date.getTime()+(days*24*60*60*1000)); | |
expires = "; expires="+date.toGMTString(); |
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE in JavaScript | |
// without resorting to user-agent sniffing | |
// ---------------------------------------------------------- | |
// If you're not in IE (or IE version is less than 5) then: | |
// ie === undefined | |
// If you're in IE (>=5) then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} |
// SMELLY: HTML in your JavaScript | |
$('#showMessage').click(function() { | |
$('<div>' + | |
'<h1>' + $('#messageTitle').val() + '</h1>' + | |
'<p>' + $('#messageText').val() + '</p>' + | |
'</div>') | |
.appendTo('#messageContainer') | |
}); | |
// MINTY FRESH: Use templates instead |
function xdomainajax() { | |
var win; | |
if (document.location == "otcsandbox.com") { | |
var content = "<html><body><scr"+"ipt>document.domain='otcsandbox.com';</scr"+"ipt><scr"+"ipt src='http://wheretogetjqueryfrom.com/jquery.js'></scr"+"ipt></body></html>"; | |
var iframe = document.createElement("iframe"); | |
document.body.appendChild(iframe); | |
win = iframe.contentDocument ? iframe : iframe.contentWindow ? iframe.contentWindow : iframe; | |
var doc = iframe.contentDocument ? iframe.contentDocument ? iframe.contentWindow ? iframe.contentWindow.document ? win.document; | |
doc.open(); |
// JSLint: | |
/*global window, parseInt*/ | |
// Conditionally check value, in case | |
// future implementations of parseInt | |
// provide native base-10 by default. | |
(function () { | |
var _parseInt = window.parseInt; | |
if (_parseInt('09') === 0) { |
var ConnectivityFsm = ( function( $, machina, amplify ) { | |
return function( heartbeatDef ) { | |
var settings = $.extend( true, { | |
type: "GET", | |
dataType: "json", | |
timeout: 5000 | |
}, heartbeatDef ); |
function deferredRequest( resource, data ) { | |
return $.Deferred(function( dfd ) { | |
amplify.request({ | |
resourceId: resource, | |
data: data, | |
success: dfd.resolve, | |
error: dfd.reject | |
}); | |
}).promise(); | |
} |
With the lastest version of Require, a new config object was introduced, the shim
.
http://requirejs.org/docs/api.html#config-shim
That allows Amplify to now be used within AMD projects.
Have Fun!
// all this `toJSON()` does is filter out any circular refs. all other values/refs, | |
// it passes through untouched, so it should be totally safe. see the test examples. | |
// only extend the prototype if `toJSON` isn't yet defined | |
if (!Object.prototype.toJSON) { | |
Object.prototype.toJSON = function() { | |
function findCircularRef(obj) { | |
for (var i=0; i<refs.length; i++) { | |
if (refs[i] === obj) return true; | |
} |