Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jymin

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jymin - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

.jshintrc

290

jymin.js
/**
* _ _ ___ ____ ____
* | |_ _ _ __ ___ (_)_ __ __ __/ _ \ |___ \ |___ \
* _ | | | | | '_ ` _ \| | '_ \ \ \ / / | | | __) | __) |
* | |_| | |_| | | | | | | | | | | \ V /| |_| | / __/ _ / __/
* \___/ \__, |_| |_| |_|_|_| |_| \_/ \___(_)_____(_)_____|
* _ _ ___ ____ _____
* | |_ _ _ __ ___ (_)_ __ __ __/ _ \ |___ \ |___ /
* _ | | | | | '_ ` _ \| | '_ \ \ \ / / | | | __) | |_ \
* | |_| | |_| | | | | | | | | | | \ V /| |_| | / __/ _ ___) |
* \___/ \__, |_| |_| |_|_|_| |_| \_/ \___(_)_____(_)____/
* |___/

@@ -16,3 +16,2 @@ *

* https://github.com/zerious/jymin/blob/master/scripts/ajax.js
* https://github.com/zerious/jymin/blob/master/scripts/animation.js
* https://github.com/zerious/jymin/blob/master/scripts/collections.js

@@ -34,3 +33,3 @@ * https://github.com/zerious/jymin/blob/master/scripts/cookies.js

this.jymin = {version: '0.2.2'};
this.jymin = {version: '0.2.3'};

@@ -65,5 +64,7 @@ /**

request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject('Microsoft.XMLHTTP');
} else {
}
else if (window.ActiveXObject) {
request = new ActiveXObject('Microsoft.XMLHTTP'); // jshint ignore:line
}
else {
return false;

@@ -85,11 +86,11 @@ }

try {
// Trick Uglify into thinking there's no eval.
var e = window.eval;
e('eval.J=' + response);
object = e.J;
// Trick UglifyJS into thinking there's no eval.
var evil = window.eval; // jshint ignore:line
evil('eval.J=' + response);
object = evil.J;
}
catch (e) {
//+env:dev
error('Could not parse JSON: "' + response + '"');
//-env:dev
//+env:debug,dev
error('Jymin: Could not parse JSON: "' + response + '"');
//-env:debug,dev
object = {_ERROR: '_BAD_JSON', _TEXT: response};

@@ -144,60 +145,3 @@ }

};
var DEFAULT_ANIMATION_FRAME_COUNT = 40;
var DEFAULT_ANIMATION_FRAME_DELAY = 20;
/**
* Perform an animation.
*/
var animate = function (
element, // string|DOMElement: Element or ID of element to animate.
styleTransitions, // object: cssText values to animate through.
onFinish, // function|: Callback to execute when animation is complete.
frameCount, // integer|: Number of frames to animate through. (Default: 40)
frameDelay, // integer|: Number of milliseconds between frames. (Default: 20ms)
frameIndex // integer|: Index of the frame to start on. (Default: 0)
) {
if (element = getElement(element)) {
// Only allow one animation on an element at a time.
stopAnimation(element);
frameIndex = frameIndex || 0;
frameCount = frameCount || DEFAULT_ANIMATION_FRAME_COUNT;
frameDelay = frameDelay || DEFAULT_ANIMATION_FRAME_DELAY;
var scale = Math.atan(1.5) * 2;
var fraction = Math.atan(frameIndex / frameCount * 3 - 1.5) / scale + 0.5;
var styles = {};
forIn(styleTransitions, function(transition, key) {
var start = transition[0];
var end = transition[1];
var value;
if (isNaN(start)) {
value = frameIndex ? end : start;
}
else {
value = (1 - fraction) * start + fraction * end;
}
styles[key] = value;
});
extendStyle(element, styles);
if (frameIndex < frameCount) {
element.animation = setTimeout(function() {
animate(element, styleTransitions, onFinish, frameCount, frameDelay, frameIndex + 1);
});
}
else if (onFinish) {
onFinish(element);
}
}
};
/**
* Stop an animation on a given DOM element.
*/
var stopAnimation = function (
element // string|DOMElement: Element or ID of element to cancel the animation on.
) {
if (element = getElement(element)) {
clearTimeout(element.animation);
}
};
/**
* Iterate over an array, and call a function on each item.

@@ -209,10 +153,10 @@ */

) {
if (array) {
for (var index = 0, length = getLength(array); index < length; index++) {
var result = callback(array[index], index, array);
if (result === false) {
break;
}
}
if (array) {
for (var index = 0, length = getLength(array); index < length; index++) {
var result = callback(array[index], index, array);
if (result === false) {
break;
}
}
}
};

@@ -227,10 +171,10 @@

) {
if (object) {
for (var key in object) {
var result = callback(object[key], key, object);
if (result === false) {
break;
}
}
if (object) {
for (var key in object) {
var result = callback(object[key], key, object);
if (result === false) {
break;
}
}
}
};

@@ -326,8 +270,8 @@

) {
// TODO: Use splice instead of pushes to get better performance?
var addToFirstArray = function (item) {
array.push(item);
};
for (var i = 1, l = arguments.length; i < l; i++) {
items = arguments[i];
// TODO: Use splice instead of push to get better performance?
forEach(items, function (item) {
array.push(item);
});
forEach(arguments[i], addToFirstArray);
}

@@ -349,3 +293,3 @@ };

if (startingLength < length) {
paddingValue = isDefined(paddingValue) ? paddingValue : '';
paddingValue = isUndefined(paddingValue) ? '' : paddingValue;
for (var index = startingLength; index < length; index++) {

@@ -364,11 +308,10 @@ array.push(paddingValue);

var getAllCookies = function () {
var str = document.cookie;
var decode = decodeURIComponent;
var obj = {};
var pairs = str.split(/ *; */);
var pair;
if ('' == pairs[0]) return obj;
for (var i = 0; i < pairs.length; ++i) {
pair = pairs[i].split('=');
obj[decode(pair[0])] = decode(pair[1]);
var documentCookie = trim(document.cookie);
if (documentCookie) {
var cookies = documentCookie.split(/\s*;\s*/);
forEach(cookies, function (cookie) {
var pair = cookie.split(/\s*=\s*/);
obj[unescape(pair[0])] = unescape(pair[1]);
});
}

@@ -397,15 +340,14 @@ return obj;

options = options || {};
var encode = encodeURIComponent;
var str = encode(name) + '=' + encode(value);
if (null == value) {
var str = escape(name) + '=' + unescape(value);
if (null === value) {
options.maxage = -1;
}
if (options.maxage) {
options.expires = new Date(+new Date + options.maxage);
options.expires = new Date(+new Date() + options.maxage);
}
if (options.path) str += ';path=' + options.path;
if (options.domain) str += ';domain=' + options.domain;
if (options.expires) str += ';expires=' + options.expires.toUTCString();
if (options.secure) str += ';secure';
document.cookie = str;
document.cookie = str +
(options.path ? ';path=' + options.path : '') +
(options.domain ? ';domain=' + options.domain : '') +
(options.expires ? ';expires=' + options.expires.toUTCString() : '') +
(options.secure ? ';secure' : '');
};

@@ -478,4 +420,5 @@

var anyTag = (tagName == '*');
var elements;
if (className) {
var elements = [];
elements = [];
if (parentElement.getElementsByClassName) {

@@ -518,4 +461,4 @@ forEach(parentElement.getElementsByClassName(className), function(element) {

/**
* Create a DOM element.
*/
* Create a DOM element.
*/
var createElement = function (

@@ -535,3 +478,3 @@ tagIdentifier

var attributes = tagAndAttributes[1];
var cachedElement = addElement[tagName] || (addElement[tagName] = document.createElement(tagName));
var cachedElement = createElement[tagName] || (createElement[tagName] = document.createElement(tagName));
var element = cachedElement.cloneNode(true);

@@ -622,9 +565,9 @@ if (id) {

) {
if (element = getElement(element)) {
var index = 0;
while (element = element.previousSibling) {
++index;
}
return index;
element = getElement(element);
var index = -1;
while (element) {
++index;
element = element.previousSibling;
}
return index;
};

@@ -654,2 +597,27 @@

/**
* Insert a DOM element after another.
*/
var insertBefore = function (
element,
childElement
) {
element = getElement(element);
var parentElement = getParent(element);
addElement(parentElement, childElement, element);
};
/**
* Insert a DOM element after another.
*/
var insertAfter = function (
element,
childElement
) {
element = getElement(element);
var parentElement = getParent(element);
var beforeElement = getNextSibling(element);
addElement(parentElement, childElement, beforeElement);
};
/**
* Remove a DOM element from its parent.

@@ -661,3 +629,4 @@ */

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Remove the element from its parent, provided that its parent still exists.

@@ -687,3 +656,4 @@ var parentElement = getParent(element);

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.innerHTML;

@@ -701,3 +671,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Set the element's innerHTML.

@@ -715,3 +686,4 @@ element.innerHTML = html;

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.innerText;

@@ -729,3 +701,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Set the element's innerText.

@@ -743,3 +716,4 @@ element.innerHTML = text;

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.className;

@@ -757,3 +731,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Set the element's innerText.

@@ -771,3 +746,4 @@ element.className = className;

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.firstChild;

@@ -784,3 +760,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.previousSibling;

@@ -797,3 +774,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.nextSibling;

@@ -821,3 +799,4 @@ }

) {
if (element = getElement(element)) {
element = getElement(element);
if (element) {
element.className += ' ' + className;

@@ -834,3 +813,4 @@ }

) {
if (element = getElement(element)) {
element = getElement(element);
if (element) {
var tokens = getClass(element).split(/\s/);

@@ -896,3 +876,3 @@ var ok = [];

/**
* Run a callback on each element matching a given selector.
* Finds elements matching a selector, and return or run a callback on them.
*/

@@ -904,5 +884,6 @@ var all = function (

) {
// TODO: Better argument collapsing.
if (!selector || isFunction(selector)) {
callback = selector;
selector = parentElement
selector = parentElement;
parentElement = document;

@@ -943,3 +924,14 @@ }

};
/**
* Finds elements matching a selector, and return or run a callback on them.
*/
var one = function (
parentElement,
selector,
callback
) {
return all(parentElement, selector, callback)[0];
};
/**
* Bind a handler to listen for a particular event on an element.

@@ -964,3 +956,4 @@ */

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {

@@ -979,3 +972,3 @@ // Invoke the event handler with the event information and the target element.

if (eventName == 'mouseout') {
while (relatedTarget = getParent(relatedTarget)) {
while (relatedTarget = getParent(relatedTarget)) { // jshint ignore:line
if (relatedTarget == target) {

@@ -1105,3 +1098,4 @@ return;

// Bubble up to find a tagAndClass match because we didn't find one this time.
if (target = getParent(target)) {
target = getParent(target);
if (target) {
onHandler(element, event, target, customData);

@@ -1260,4 +1254,4 @@ }

}
return value;
}
return value;
};

@@ -1425,3 +1419,3 @@

setTimeout(function () {
onReady()
onReady();
}, 1);

@@ -1467,3 +1461,3 @@ }

) {
return ensureString(string).indexOf(substring) == 0;
return ensureString(string).indexOf(substring) == 0; // jshint ignore:line
};

@@ -1576,2 +1570,16 @@

/**
* Return an escaped value for URLs.
*/
var escape = function (value) {
return encodeURIComponent(value);
};
/**
* Return an unescaped value from an escaped URL.
*/
var unescape = function (value) {
return decodeURIComponent(value);
};
/**
* Returns a query string generated by serializing an object and joined using a delimiter (defaults to '&')

@@ -1578,0 +1586,0 @@ */

@@ -15,3 +15,3 @@ {

],
"version": "0.2.2",
"version": "0.2.3",
"main": "chug/chug.js",

@@ -53,7 +53,7 @@ "homepage": "http://lighter.io/jymin",

"mocha": "1.20.1",
"istanbul": "0.2.10",
"istanbul": "0.2.11",
"coveralls": "2.10.0",
"chug": "0.1.26",
"figlet": "1.0.8"
"chug": "0.1.27",
"figlet": "1.0.9"
}
}

@@ -29,5 +29,7 @@ /**

request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject('Microsoft.XMLHTTP');
} else {
}
else if (window.ActiveXObject) {
request = new ActiveXObject('Microsoft.XMLHTTP'); // jshint ignore:line
}
else {
return false;

@@ -49,11 +51,11 @@ }

try {
// Trick Uglify into thinking there's no eval.
var e = window.eval;
e('eval.J=' + response);
object = e.J;
// Trick UglifyJS into thinking there's no eval.
var evil = window.eval; // jshint ignore:line
evil('eval.J=' + response);
object = evil.J;
}
catch (e) {
//+env:dev
error('Could not parse JSON: "' + response + '"');
//-env:dev
//+env:debug,dev
error('Jymin: Could not parse JSON: "' + response + '"');
//-env:debug,dev
object = {_ERROR: '_BAD_JSON', _TEXT: response};

@@ -60,0 +62,0 @@ }

@@ -8,10 +8,10 @@ /**

) {
if (array) {
for (var index = 0, length = getLength(array); index < length; index++) {
var result = callback(array[index], index, array);
if (result === false) {
break;
}
}
if (array) {
for (var index = 0, length = getLength(array); index < length; index++) {
var result = callback(array[index], index, array);
if (result === false) {
break;
}
}
}
};

@@ -26,10 +26,10 @@

) {
if (object) {
for (var key in object) {
var result = callback(object[key], key, object);
if (result === false) {
break;
}
}
if (object) {
for (var key in object) {
var result = callback(object[key], key, object);
if (result === false) {
break;
}
}
}
};

@@ -125,8 +125,8 @@

) {
// TODO: Use splice instead of pushes to get better performance?
var addToFirstArray = function (item) {
array.push(item);
};
for (var i = 1, l = arguments.length; i < l; i++) {
items = arguments[i];
// TODO: Use splice instead of push to get better performance?
forEach(items, function (item) {
array.push(item);
});
forEach(arguments[i], addToFirstArray);
}

@@ -148,3 +148,3 @@ };

if (startingLength < length) {
paddingValue = isDefined(paddingValue) ? paddingValue : '';
paddingValue = isUndefined(paddingValue) ? '' : paddingValue;
for (var index = startingLength; index < length; index++) {

@@ -151,0 +151,0 @@ array.push(paddingValue);

@@ -6,11 +6,10 @@ /**

var getAllCookies = function () {
var str = document.cookie;
var decode = decodeURIComponent;
var obj = {};
var pairs = str.split(/ *; */);
var pair;
if ('' == pairs[0]) return obj;
for (var i = 0; i < pairs.length; ++i) {
pair = pairs[i].split('=');
obj[decode(pair[0])] = decode(pair[1]);
var documentCookie = trim(document.cookie);
if (documentCookie) {
var cookies = documentCookie.split(/\s*;\s*/);
forEach(cookies, function (cookie) {
var pair = cookie.split(/\s*=\s*/);
obj[unescape(pair[0])] = unescape(pair[1]);
});
}

@@ -39,15 +38,14 @@ return obj;

options = options || {};
var encode = encodeURIComponent;
var str = encode(name) + '=' + encode(value);
if (null == value) {
var str = escape(name) + '=' + unescape(value);
if (null === value) {
options.maxage = -1;
}
if (options.maxage) {
options.expires = new Date(+new Date + options.maxage);
options.expires = new Date(+new Date() + options.maxage);
}
if (options.path) str += ';path=' + options.path;
if (options.domain) str += ';domain=' + options.domain;
if (options.expires) str += ';expires=' + options.expires.toUTCString();
if (options.secure) str += ';secure';
document.cookie = str;
document.cookie = str +
(options.path ? ';path=' + options.path : '') +
(options.domain ? ';domain=' + options.domain : '') +
(options.expires ? ';expires=' + options.expires.toUTCString() : '') +
(options.secure ? ';secure' : '');
};

@@ -54,0 +52,0 @@

@@ -47,4 +47,5 @@ /**

var anyTag = (tagName == '*');
var elements;
if (className) {
var elements = [];
elements = [];
if (parentElement.getElementsByClassName) {

@@ -87,4 +88,4 @@ forEach(parentElement.getElementsByClassName(className), function(element) {

/**
* Create a DOM element.
*/
* Create a DOM element.
*/
var createElement = function (

@@ -104,3 +105,3 @@ tagIdentifier

var attributes = tagAndAttributes[1];
var cachedElement = addElement[tagName] || (addElement[tagName] = document.createElement(tagName));
var cachedElement = createElement[tagName] || (createElement[tagName] = document.createElement(tagName));
var element = cachedElement.cloneNode(true);

@@ -191,9 +192,9 @@ if (id) {

) {
if (element = getElement(element)) {
var index = 0;
while (element = element.previousSibling) {
++index;
}
return index;
element = getElement(element);
var index = -1;
while (element) {
++index;
element = element.previousSibling;
}
return index;
};

@@ -223,2 +224,27 @@

/**
* Insert a DOM element after another.
*/
var insertBefore = function (
element,
childElement
) {
element = getElement(element);
var parentElement = getParent(element);
addElement(parentElement, childElement, element);
};
/**
* Insert a DOM element after another.
*/
var insertAfter = function (
element,
childElement
) {
element = getElement(element);
var parentElement = getParent(element);
var beforeElement = getNextSibling(element);
addElement(parentElement, childElement, beforeElement);
};
/**
* Remove a DOM element from its parent.

@@ -230,3 +256,4 @@ */

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Remove the element from its parent, provided that its parent still exists.

@@ -256,3 +283,4 @@ var parentElement = getParent(element);

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.innerHTML;

@@ -270,3 +298,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Set the element's innerHTML.

@@ -284,3 +313,4 @@ element.innerHTML = html;

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.innerText;

@@ -298,3 +328,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Set the element's innerText.

@@ -312,3 +343,4 @@ element.innerHTML = text;

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.className;

@@ -326,3 +358,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
// Set the element's innerText.

@@ -340,3 +373,4 @@ element.className = className;

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.firstChild;

@@ -353,3 +387,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.previousSibling;

@@ -366,3 +401,4 @@ }

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {
return element.nextSibling;

@@ -390,3 +426,4 @@ }

) {
if (element = getElement(element)) {
element = getElement(element);
if (element) {
element.className += ' ' + className;

@@ -403,3 +440,4 @@ }

) {
if (element = getElement(element)) {
element = getElement(element);
if (element) {
var tokens = getClass(element).split(/\s/);

@@ -465,3 +503,3 @@ var ok = [];

/**
* Run a callback on each element matching a given selector.
* Finds elements matching a selector, and return or run a callback on them.
*/

@@ -473,5 +511,6 @@ var all = function (

) {
// TODO: Better argument collapsing.
if (!selector || isFunction(selector)) {
callback = selector;
selector = parentElement
selector = parentElement;
parentElement = document;

@@ -512,1 +551,12 @@ }

};
/**
* Finds elements matching a selector, and return or run a callback on them.
*/
var one = function (
parentElement,
selector,
callback
) {
return all(parentElement, selector, callback)[0];
};

@@ -21,3 +21,4 @@ /**

// Ensure that we have an element, not just an ID.
if (element = getElement(element)) {
element = getElement(element);
if (element) {

@@ -36,3 +37,3 @@ // Invoke the event handler with the event information and the target element.

if (eventName == 'mouseout') {
while (relatedTarget = getParent(relatedTarget)) {
while (relatedTarget = getParent(relatedTarget)) { // jshint ignore:line
if (relatedTarget == target) {

@@ -162,3 +163,4 @@ return;

// Bubble up to find a tagAndClass match because we didn't find one this time.
if (target = getParent(target)) {
target = getParent(target);
if (target) {
onHandler(element, event, target, customData);

@@ -165,0 +167,0 @@ }

@@ -27,4 +27,4 @@ /**

}
return value;
}
return value;
};

@@ -31,0 +31,0 @@

@@ -16,3 +16,3 @@ /**

setTimeout(function () {
onReady()
onReady();
}, 1);

@@ -19,0 +19,0 @@ }

@@ -27,3 +27,3 @@ /**

) {
return ensureString(string).indexOf(substring) == 0;
return ensureString(string).indexOf(substring) == 0; // jshint ignore:line
};

@@ -136,2 +136,16 @@

/**
* Return an escaped value for URLs.
*/
var escape = function (value) {
return encodeURIComponent(value);
};
/**
* Return an unescaped value from an escaped URL.
*/
var unescape = function (value) {
return decodeURIComponent(value);
};
/**
* Returns a query string generated by serializing an object and joined using a delimiter (defaults to '&')

@@ -138,0 +152,0 @@ */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc