How to use setcookie method in Cypress

Best JavaScript code snippet using cypress

encoding.js

Source:encoding.js Github

copy

Full Screen

1QUnit.module('cookie-value', lifecycle);2QUnit.test('cookie-value with double quotes', function (assert) {3	assert.expect(1);4	using(assert)5	.setCookie('c', '"')6	.then(function (decodedValue) {7		assert.strictEqual(decodedValue, '"', 'should print the quote character');8	});9});10QUnit.test('cookie-value with double quotes in the left', function (assert) {11	assert.expect(1);12	using(assert)13	.setCookie('c', '"content')14	.then(function (decodedValue) {15		assert.strictEqual(decodedValue, '"content', 'should print the quote character');16	});17});18QUnit.test('cookie-value with double quotes in the right', function (assert) {19	assert.expect(1);20	using(assert)21	.setCookie('c', 'content"')22	.then(function (decodedValue) {23		assert.strictEqual(decodedValue, 'content"', 'should print the quote character');24	});25});26QUnit.test('RFC 6265 - character not allowed in the cookie-value " "', function (assert) {27	assert.expect(2);28	using(assert)29	.setCookie('c', ' ')30	.then(function (decodedValue, plainValue) {31		assert.strictEqual(decodedValue, ' ', 'should handle the whitespace character');32		assert.strictEqual(plainValue, 'c=%20', 'whitespace is not allowed, need to encode');33	});34});35QUnit.test('RFC 6265 - character not allowed in the cookie-value ","', function (assert) {36	assert.expect(2);37	using(assert)38	.setCookie('c', ',')39	.then(function (decodedValue, plainValue) {40		assert.strictEqual(decodedValue, ',', 'should handle the comma character');41		assert.strictEqual(plainValue, 'c=%2C', 'comma is not allowed, need to encode');42	});43});44QUnit.test('RFC 6265 - character not allowed in the cookie-value ";"', function (assert) {45	assert.expect(2);46	using(assert)47	.setCookie('c', ';')48	.then(function (decodedValue, plainValue) {49		assert.strictEqual(decodedValue, ';', 'should handle the semicolon character');50		assert.strictEqual(plainValue, 'c=%3B', 'semicolon is not allowed, need to encode');51	});52});53QUnit.test('RFC 6265 - character not allowed in the cookie-value "\\"', function (assert) {54	assert.expect(2);55	using(assert)56	.setCookie('c', '\\')57	.then(function (decodedValue, plainValue) {58		assert.strictEqual(decodedValue, '\\', 'should handle the backslash character');59		assert.strictEqual(plainValue, 'c=%5C', 'backslash is not allowed, need to encode');60	});61});62QUnit.test('RFC 6265 - characters not allowed in the cookie-value should be replaced globally', function (assert) {63	assert.expect(2);64	using(assert)65	.setCookie('c', ';;')66	.then(function (decodedValue, plainValue) {67		assert.strictEqual(decodedValue, ';;', 'should handle multiple not allowed characters');68		assert.strictEqual(plainValue, 'c=%3B%3B', 'should replace multiple not allowed characters');69	});70});71QUnit.test('RFC 6265 - character allowed in the cookie-value "#"', function (assert) {72	assert.expect(2);73	using(assert)74	.setCookie('c', '#')75	.then(function (decodedValue, plainValue) {76		assert.strictEqual(decodedValue, '#', 'should handle the sharp character');77		assert.strictEqual(plainValue, 'c=#', 'sharp is allowed, should not encode');78	});79});80QUnit.test('RFC 6265 - character allowed in the cookie-value "$"', function (assert) {81	assert.expect(2);82	using(assert)83	.setCookie('c', '$')84	.then(function (decodedValue, plainValue) {85		assert.strictEqual(decodedValue, '$', 'should handle the dollar sign character');86		assert.strictEqual(plainValue, 'c=$', 'dollar sign is allowed, should not encode');87	});88});89QUnit.test('RFC 6265 - character allowed in the cookie-value "%"', function (assert) {90	assert.expect(2);91	using(assert)92	.setCookie('c', '%')93	.then(function (decodedValue, plainValue) {94		assert.strictEqual(decodedValue, '%', 'should handle the percent character');95		assert.strictEqual(plainValue, 'c=%25', 'percent is allowed, but need to be escaped');96	});97});98QUnit.test('RFC 6265 - character allowed in the cookie-value "&"', function (assert) {99	assert.expect(2);100	using(assert)101	.setCookie('c', '&')102	.then(function (decodedValue, plainValue) {103		assert.strictEqual(decodedValue, '&', 'should handle the ampersand character');104		assert.strictEqual(plainValue, 'c=&', 'ampersand is allowed, should not encode');105	});106});107// github.com/carhartl/jquery-cookie/pull/62108QUnit.test('RFC 6265 - character allowed in the cookie-value "+"', function (assert) {109	assert.expect(2);110	using(assert)111	.setCookie('c', '+')112	.then(function (decodedValue, plainValue) {113		assert.strictEqual(decodedValue, '+', 'should handle the plus character');114		assert.strictEqual(plainValue, 'c=+', 'plus is allowed, should not encode');115	});116});117QUnit.test('RFC 6265 - character allowed in the cookie-value ":"', function (assert) {118	assert.expect(2);119	using(assert)120	.setCookie('c', ':')121	.then(function (decodedValue, plainValue) {122		assert.strictEqual(decodedValue, ':', 'should handle the colon character');123		assert.strictEqual(plainValue, 'c=:', 'colon is allowed, should not encode');124	});125});126QUnit.test('RFC 6265 - character allowed in the cookie-value "<"', function (assert) {127	assert.expect(2);128	using(assert)129	.setCookie('c', '<')130	.then(function (decodedValue, plainValue) {131		assert.strictEqual(decodedValue, '<', 'should handle the less-than character');132		assert.strictEqual(plainValue, 'c=<', 'less-than is allowed, should not encode');133	});134});135QUnit.test('RFC 6265 - character allowed in the cookie-value ">"', function (assert) {136	assert.expect(2);137	using(assert)138	.setCookie('c', '>')139	.then(function (decodedValue, plainValue) {140		assert.strictEqual(decodedValue, '>', 'should handle the greater-than character');141		assert.strictEqual(plainValue, 'c=>', 'greater-than is allowed, should not encode');142	});143});144QUnit.test('RFC 6265 - character allowed in the cookie-value "="', function (assert) {145	assert.expect(2);146	using(assert)147	.setCookie('c', '=')148	.then(function (decodedValue, plainValue) {149		assert.strictEqual(decodedValue, '=', 'should handle the equal sign character');150		assert.strictEqual(plainValue, 'c==', 'equal sign is allowed, should not encode');151	});152});153QUnit.test('RFC 6265 - character allowed in the cookie-value "/"', function (assert) {154	assert.expect(2);155	using(assert)156	.setCookie('c', '/')157	.then(function (decodedValue, plainValue) {158		assert.strictEqual(decodedValue, '/', 'should handle the slash character');159		assert.strictEqual(plainValue, 'c=/', 'slash is allowed, should not encode');160	});161});162QUnit.test('RFC 6265 - character allowed in the cookie-value "?"', function (assert) {163	assert.expect(2);164	using(assert)165	.setCookie('c', '?')166	.then(function (decodedValue, plainValue) {167		assert.strictEqual(decodedValue, '?', 'should handle the question mark character');168		assert.strictEqual(plainValue, 'c=?', 'question mark is allowed, should not encode');169	});170});171QUnit.test('RFC 6265 - character allowed in the cookie-value "@"', function (assert) {172	assert.expect(2);173	using(assert)174	.setCookie('c', '@')175	.then(function (decodedValue, plainValue) {176		assert.strictEqual(decodedValue, '@', 'should handle the at character');177		assert.strictEqual(plainValue, 'c=@', 'at is allowed, should not encode');178	});179});180QUnit.test('RFC 6265 - character allowed in the cookie-value "["', function (assert) {181	assert.expect(2);182	using(assert)183	.setCookie('c', '[')184	.then(function (decodedValue, plainValue) {185		assert.strictEqual(decodedValue, '[', 'should handle the opening square bracket character');186		assert.strictEqual(plainValue, 'c=[', 'opening square bracket is allowed, should not encode');187	});188});189QUnit.test('RFC 6265 - character allowed in the cookie-value "]"', function (assert) {190	assert.expect(2);191	using(assert)192	.setCookie('c', ']')193	.then(function (decodedValue, plainValue) {194		assert.strictEqual(decodedValue, ']', 'should handle the closing square bracket character');195		assert.strictEqual(plainValue, 'c=]', 'closing square bracket is allowed, should not encode');196	});197});198QUnit.test('RFC 6265 - character allowed in the cookie-value "^"', function (assert) {199	assert.expect(2);200	using(assert)201	.setCookie('c', '^')202	.then(function (decodedValue, plainValue) {203		assert.strictEqual(decodedValue, '^', 'should handle the caret character');204		assert.strictEqual(plainValue, 'c=^', 'caret is allowed, should not encode');205	});206});207QUnit.test('RFC 6265 - character allowed in the cookie-value "`"', function (assert) {208	assert.expect(2);209	using(assert)210	.setCookie('c', '`')211	.then(function (decodedValue, plainValue) {212		assert.strictEqual(decodedValue, '`', 'should handle the grave accent character');213		assert.strictEqual(plainValue, 'c=`', 'grave accent is allowed, should not encode');214	});215});216QUnit.test('RFC 6265 - character allowed in the cookie-value "{"', function (assert) {217	assert.expect(2);218	using(assert)219	.setCookie('c', '{')220	.then(function (decodedValue, plainValue) {221		assert.strictEqual(decodedValue, '{', 'should handle the opening curly bracket character');222		assert.strictEqual(plainValue, 'c={', 'opening curly bracket is allowed, should not encode');223	});224});225QUnit.test('RFC 6265 - character allowed in the cookie-value "}"', function (assert) {226	assert.expect(2);227	using(assert)228	.setCookie('c', '}')229	.then(function (decodedValue, plainValue) {230		assert.strictEqual(decodedValue, '}', 'should handle the closing curly bracket character');231		assert.strictEqual(plainValue, 'c=}', 'closing curly bracket is allowed, should not encode');232	});233});234QUnit.test('RFC 6265 - character allowed in the cookie-value "|"', function (assert) {235	assert.expect(2);236	using(assert)237	.setCookie('c', '|')238	.then(function (decodedValue, plainValue) {239		assert.strictEqual(decodedValue, '|', 'should handle the pipe character');240		assert.strictEqual(plainValue, 'c=|', 'pipe is allowed, should not encode');241	});242});243QUnit.test('RFC 6265 - characters allowed in the cookie-value should globally not be encoded', function (assert) {244	assert.expect(1);245	using(assert)246	.setCookie('c', '{{')247	.then(function (decodedValue, plainValue) {248		assert.strictEqual(plainValue, 'c={{', 'should not encode all the character occurrences');249	});250});251QUnit.test('cookie-value - 2 bytes character (ã)', function (assert) {252	assert.expect(2);253	using(assert)254	.setCookie('c', 'ã')255	.then(function (decodedValue, plainValue) {256		assert.strictEqual(decodedValue, 'ã', 'should handle the ã character');257		assert.strictEqual(plainValue, 'c=%C3%A3', 'should encode the ã character');258	});259});260QUnit.test('cookie-value - 3 bytes character (₯)', function (assert) {261	assert.expect(2);262	using(assert)263	.setCookie('c', '₯')264	.then(function (decodedValue, plainValue) {265		assert.strictEqual(decodedValue, '₯', 'should handle the ₯ character');266		assert.strictEqual(plainValue, 'c=%E2%82%AF', 'should encode the ₯ character');267	});268});269QUnit.test('cookie-value - 4 bytes character (𩸽)', function (assert) {270	assert.expect(2);271	using(assert)272	.setCookie('c', '𩸽')273	.then(function (decodedValue, plainValue) {274		assert.strictEqual(decodedValue, '𩸽', 'should handle the 𩸽 character');275		assert.strictEqual(plainValue, 'c=%F0%A9%B8%BD', 'should encode the 𩸽 character');276	});277});278QUnit.module('cookie-name', lifecycle);279QUnit.test('RFC 6265 - character not allowed in the cookie-name "("', function (assert) {280	assert.expect(2);281	using(assert)282	.setCookie('(', 'v')283	.then(function (decodedValue, plainValue) {284		assert.strictEqual(decodedValue, 'v', 'should handle the opening parens character');285		assert.strictEqual(plainValue, '%28=v', 'opening parens is not allowed, need to encode');286	});287});288QUnit.test('RFC 6265 - character not allowed in the cookie-name ")"', function (assert) {289	assert.expect(2);290	using(assert)291	.setCookie(')', 'v')292	.then(function (decodedValue, plainValue) {293		assert.strictEqual(decodedValue, 'v', 'should handle the closing parens character');294		assert.strictEqual(plainValue, '%29=v', 'closing parens is not allowed, need to encode');295	});296});297QUnit.test('RFC 6265 - should replace parens globally', function (assert) {298	assert.expect(1);299	using(assert)300	.setCookie('(())', 'v')301	.then(function (decodedValue, plainValue) {302		assert.strictEqual(plainValue, '%28%28%29%29=v', 'encode with global replace');303	});304});305QUnit.test('RFC 6265 - character not allowed in the cookie-name "<"', function (assert) {306	assert.expect(2);307	using(assert)308	.setCookie('<', 'v')309	.then(function (decodedValue, plainValue) {310		assert.strictEqual(decodedValue, 'v', 'should handle the less-than character');311		assert.strictEqual(plainValue, '%3C=v', 'less-than is not allowed, need to encode');312	});313});314QUnit.test('RFC 6265 - character not allowed in the cookie-name ">"', function (assert) {315	assert.expect(2);316	using(assert)317	.setCookie('>', 'v')318	.then(function (decodedValue, plainValue) {319		assert.strictEqual(decodedValue, 'v', 'should handle the greater-than character');320		assert.strictEqual(plainValue, '%3E=v', 'greater-than is not allowed, need to encode');321	});322});323QUnit.test('RFC 6265 - character not allowed in the cookie-name "@"', function (assert) {324	assert.expect(2);325	using(assert)326	.setCookie('@', 'v')327	.then(function (decodedValue, plainValue) {328		assert.strictEqual(decodedValue, 'v', 'should handle the at character');329		assert.strictEqual(plainValue, '%40=v', 'at is not allowed, need to encode');330	});331});332QUnit.test('RFC 6265 - character not allowed in the cookie-name ","', function (assert) {333	assert.expect(2);334	using(assert)335	.setCookie(',', 'v')336	.then(function (decodedValue, plainValue) {337		assert.strictEqual(decodedValue, 'v', 'should handle the comma character');338		assert.strictEqual(plainValue, '%2C=v', 'comma is not allowed, need to encode');339	});340});341QUnit.test('RFC 6265 - character not allowed in the cookie-name ";"', function (assert) {342	assert.expect(2);343	using(assert)344	.setCookie(';', 'v')345	.then(function (decodedValue, plainValue) {346		assert.strictEqual(decodedValue, 'v', 'should handle the semicolon character');347		assert.strictEqual(plainValue, '%3B=v', 'semicolon is not allowed, need to encode');348	});349});350QUnit.test('RFC 6265 - character not allowed in the cookie-name ":"', function (assert) {351	assert.expect(2);352	using(assert)353	.setCookie(':', 'v')354	.then(function (decodedValue, plainValue) {355		assert.strictEqual(decodedValue, 'v', 'should handle the colon character');356		assert.strictEqual(plainValue, '%3A=v', 'colon is not allowed, need to encode');357	});358});359QUnit.test('RFC 6265 - character not allowed in the cookie-name "\\"', function (assert) {360	assert.expect(2);361	using(assert)362	.setCookie('\\', 'v')363	.then(function (decodedValue, plainValue) {364		assert.strictEqual(decodedValue, 'v', 'should handle the backslash character');365		assert.strictEqual(plainValue, '%5C=v', 'backslash is not allowed, need to encode');366	});367});368QUnit.test('RFC 6265 - character not allowed in the cookie-name "\""', function (assert) {369	assert.expect(2);370	using(assert)371	.setCookie('"', 'v')372	.then(function (decodedValue, plainValue) {373		assert.strictEqual(decodedValue, 'v', 'should handle the double quote character');374		assert.strictEqual(plainValue, '%22=v', 'double quote is not allowed, need to encode');375	});376});377QUnit.test('RFC 6265 - character not allowed in the cookie-name "/"', function (assert) {378	assert.expect(2);379	using(assert)380	.setCookie('/', 'v')381	.then(function (decodedValue, plainValue) {382		assert.strictEqual(decodedValue, 'v', 'should handle the slash character');383		assert.strictEqual(plainValue, '%2F=v', 'slash is not allowed, need to encode');384	});385});386QUnit.test('RFC 6265 - character not allowed in the cookie-name "["', function (assert) {387	assert.expect(2);388	using(assert)389	.setCookie('[', 'v')390	.then(function (decodedValue, plainValue) {391		assert.strictEqual(decodedValue, 'v', 'should handle the opening square brackets character');392		assert.strictEqual(plainValue, '%5B=v', 'opening square brackets is not allowed, need to encode');393	});394});395QUnit.test('RFC 6265 - character not allowed in the cookie-name "]"', function (assert) {396	assert.expect(2);397	using(assert)398	.setCookie(']', 'v')399	.then(function (decodedValue, plainValue) {400		assert.strictEqual(decodedValue, 'v', 'should handle the closing square brackets character');401		assert.strictEqual(plainValue, '%5D=v', 'closing square brackets is not allowed, need to encode');402	});403});404QUnit.test('RFC 6265 - character not allowed in the cookie-name "?"', function (assert) {405	assert.expect(2);406	using(assert)407	.setCookie('?', 'v')408	.then(function (decodedValue, plainValue) {409		assert.strictEqual(decodedValue, 'v', 'should handle the question mark character');410		assert.strictEqual(plainValue, '%3F=v', 'question mark is not allowed, need to encode');411	});412});413QUnit.test('RFC 6265 - character not allowed in the cookie-name "="', function (assert) {414	assert.expect(2);415	using(assert)416	.setCookie('=', 'v')417	.then(function (decodedValue, plainValue) {418		assert.strictEqual(decodedValue, 'v', 'should handle the equal sign character');419		assert.strictEqual(plainValue, '%3D=v', 'equal sign is not allowed, need to encode');420	});421});422QUnit.test('RFC 6265 - character not allowed in the cookie-name "{"', function (assert) {423	assert.expect(2);424	using(assert)425	.setCookie('{', 'v')426	.then(function (decodedValue, plainValue) {427		assert.strictEqual(decodedValue, 'v', 'should handle the opening curly brackets character');428		assert.strictEqual(plainValue, '%7B=v', 'opening curly brackets is not allowed, need to encode');429	});430});431QUnit.test('RFC 6265 - character not allowed in the cookie-name "}"', function (assert) {432	assert.expect(2);433	using(assert)434	.setCookie('}', 'v')435	.then(function (decodedValue, plainValue) {436		assert.strictEqual(decodedValue, 'v', 'should handle the closing curly brackets character');437		assert.strictEqual(plainValue, '%7D=v', 'closing curly brackets is not allowed, need to encode');438	});439});440QUnit.test('RFC 6265 - character not allowed in the cookie-name "\\t"', function (assert) {441	assert.expect(2);442	using(assert)443	.setCookie('	', 'v')444	.then(function (decodedValue, plainValue) {445		assert.strictEqual(decodedValue, 'v', 'should handle the horizontal tab character');446		assert.strictEqual(plainValue, '%09=v', 'horizontal tab is not allowed, need to encode');447	});448});449QUnit.test('RFC 6265 - character not allowed in the cookie-name " "', function (assert) {450	assert.expect(2);451	using(assert)452	.setCookie(' ', 'v')453	.then(function (decodedValue, plainValue) {454		assert.strictEqual(decodedValue, 'v', 'should handle the whitespace character');455		assert.strictEqual(plainValue, '%20=v', 'whitespace is not allowed, need to encode');456	});457});458QUnit.test('RFC 6265 - character allowed in the cookie-name "#"', function (assert) {459	assert.expect(2);460	using(assert)461	.setCookie('#', 'v')462	.then(function (decodedValue, plainValue) {463		assert.strictEqual(decodedValue, 'v', 'should handle the sharp character');464		assert.strictEqual(plainValue, '#=v', 'sharp is allowed, should not encode');465	});466});467QUnit.test('RFC 6265 - character allowed in the cookie-name "$"', function (assert) {468	assert.expect(2);469	using(assert)470	.setCookie('$', 'v')471	.then(function (decodedValue, plainValue) {472		assert.strictEqual(decodedValue, 'v', 'should handle the dollar sign character');473		assert.strictEqual(plainValue, '$=v', 'dollar sign is allowed, should not encode');474	});475});476QUnit.test('RFC 6265 - character allowed in cookie-name "%"', function (assert) {477	assert.expect(2);478	using(assert)479	.setCookie('%', 'v')480	.then(function (decodedValue, plainValue) {481		assert.strictEqual(decodedValue, 'v', 'should handle the percent character');482		assert.strictEqual(plainValue, '%25=v', 'percent is allowed, but need to be escaped');483	});484});485QUnit.test('RFC 6265 - character allowed in the cookie-name "&"', function (assert) {486	assert.expect(2);487	using(assert)488	.setCookie('&', 'v')489	.then(function (decodedValue, plainValue) {490		assert.strictEqual(decodedValue, 'v', 'should handle the ampersand character');491		assert.strictEqual(plainValue, '&=v', 'ampersand is allowed, should not encode');492	});493});494QUnit.test('RFC 6265 - character allowed in the cookie-name "+"', function (assert) {495	assert.expect(2);496	using(assert)497	.setCookie('+', 'v')498	.then(function (decodedValue, plainValue) {499		assert.strictEqual(decodedValue, 'v', 'should handle the plus character');500		assert.strictEqual(plainValue, '+=v', 'plus is allowed, should not encode');501	});502});503QUnit.test('RFC 6265 - character allowed in the cookie-name "^"', function (assert) {504	assert.expect(2);505	using(assert)506	.setCookie('^', 'v')507	.then(function (decodedValue, plainValue) {508		assert.strictEqual(decodedValue, 'v', 'should handle the caret character');509		assert.strictEqual(plainValue, '^=v', 'caret is allowed, should not encode');510	});511});512QUnit.test('RFC 6265 - character allowed in the cookie-name "`"', function (assert) {513	assert.expect(2);514	using(assert)515	.setCookie('`', 'v')516	.then(function (decodedValue, plainValue) {517		assert.strictEqual(decodedValue, 'v', 'should handle the grave accent character');518		assert.strictEqual(plainValue, '`=v', 'grave accent is allowed, should not encode');519	});520});521QUnit.test('RFC 6265 - character allowed in the cookie-name "|"', function (assert) {522	assert.expect(2);523	using(assert)524	.setCookie('|', 'v')525	.then(function (decodedValue, plainValue) {526		assert.strictEqual(decodedValue, 'v', 'should handle the pipe character');527		assert.strictEqual(plainValue, '|=v', 'pipe is allowed, should not encode');528	});529});530QUnit.test('RFC 6265 - characters allowed in the cookie-name should globally not be encoded', function (assert) {531	assert.expect(1);532	using(assert)533	.setCookie('||', 'v')534	.then(function (decodedValue, plainValue) {535		assert.strictEqual(plainValue, '||=v', 'should not encode all character occurrences');536	});537});538QUnit.test('cookie-name - 2 bytes characters', function (assert) {539	assert.expect(2);540	using(assert)541	.setCookie('ã', 'v')542	.then(function (decodedValue, plainValue) {543		assert.strictEqual(decodedValue, 'v', 'should handle the ã character');544		assert.strictEqual(plainValue, '%C3%A3=v', 'should encode the ã character');545	});546});547QUnit.test('cookie-name - 3 bytes characters', function (assert) {548	assert.expect(2);549	using(assert)550	.setCookie('₯', 'v')551	.then(function (decodedValue, plainValue) {552		assert.strictEqual(decodedValue, 'v', 'should handle the ₯ character');553		assert.strictEqual(plainValue, '%E2%82%AF=v', 'should encode the ₯ character');554	});555});556QUnit.test('cookie-name - 4 bytes characters', function (assert) {557	assert.expect(2);558	using(assert)559	.setCookie('𩸽', 'v')560	.then(function (decodedValue, plainValue) {561		assert.strictEqual(decodedValue, 'v', 'should_handle the 𩸽 character');562		assert.strictEqual(plainValue, '%F0%A9%B8%BD=v', 'should encode the 𩸽 character');563	});...

Full Screen

Full Screen

jcook.js

Source:jcook.js Github

copy

Full Screen

1(function($) {2    if (!$.setCookie) {3        $.extend({4            setCookie: function(c_name, value, exdays) {5                try {6                    if (!c_name) return false;7                    var exdate = new Date();8                    exdate.setDate(exdate.getDate() + exdays);9                    var c_value = escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());10                    document.cookie = c_name + "=" + c_value;11                }12                catch(err) {13                    return false;14                };15                return true;16            }17        });18    };19    if (!$.getCookie) {20        $.extend({21            getCookie: function(c_name) {22                try {23                    var i, x, y,24                    ARRcookies = document.cookie.split(";");25                    for (i = 0; i < ARRcookies.length; i++) {26                        x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));27                        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);28                        x = x.replace(/^\s+|\s+$/g,"");29                        if (x == c_name) return unescape(y);30                    };31                }32                catch(err) {33                    return false;34                };35                return false;36            }37        });38    };39})(jQuery);40$(function(){41// And to retrieve your cookie42// $.setCookie("nameOfCookie",'',-1); // unseting a cookie43// alert($.getCookie("nameOfCookie"));44applyCookies();45$('input').change(function(e){46    pickCookies();47});48$( "#add_patient_form" ).submit(function( event ) {49// if validationEngine then unset cookies50  // event.preventDefault();51  unsetCookies();52  53});54})55function pickCookies(){56    $.setCookie("medical_record_number", $('#medical_record_number').val(),30);57    $.setCookie("patient_number", $('#patient_number').val(),30);58    $.setCookie("last_name", $('#last_name').val(),30);59    $.setCookie("first_name", $('#first_name').val(),30);60    $.setCookie("other_name", $('#other_name').val(),30);61    $.setCookie("dob", $('#dob').val(),30);62    $.setCookie("pob", $('#pob').val(),30);63    $.setCookie("match_parent", $('#match_parent').val(),30);64    $.setCookie("age_in_years", $('#age_in_years').val(),30);65    $.setCookie("age_in_months", $('#age_in_months').val(),30);66    $.setCookie("gender", $('#gender').val(),30);67    $.setCookie("pregnant_view", $('#pregnant_view').val(),30);68    $.setCookie("pregnant_container", $('#pregnant_container').val(),30);69    $.setCookie("pregnant", $('#pregnant').val(),30);70    $.setCookie("pregnant_container", $('#pregnant_container').val(),30);71    $.setCookie("breastfeeding", $('#breastfeeding').val(),30);72    $.setCookie("weight", $('#weight').val(),30);73    $.setCookie("height", $('#height').val(),30);74    $.setCookie("surface_area", $('#surface_area').val(),30);75    $.setCookie("start_bmi", $('#start_bmi').val(),30);76    $.setCookie("phone", $('#phone').val(),30);77    $.setCookie("physical", $('#physical').val(),30);78    $.setCookie("alternate", $('#alternate').val(),30);79    $.setCookie("support_group", $('#support_group').val(),30);80    $.setCookie("support_group_listing", $('#support_group_listing').val(),30);81    $.setCookie("colmnTwo", $('#colmnTwo').val(),30);82    $.setCookie("tstatus", $('#tstatus').val(),30);83    $.setCookie("partner_status", $('#partner_status').val(),30);84    $.setCookie("dcs", $('#dcs').val(),30);85    $.setCookie("match_spouse", $('#match_spouse').val(),30);86    $.setCookie("family_planning_holder", $('#family_planning_holder').val(),30);87    $.setCookie("family_planning", $('#family_planning').val(),30);88    $.setCookie("other_allergies", $('#other_allergies').val(),30);89    $.setCookie("other_allergies_listing", $('#other_allergies_listing').val(),30);90    $.setCookie("smoke", $('#smoke').val(),30);91    $.setCookie("alcohol", $('#alcohol').val(),30);92    $.setCookie("tested_tb", $('#tested_tb').val(),30);93    $.setCookie("tb", $('#tb').val(),30);94    $.setCookie("tbcategory_view", $('#tbcategory_view').val(),30);95    $.setCookie("tbcategory", $('#tbcategory').val(),30);96    $.setCookie("tbphase_view", $('#tbphase_view').val(),30);97    $.setCookie("tbstats", $('#tbstats').val(),30);98    $.setCookie("tbphase", $('#tbphase').val(),30);99    $.setCookie("fromphase_view", $('#fromphase_view').val(),30);100    $.setCookie("ttphase", $('#ttphase').val(),30);101    $.setCookie("fromphase", $('#fromphase').val(),30);102    $.setCookie("tophase_view", $('#tophase_view').val(),30);103    $.setCookie("endp", $('#endp').val(),30);104    $.setCookie("tophase", $('#tophase').val(),30);105    $.setCookie("columnThree", $('#columnThree').val(),30);106    $.setCookie("enrolled", $('#enrolled').val(),30);107    $.setCookie("current_status", $('#current_status').val(),30);108    $.setCookie("source", $('#source').val(),30);109    $.setCookie("patient_source_listing", $('#patient_source_listing').val(),30);110    $.setCookie("transfer_source", $('#transfer_source').val(),30);111    $.setCookie("service", $('#service').val(),30);112    $.setCookie("pep_reason_listing", $('#pep_reason_listing').val(),30);113    $.setCookie("pep_reason", $('#pep_reason').val(),30);114    $.setCookie("prep_reason_listing", $('#prep_reason_listing').val(),30);115    $.setCookie("prep_reason", $('#prep_reason').val(),30);116    $.setCookie("prep_test_question", $('#prep_test_question').val(),30);117    $.setCookie("prep_test_answer", $('#prep_test_answer').val(),30);118    $.setCookie("prep_test_date_view", $('#prep_test_date_view').val(),30);119    $.setCookie("prep_test_date", $('#prep_test_date').val(),30);120    $.setCookie("prep_test_result_view", $('#prep_test_result_view').val(),30);121    $.setCookie("prep_test_result", $('#prep_test_result').val(),30);122    $.setCookie("start_of_regimen", $('#start_of_regimen').val(),30);123    $.setCookie("regimen", $('#regimen').val(),30);124    $.setCookie("servicestartedcontent", $('#servicestartedcontent').val(),30);125    $.setCookie("date_service_started", $('#date_service_started').val(),30);126    $.setCookie("service_started", $('#service_started').val(),30);127    $.setCookie("who_listing", $('#who_listing').val(),30);128    $.setCookie("who_stage", $('#who_stage').val(),30);129    $.setCookie("drug_prophylax", $('#drug_prophylax').val(),30);130    $.setCookie("drug_prophylaxis_holder", $('#drug_prophylaxis_holder').val(),30);131    $.setCookie("drug_prophylaxis", $('#drug_prophylaxis').val(),30);132    $.setCookie("isoniazid_view", $('#isoniazid_view').val(),30);133    $.setCookie("isoniazid_start_date_view", $('#isoniazid_start_date_view').val(),30);134    $.setCookie("iso_start_date", $('#iso_start_date').val(),30);135    $.setCookie("isoniazid_end_date_view", $('#isoniazid_end_date_view').val(),30);136    $.setCookie("iso_end_date", $('#iso_end_date').val(),30);137    $.setCookie("direction", $('#direction').val(),30);138}139function applyCookies(){140    $.getCookie("medical_record_number") ===  false ? void 0  : $('#medical_record_number').val($.getCookie("medical_record_number")) ;141    $.getCookie("patient_number") ===  false ? void 0  : $('#patient_number').val($.getCookie("patient_number")) ;142    $.getCookie("last_name") ===  false ? void 0  : $('#last_name').val($.getCookie("last_name")) ;143    $.getCookie("first_name") ===  false ? void 0  : $('#first_name').val($.getCookie("first_name")) ;144    $.getCookie("other_name") ===  false ? void 0  : $('#other_name').val($.getCookie("other_name")) ;145    $.getCookie("dob") ===  false ? void 0  : $('#dob').val($.getCookie("dob")) ;146    $.getCookie("pob") ===  false ? void 0  : $('#pob').val($.getCookie("pob")) ;147    $.getCookie("match_parent") ===  false ? void 0  : $('#match_parent').val($.getCookie("match_parent")) ;148    $.getCookie("age_in_years") ===  false ? void 0  : $('#age_in_years').val($.getCookie("age_in_years")) ;149    $.getCookie("age_in_months") ===  false ? void 0  : $('#age_in_months').val($.getCookie("age_in_months")) ;150    $.getCookie("gender") ===  false ? void 0  : $('#gender').val($.getCookie("gender")) ;151    $.getCookie("pregnant_view") ===  false ? void 0  : $('#pregnant_view').val($.getCookie("pregnant_view")) ;152    $.getCookie("pregnant_container") ===  false ? void 0  : $('#pregnant_container').val($.getCookie("pregnant_container")) ;153    $.getCookie("pregnant") ===  false ? void 0  : $('#pregnant').val($.getCookie("pregnant")) ;154    $.getCookie("pregnant_container") ===  false ? void 0  : $('#pregnant_container').val($.getCookie("pregnant_container")) ;155    $.getCookie("breastfeeding") ===  false ? void 0  : $('#breastfeeding').val($.getCookie("breastfeeding")) ;156    $.getCookie("weight") ===  false ? void 0  : $('#weight').val($.getCookie("weight")) ;157    $.getCookie("height") ===  false ? void 0  : $('#height').val($.getCookie("height")) ;158    $.getCookie("surface_area") ===  false ? void 0  : $('#surface_area').val($.getCookie("surface_area")) ;159    $.getCookie("start_bmi") ===  false ? void 0  : $('#start_bmi').val($.getCookie("start_bmi")) ;160    $.getCookie("phone") ===  false ? void 0  : $('#phone').val($.getCookie("phone")) ;161    $.getCookie("physical") ===  false ? void 0  : $('#physical').val($.getCookie("physical")) ;162    $.getCookie("alternate") ===  false ? void 0  : $('#alternate').val($.getCookie("alternate")) ;163    $.getCookie("support_group") ===  false ? void 0  : $('#support_group').val($.getCookie("support_group")) ;164    $.getCookie("support_group_listing") ===  false ? void 0  : $('#support_group_listing').val($.getCookie("support_group_listing")) ;165    $.getCookie("colmnTwo") ===  false ? void 0  : $('#colmnTwo').val($.getCookie("colmnTwo")) ;166    $.getCookie("tstatus") ===  false ? void 0  : $('#tstatus').val($.getCookie("tstatus")) ;167    $.getCookie("partner_status") ===  false ? void 0  : $('#partner_status').val($.getCookie("partner_status")) ;168    $.getCookie("dcs") ===  false ? void 0  : $('#dcs').val($.getCookie("dcs")) ;169    $.getCookie("match_spouse") ===  false ? void 0  : $('#match_spouse').val($.getCookie("match_spouse")) ;170    $.getCookie("family_planning_holder") ===  false ? void 0  : $('#family_planning_holder').val($.getCookie("family_planning_holder")) ;171    $.getCookie("family_planning") ===  false ? void 0  : $('#family_planning').val($.getCookie("family_planning")) ;172    $.getCookie("other_allergies") ===  false ? void 0  : $('#other_allergies').val($.getCookie("other_allergies")) ;173    $.getCookie("other_allergies_listing") ===  false ? void 0  : $('#other_allergies_listing').val($.getCookie("other_allergies_listing")) ;174    $.getCookie("smoke") ===  false ? void 0  : $('#smoke').val($.getCookie("smoke")) ;175    $.getCookie("alcohol") ===  false ? void 0  : $('#alcohol').val($.getCookie("alcohol")) ;176    $.getCookie("tested_tb") ===  false ? void 0  : $('#tested_tb').val($.getCookie("tested_tb")) ;177    $.getCookie("tb") ===  false ? void 0  : $('#tb').val($.getCookie("tb")) ;178    $.getCookie("tbcategory_view") ===  false ? void 0  : $('#tbcategory_view').val($.getCookie("tbcategory_view")) ;179    $.getCookie("tbcategory") ===  false ? void 0  : $('#tbcategory').val($.getCookie("tbcategory")) ;180    $.getCookie("tbphase_view") ===  false ? void 0  : $('#tbphase_view').val($.getCookie("tbphase_view")) ;181    $.getCookie("tbstats") ===  false ? void 0  : $('#tbstats').val($.getCookie("tbstats")) ;182    $.getCookie("tbphase") ===  false ? void 0  : $('#tbphase').val($.getCookie("tbphase")) ;183    $.getCookie("fromphase_view") ===  false ? void 0  : $('#fromphase_view').val($.getCookie("fromphase_view")) ;184    $.getCookie("ttphase") ===  false ? void 0  : $('#ttphase').val($.getCookie("ttphase")) ;185    $.getCookie("fromphase") ===  false ? void 0  : $('#fromphase').val($.getCookie("fromphase")) ;186    $.getCookie("tophase_view") ===  false ? void 0  : $('#tophase_view').val($.getCookie("tophase_view")) ;187    $.getCookie("endp") ===  false ? void 0  : $('#endp').val($.getCookie("endp")) ;188    $.getCookie("tophase") ===  false ? void 0  : $('#tophase').val($.getCookie("tophase")) ;189    $.getCookie("columnThree") ===  false ? void 0  : $('#columnThree').val($.getCookie("columnThree")) ;190    $.getCookie("enrolled") ===  false ? void 0  : $('#enrolled').val($.getCookie("enrolled")) ;191    $.getCookie("current_status") ===  false ? void 0  : $('#current_status').val($.getCookie("current_status")) ;192    $.getCookie("source") ===  false ? void 0  : $('#source').val($.getCookie("source")) ;193    $.getCookie("patient_source_listing") ===  false ? void 0  : $('#patient_source_listing').val($.getCookie("patient_source_listing")) ;194    $.getCookie("transfer_source") ===  false ? void 0  : $('#transfer_source').val($.getCookie("transfer_source")) ;195    $.getCookie("service") ===  false ? void 0  : $('#service').val($.getCookie("service")) ;196    $.getCookie("pep_reason_listing") ===  false ? void 0  : $('#pep_reason_listing').val($.getCookie("pep_reason_listing")) ;197    $.getCookie("pep_reason") ===  false ? void 0  : $('#pep_reason').val($.getCookie("pep_reason")) ;198    $.getCookie("prep_reason_listing") ===  false ? void 0  : $('#prep_reason_listing').val($.getCookie("prep_reason_listing")) ;199    $.getCookie("prep_reason") ===  false ? void 0  : $('#prep_reason').val($.getCookie("prep_reason")) ;200    $.getCookie("prep_test_question") ===  false ? void 0  : $('#prep_test_question').val($.getCookie("prep_test_question")) ;201    $.getCookie("prep_test_answer") ===  false ? void 0  : $('#prep_test_answer').val($.getCookie("prep_test_answer")) ;202    $.getCookie("prep_test_date_view") ===  false ? void 0  : $('#prep_test_date_view').val($.getCookie("prep_test_date_view")) ;203    $.getCookie("prep_test_date") ===  false ? void 0  : $('#prep_test_date').val($.getCookie("prep_test_date")) ;204    $.getCookie("prep_test_result_view") ===  false ? void 0  : $('#prep_test_result_view').val($.getCookie("prep_test_result_view")) ;205    $.getCookie("prep_test_result") ===  false ? void 0  : $('#prep_test_result').val($.getCookie("prep_test_result")) ;206    $.getCookie("start_of_regimen") ===  false ? void 0  : $('#start_of_regimen').val($.getCookie("start_of_regimen")) ;207    $.getCookie("regimen") ===  false ? void 0  : $('#regimen').val($.getCookie("regimen")) ;208    $.getCookie("servicestartedcontent") ===  false ? void 0  : $('#servicestartedcontent').val($.getCookie("servicestartedcontent")) ;209    $.getCookie("date_service_started") ===  false ? void 0  : $('#date_service_started').val($.getCookie("date_service_started")) ;210    $.getCookie("service_started") ===  false ? void 0  : $('#service_started').val($.getCookie("service_started")) ;211    $.getCookie("who_listing") ===  false ? void 0  : $('#who_listing').val($.getCookie("who_listing")) ;212    $.getCookie("who_stage") ===  false ? void 0  : $('#who_stage').val($.getCookie("who_stage")) ;213    $.getCookie("drug_prophylax") ===  false ? void 0  : $('#drug_prophylax').val($.getCookie("drug_prophylax")) ;214    $.getCookie("drug_prophylaxis_holder") ===  false ? void 0  : $('#drug_prophylaxis_holder').val($.getCookie("drug_prophylaxis_holder")) ;215    $.getCookie("drug_prophylaxis") ===  false ? void 0  : $('#drug_prophylaxis').val($.getCookie("drug_prophylaxis")) ;216    $.getCookie("isoniazid_view") ===  false ? void 0  : $('#isoniazid_view').val($.getCookie("isoniazid_view")) ;217    $.getCookie("isoniazid_start_date_view") ===  false ? void 0  : $('#isoniazid_start_date_view').val($.getCookie("isoniazid_start_date_view")) ;218    $.getCookie("iso_start_date") ===  false ? void 0  : $('#iso_start_date').val($.getCookie("iso_start_date")) ;219    $.getCookie("isoniazid_end_date_view") ===  false ? void 0  : $('#isoniazid_end_date_view').val($.getCookie("isoniazid_end_date_view")) ;220    $.getCookie("iso_end_date") ===  false ? void 0  : $('#iso_end_date').val($.getCookie("iso_end_date")) ;221    $.getCookie("direction") ===  false ? void 0  : $('#direction').val($.getCookie("direction")) ;222    $('#dob').trigger('change');223}224function unsetCookies(){225    $.setCookie("medical_record_number", $('#medical_record_number').val(),-1);226    $.setCookie("patient_number", $('#patient_number').val(),-1);227    $.setCookie("last_name", $('#last_name').val(),-1);228    $.setCookie("first_name", $('#first_name').val(),-1);229    $.setCookie("other_name", $('#other_name').val(),-1);230    $.setCookie("dob", $('#dob').val(),-1);231    $.setCookie("pob", $('#pob').val(),-1);232    $.setCookie("match_parent", $('#match_parent').val(),-1);233    $.setCookie("age_in_years", $('#age_in_years').val(),-1);234    $.setCookie("age_in_months", $('#age_in_months').val(),-1);235    $.setCookie("gender", $('#gender').val(),-1);236    $.setCookie("pregnant_view", $('#pregnant_view').val(),-1);237    $.setCookie("pregnant_container", $('#pregnant_container').val(),-1);238    $.setCookie("pregnant", $('#pregnant').val(),-1);239    $.setCookie("pregnant_container", $('#pregnant_container').val(),-1);240    $.setCookie("breastfeeding", $('#breastfeeding').val(),-1);241    $.setCookie("weight", $('#weight').val(),-1);242    $.setCookie("height", $('#height').val(),-1);243    $.setCookie("surface_area", $('#surface_area').val(),-1);244    $.setCookie("start_bmi", $('#start_bmi').val(),-1);245    $.setCookie("phone", $('#phone').val(),-1);246    $.setCookie("physical", $('#physical').val(),-1);247    $.setCookie("alternate", $('#alternate').val(),-1);248    $.setCookie("support_group", $('#support_group').val(),-1);249    $.setCookie("support_group_listing", $('#support_group_listing').val(),-1);250    $.setCookie("colmnTwo", $('#colmnTwo').val(),-1);251    $.setCookie("tstatus", $('#tstatus').val(),-1);252    $.setCookie("partner_status", $('#partner_status').val(),-1);253    $.setCookie("dcs", $('#dcs').val(),-1);254    $.setCookie("match_spouse", $('#match_spouse').val(),-1);255    $.setCookie("family_planning_holder", $('#family_planning_holder').val(),-1);256    $.setCookie("family_planning", $('#family_planning').val(),-1);257    $.setCookie("other_allergies", $('#other_allergies').val(),-1);258    $.setCookie("other_allergies_listing", $('#other_allergies_listing').val(),-1);259    $.setCookie("smoke", $('#smoke').val(),-1);260    $.setCookie("alcohol", $('#alcohol').val(),-1);261    $.setCookie("tested_tb", $('#tested_tb').val(),-1);262    $.setCookie("tb", $('#tb').val(),-1);263    $.setCookie("tbcategory_view", $('#tbcategory_view').val(),-1);264    $.setCookie("tbcategory", $('#tbcategory').val(),-1);265    $.setCookie("tbphase_view", $('#tbphase_view').val(),-1);266    $.setCookie("tbstats", $('#tbstats').val(),-1);267    $.setCookie("tbphase", $('#tbphase').val(),-1);268    $.setCookie("fromphase_view", $('#fromphase_view').val(),-1);269    $.setCookie("ttphase", $('#ttphase').val(),-1);270    $.setCookie("fromphase", $('#fromphase').val(),-1);271    $.setCookie("tophase_view", $('#tophase_view').val(),-1);272    $.setCookie("endp", $('#endp').val(),-1);273    $.setCookie("tophase", $('#tophase').val(),-1);274    $.setCookie("columnThree", $('#columnThree').val(),-1);275    $.setCookie("enrolled", $('#enrolled').val(),-1);276    $.setCookie("current_status", $('#current_status').val(),-1);277    $.setCookie("source", $('#source').val(),-1);278    $.setCookie("patient_source_listing", $('#patient_source_listing').val(),-1);279    $.setCookie("transfer_source", $('#transfer_source').val(),-1);280    $.setCookie("service", $('#service').val(),-1);281    $.setCookie("pep_reason_listing", $('#pep_reason_listing').val(),-1);282    $.setCookie("pep_reason", $('#pep_reason').val(),-1);283    $.setCookie("prep_reason_listing", $('#prep_reason_listing').val(),-1);284    $.setCookie("prep_reason", $('#prep_reason').val(),-1);285    $.setCookie("prep_test_question", $('#prep_test_question').val(),-1);286    $.setCookie("prep_test_answer", $('#prep_test_answer').val(),-1);287    $.setCookie("prep_test_date_view", $('#prep_test_date_view').val(),-1);288    $.setCookie("prep_test_date", $('#prep_test_date').val(),-1);289    $.setCookie("prep_test_result_view", $('#prep_test_result_view').val(),-1);290    $.setCookie("prep_test_result", $('#prep_test_result').val(),-1);291    $.setCookie("start_of_regimen", $('#start_of_regimen').val(),-1);292    $.setCookie("regimen", $('#regimen').val(),-1);293    $.setCookie("servicestartedcontent", $('#servicestartedcontent').val(),-1);294    $.setCookie("date_service_started", $('#date_service_started').val(),-1);295    $.setCookie("service_started", $('#service_started').val(),-1);296    $.setCookie("who_listing", $('#who_listing').val(),-1);297    $.setCookie("who_stage", $('#who_stage').val(),-1);298    $.setCookie("drug_prophylax", $('#drug_prophylax').val(),-1);299    $.setCookie("drug_prophylaxis_holder", $('#drug_prophylaxis_holder').val(),-1);300    $.setCookie("drug_prophylaxis", $('#drug_prophylaxis').val(),-1);301    $.setCookie("isoniazid_view", $('#isoniazid_view').val(),-1);302    $.setCookie("isoniazid_start_date_view", $('#isoniazid_start_date_view').val(),-1);303    $.setCookie("iso_start_date", $('#iso_start_date').val(),-1);304    $.setCookie("isoniazid_end_date_view", $('#isoniazid_end_date_view').val(),-1);305    $.setCookie("iso_end_date", $('#iso_end_date').val(),-1);306    $.setCookie("direction", $('#direction').val(),-1);...

Full Screen

Full Screen

vertical-layout.js

Source:vertical-layout.js Github

copy

Full Screen

1"use strict!"2$(document).ready(function() {3    // variable4    var Navbarbg = "themelight1"; // navbar color themelight1 / theme15    var headerbg = "theme1"; //  navbar color theme1 / theme2 / theme3 / theme4 / theme5 / theme66    var menucaption = "theme1"; //  menu caption color theme1 / theme2 / theme3 / theme4 / theme5 / theme6 / theme7 / theme8 / theme97    var bgpattern = "theme1"; //  background pattern theme1 / theme2 / theme3 / theme4 / theme5 / theme68    var activeitemtheme = "theme1"; //  menu active color theme1 / theme2 / theme3 / theme4 / theme5 / theme6 / theme7 / theme8 / theme9 / theme10 / theme11 / theme129    var frametype = "theme1"; //  preset frame color theme1 / theme2 / theme3 / theme4 / theme5 / theme610    var layout_type = "light"; //  theme layout dark / light11    var nav_image = "false"; //  navbar image bg false / true12    var active_image = "img1"; //  avtive navbar image layout img1 / img2 / img3 / img4 / img5 / img613    var layout_width = "wide"; //  theme layout wide / box14    var menu_effect_desktop = "shrink"; //  navbar effect in desktop  shrink / overlay / push15    var menu_effect_tablet = "overlay"; //  navbar effect in tablet  shrink / overlay / push16    var menu_effect_phone = "overlay"; //  navbar effect in phone  shrink / overlay / push17    function setCookie(cname, cvalue, exdays) {18		var d = new Date();19        d.setTime(d.getTime() + (exdays*24*60*60*1000));20        var expires = "expires=" + d.toGMTString();21        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";22    }23    function getCookie(cname) {24        var name = cname + "=";25        var decodedCookie = decodeURIComponent(document.cookie);26        var ca = decodedCookie.split(';');27        for (var i = 0; i < ca.length; i++) {28            var c = ca[i];29            while (c.charAt(0) == ' ') {30                c = c.substring(1);31            }32            if (c.indexOf(name) == 0) {33                return c.substring(name.length, c.length);34            }35        }36        return "";37    }38    function checkCookie() {39        var temp = getCookie("NavbarBackground");40        if (temp != "") {41            Navbarbg = temp;42        }43        var temp = getCookie("header-theme");44        if (temp != "") {45            headerbg = temp;46        }47        var temp = getCookie("menu-title-theme");48        if (temp != "") {49            menucaption = temp;50        }51        var temp = getCookie("themebg-pattern");52        if (temp != "") {53            bgpattern = temp;54        }55        var temp = getCookie("active-item-theme");56        if (temp != "") {57            activeitemtheme = temp;58        }59        var temp = getCookie("fream-type");60        if (temp != "") {61            frametype = temp;62        }63        var temp = getCookie("layoutlayout");64        if (temp != "") {65            layout_type = temp;66        }67        var temp = getCookie("sidebar-img");68        if (temp != "") {69            nav_image = temp;70        }71        var temp = getCookie("sidebar-img-type");72        if (temp != "") {73            active_image = temp;74        }75        var temp = getCookie("vertical-layout");76        if (temp != "") {77            layout_width = temp;78        }79        var temp = getCookie("vertical-effect");80        if (temp != "") {81            menu_effect_desktop = temp;82        }83    }84    checkCookie();85    $("#pcoded").pcodedmenu({86        themelayout: 'vertical',87        verticalMenuplacement: 'left', // value should be left/right88        verticalMenulayout: layout_width, // value should be wide/box89        MenuTrigger: 'click', // click / hover90        SubMenuTrigger: 'click', // click / hover91        activeMenuClass: 'active',92        ThemeBackgroundPattern: bgpattern, // pattern1, pattern2, pattern3, pattern4, pattern5, pattern693        HeaderBackground: headerbg, // theme1, theme2, theme3, theme4, theme5  header color94        LHeaderBackground: menucaption, // theme1, theme2, theme3, theme4, theme5, theme6   brand color95        NavbarBackground: Navbarbg, // themelight1, theme1  // light  and dark sidebar96        ActiveItemBackground: activeitemtheme, // theme1, theme2, theme3, theme4, theme5, theme6, theme7, theme8, theme9, theme10, theme11, theme12  mennu active item color97        SubItemBackground: 'theme2',98        ActiveItemStyle: 'style0',99        ItemBorder: true,100        ItemBorderStyle: 'none',101        NavbarImage: nav_image,102        ActiveNavbarImage: active_image,103        freamtype: frametype,104        SubItemBorder: true,105        DropDownIconStyle: 'style3', // Value should be style1,style2,style3106        menutype: 'st2', // Value should be st1, st2, st3, st4, st5 menu icon style107        layouttype: layout_type, // Value should be light / dark108        FixedNavbarPosition: true, // Value should be true / false  header postion109        FixedHeaderPosition: true, // Value should be true / false  sidebar menu postion110        collapseVerticalLeftHeader: true,111        VerticalSubMenuItemIconStyle: 'style7', // value should be style1, style2, style3, style4, style5, style6112        VerticalNavigationView: 'view1',113        verticalMenueffect: {114            desktop: menu_effect_desktop,115            tablet: menu_effect_tablet,116            phone: menu_effect_phone,117        },118        defaultVerticalMenu: {119            desktop: "expanded", // value should be offcanvas/collapsed/expanded/compact/compact-acc/fullpage/ex-popover/sub-expanded120            tablet: "offcanvas", // value should be offcanvas/collapsed/expanded/compact/fullpage/ex-popover/sub-expanded121            phone: "offcanvas", // value should be offcanvas/collapsed/expanded/compact/fullpage/ex-popover/sub-expanded122        },123        onToggleVerticalMenu: {124            desktop: "offcanvas", // value should be offcanvas/collapsed/expanded/compact/fullpage/ex-popover/sub-expanded125            tablet: "expanded", // value should be offcanvas/collapsed/expanded/compact/fullpage/ex-popover/sub-expanded126            phone: "expanded", // value should be offcanvas/collapsed/expanded/compact/fullpage/ex-popover/sub-expanded127        },128    });129    function handlenavimg() {130        $('.theme-color > a.navbg-pattern').on("click", function() {131            var value = $(this).attr("navbg-pattern");132            $('.pcoded').attr('sidebar-img-type', value);133            setCookie("sidebar-img-type", value, 1);134        });135    };136    handlenavimg();137    /* layout type Change function Start */138    function handlelayouttheme() {139        $('.theme-color > a.Layout-type').on("click", function() {140            var layout = $(this).attr("layout-type");141            $('.pcoded').attr("layout-type", layout);142            setCookie("layoutlayout", layout, 1);143            if (layout == 'dark') {144                $('.pcoded-header').attr("header-theme", "theme6");145                $('.pcoded-navbar').attr("navbar-theme", "theme1");146                $('.pcoded').attr("sidebar-img", "false");147                $('body').addClass('dark');148                $('body').attr("themebg-pattern", "theme6");149                $('.pcoded-navigation-label').attr("menu-title-theme", "theme9");150                setCookie("header-theme", "theme6", 1);151                setCookie("NavbarBackground", "theme1", 1);152                setCookie("menu-title-theme", "theme9", 1);153                setCookie("themebg-pattern", "theme6", 1);154                setCookie("sidebar-img", "false", 1);155            }156            if (layout == 'light') {157                $('.pcoded-header').attr("header-theme", "theme1");158                $('.pcoded-navbar').attr("navbar-theme", "themelight1");159                $('.pcoded').attr("sidebar-img", "false");160                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");161                $('body').removeClass('dark');162                $('body').attr("themebg-pattern", "theme1");163                setCookie("header-theme", "theme1", 1);164                setCookie("NavbarBackground", "themelight1", 1);165                setCookie("menu-title-theme", "theme1", 1);166                setCookie("themebg-pattern", "theme1", 1);167                setCookie("sidebar-img", "false", 1);168            }169            if (layout == 'img') {170                $('.pcoded-header').attr("header-theme", "theme1");171                $('.pcoded-navbar').attr("navbar-theme", "themelight1");172                $('.pcoded-navbar').attr("navbar-theme", "themelight1");173                $('.pcoded').attr("sidebar-img", "true");174                $('.pcoded').attr("frame-type", "theme1");175                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");176                setCookie("header-theme", "theme1", 1);177                setCookie("NavbarBackground", "themelight1", 1);178                setCookie("menu-title-theme", "theme1", 1);179                setCookie("themebg-pattern", "theme1", 1);180                setCookie("sidebar-img", "true", 1);181                setCookie("fream-type", "theme1" ,1);182            }183            if (layout == 'reset') {184                setCookie("NavbarBackground", null, 0);185                setCookie("header-theme", null, 0);186                setCookie("menu-title-theme", null, 0);187                setCookie("themebg-pattern", null, 0);188                setCookie("active-item-theme", null, 0);189                setCookie("fream-type", null, 0);190                setCookie("layoutlayout", null, 0);191                setCookie("sidebar-img", null, 0);192                setCookie("sidebar-img-type", null, 0);193                setCookie("vertical-layout", null, 0);194                setCookie("vertical-effect", null, 0);195                location.reload();196            }197        });198    };199    handlelayouttheme();200    /* Left header Theme Change function Start */201    function handleleftheadertheme() {202        $('.theme-color > a.leftheader-theme').on("click", function() {203            var lheadertheme = $(this).attr("lheader-theme");204            $('.pcoded-navigation-label').attr("menu-title-theme", lheadertheme);205            setCookie("menu-title-theme", lheadertheme, 1);206        });207    };208    handleleftheadertheme();209    /* Left header Theme Change function Close */210    /* header Theme Change function Start */211    function handleheadertheme() {212        $('.theme-color > a.header-theme').on("click", function() {213            var headertheme = $(this).attr("header-theme");214            var activeitem = $(this).attr("active-item-color");215            $('.pcoded-header').attr("header-theme", headertheme);216            $('.pcoded-navbar').attr("active-item-theme", activeitem);217            $('.pcoded').attr("fream-type", headertheme);218            $('.pcoded-navigation-label').attr("menu-title-theme", headertheme);219            $('body').attr("themebg-pattern", headertheme);220            // coockies221            setCookie("header-theme", headertheme, 1);222            setCookie("active-item-theme", activeitem, 1);223            setCookie("menu-title-theme", headertheme, 1);224            setCookie("themebg-pattern", headertheme, 1);225            setCookie("fream-type", headertheme, 1);226        });227    };228    handleheadertheme();229    /* header Theme Change function Close */230    /* Navbar Theme Change function Start */231    function handlenavbartheme() {232        $('.theme-color > a.navbar-theme').on("click", function() {233            var navbartheme = $(this).attr("navbar-theme");234            $('.pcoded-navbar').attr("navbar-theme", navbartheme);235            $('.pcoded').attr("sidebar-img", "false");236            setCookie("NavbarBackground", navbartheme, 1);237            setCookie("sidebar-img", "false", 1);238            if (navbartheme == 'themelight1') {239                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");240                setCookie("menu-title-theme", "theme1", 1);241            }242            if (navbartheme == 'theme1') {243                $('.pcoded-navigation-label').attr("menu-title-theme", "theme9");244                setCookie("menu-title-theme", "theme9", 1);245            }246        });247    };248    handlenavbartheme();249    /* Navbar Theme Change function Close */250    /* Active Item Theme Change function Start */251    function handleactiveitemtheme() {252        $('.theme-color > a.active-item-theme').on("click", function() {253            var activeitemtheme = $(this).attr("active-item-theme");254            $('.pcoded-navbar').attr("active-item-theme", activeitemtheme);255            setCookie("active-item-theme", activeitemtheme, 1);256        });257    };258    handleactiveitemtheme();259    /* Active Item Theme Change function Close */260    /* Theme background pattren Change function Start */261    function handlethemebgpattern() {262        $('.theme-color > a.themebg-pattern').on("click", function() {263            var themebgpattern = $(this).attr("themebg-pattern");264            $('body').attr("themebg-pattern", themebgpattern);265            setCookie("themebg-pattern", themebgpattern, 1);266        });267    };268    handlethemebgpattern();269    /* Theme background pattren Change function Close */270    /* Theme Layout Change function start*/271    function handlethemeverticallayout() {272        $('#theme-layout').change(function() {273            if ($(this).is(":checked")) {274                $('.pcoded').attr('vertical-layout', "box");275                setCookie("vertical-layout", "box", 1);276                $('#bg-pattern-visiblity').removeClass('d-none');277            } else {278                $('.pcoded').attr('vertical-layout', "wide");279                setCookie("vertical-layout", "wide", 1);280                $('#bg-pattern-visiblity').addClass('d-none');281            }282        });283    };284    handlethemeverticallayout();285    /* Theme Layout Change function Close*/286    /* Menu effect change function start*/287    function handleverticalMenueffect() {288        $('#vertical-menu-effect').val('shrink').on('change', function(get_value) {289            get_value = $(this).val();290            $('.pcoded').attr('vertical-effect', get_value);291            setCookie("vertical-effect", get_value, 1);292        });293    };294    handleverticalMenueffect();295    /* Menu effect change function Close*/296    /* Vertical Item border Style change function Start*/297    function handleverticalboderstyle() {298        $('#vertical-border-style').val('solid').on('change', function(get_value) {299            get_value = $(this).val();300            $('.pcoded-navbar .pcoded-item').attr('item-border-style', get_value);301        });302    };303    handleverticalboderstyle();304    /* Vertical Item border Style change function Close*/305    /* Vertical Dropdown Icon change function Start*/306    function handleVerticalDropDownIconStyle() {307        $('#vertical-dropdown-icon').val('style1').on('change', function(get_value) {308            get_value = $(this).val();309            $('.pcoded-navbar .pcoded-hasmenu').attr('dropdown-icon', get_value);310        });311    };312    handleVerticalDropDownIconStyle();313    /* Vertical Dropdown Icon change function Close*/314    /* Vertical SubItem Icon change function Start*/315    function handleVerticalSubMenuItemIconStyle() {316        $('#vertical-subitem-icon').val('style5').on('change', function(get_value) {317            get_value = $(this).val();318            $('.pcoded-navbar .pcoded-hasmenu').attr('subitem-icon', get_value);319        });320    };321    handleVerticalSubMenuItemIconStyle();322    /* Vertical SubItem Icon change function Close*/323    /* Vertical Navbar Position change function Start*/324    function handlesidebarposition() {325        $('#sidebar-position').change(function() {326            if ($(this).is(":checked")) {327                $('.pcoded-navbar').attr("pcoded-navbar-position", 'fixed');328                $('.pcoded-header .pcoded-left-header').attr("pcoded-lheader-position", 'fixed');329            } else {330                $('.pcoded-navbar').attr("pcoded-navbar-position", 'absolute');331                $('.pcoded-header .pcoded-left-header').attr("pcoded-lheader-position", 'relative');332            }333        });334    };335    handlesidebarposition();336    /* Vertical Navbar Position change function Close*/337    /* Vertical Header Position change function Start*/338    function handleheaderposition() {339        $('#header-position').change(function() {340            if ($(this).is(":checked")) {341                $('.pcoded-header').attr("pcoded-header-position", 'fixed');342                $('.pcoded-navbar').attr("pcoded-header-position", 'fixed');343                $('.pcoded-main-container').css('margin-top', $(".pcoded-header").outerHeight());344            } else {345                $('.pcoded-header').attr("pcoded-header-position", 'relative');346                $('.pcoded-navbar').attr("pcoded-header-position", 'relative');347                $('.pcoded-main-container').css('margin-top', '0px');348            }349        });350    };351    handleheaderposition();352    /* Vertical Header Position change function Close*/353    /*  collapseable Left Header Change Function Start here*/354    function handlecollapseLeftHeader() {355        $('#collapse-left-header').change(function() {356            if ($(this).is(":checked")) {357                $('.pcoded-header, .pcoded ').removeClass('iscollapsed');358                $('.pcoded-header, .pcoded').addClass('nocollapsed');359            } else {360                $('.pcoded-header, .pcoded').addClass('iscollapsed');361                $('.pcoded-header, .pcoded').removeClass('nocollapsed');362            }363        });364    };365    handlecollapseLeftHeader();366    /*  collapseable Left Header Change Function Close here*/367});368function handlemenutype(get_value) {369    $('.pcoded').attr('nav-type', get_value);370};...

Full Screen

Full Screen

menu-hori-fixed.js

Source:menu-hori-fixed.js Github

copy

Full Screen

1"use strict!"2$( document ).ready(function() {3	// variable4    var noofdays = 1;                       //  total no of days cookie will store5    var Navbarbg = "themelight1";           //  navbar color                themelight1 / theme16    var headerbg = "theme1";                //  header color                theme1 / theme2 / theme3 / theme4 / theme5 / theme67    var menucaption = "theme1";             //  menu caption color          theme1 / theme2 / theme3 / theme4 / theme5 / theme6 / theme7 / theme8 / theme98    var bgpattern = "theme1";               //  background color            theme1 / theme2 / theme3 / theme4 / theme5 / theme69    var activeitemtheme = "theme1";         //  menu active color           theme1 / theme2 / theme3 / theme4 / theme5 / theme6 / theme7 / theme8 / theme9 / theme10 / theme11 / theme1210    var frametype = "theme1";               //  preset frame color          theme1 / theme2 / theme3 / theme4 / theme5 / theme611    var layout_type = "light";              //  theme layout color          dark / light12    var layout_width = "wide";              //  theme layout size           wide / box13    var menu_effect_desktop = "shrink";     //  navbar effect in desktop    shrink / overlay / push14    var menu_effect_tablet = "overlay";     //  navbar effect in tablet     shrink / overlay / push15    var menu_effect_phone = "overlay";      //  navbar effect in phone      shrink / overlay / push16    var menu_icon_style = "st2";            //  navbar menu icon            st1 / st217    function setCookie(cname, cvalue, exdays) {18		var d = new Date();19        d.setTime(d.getTime() + (exdays*24*60*60*1000));20        var expires = "expires=" + d.toGMTString();21        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";22    }23    function getCookie(cname) {24        var name = cname + "=";25        var decodedCookie = decodeURIComponent(document.cookie);26        var ca = decodedCookie.split(';');27        for (var i = 0; i < ca.length; i++) {28            var c = ca[i];29            while (c.charAt(0) == ' ') {30                c = c.substring(noofdays);31            }32            if (c.indexOf(name) == 0) {33                return c.substring(name.length, c.length);34            }35        }36        return "";37    }38    function checkCookie() {39        Navbarbg = (getCookie("NavbarBackground") != "") ? getCookie("NavbarBackground"): Navbarbg;40        headerbg = (getCookie("header-theme") != "") ? getCookie("header-theme"): headerbg;41        menucaption = (getCookie("menu-title-theme") != "") ? getCookie("menu-title-theme"): menucaption;42        bgpattern = (getCookie("themebg-pattern") != "") ? getCookie("themebg-pattern"): bgpattern;43        activeitemtheme = (getCookie("active-item-theme") != "") ? getCookie("active-item-theme"): activeitemtheme;44        frametype = (getCookie("fream-type") != "") ? getCookie("fream-type"): frametype;45        layout_type = (getCookie("layoutlayout") != "") ? getCookie("layoutlayout"): layout_type;46        layout_width = (getCookie("vertical-layout") != "") ? getCookie("vertical-layout"): layout_width;47        menu_effect_desktop = (getCookie("vertical-effect") != "") ? getCookie("vertical-effect"): menu_effect_desktop;48        menu_icon_style = (getCookie("menu-icon-style") != "") ? getCookie("menu-icon-style"): menu_icon_style;49    }50    //checkCookie();51	$('.pcoded-navbar .pcoded-hasmenu').attr('subitem-icon', 'style1');52	$( "#pcoded" ).pcodedmenu({53		themelayout: 'horizontal',54		horizontalMenuplacement: 'top',55		horizontalBrandItem: true,56		horizontalLeftNavItem: true,57		horizontalRightItem: true,58		horizontalSearchItem: true,59		horizontalMobileMenu: true,60		MenuTrigger: 'hover',61		SubMenuTrigger: 'hover',62		activeMenuClass: 'active',63		ThemeBackgroundPattern: bgpattern,64		HeaderBackground: headerbg,65        LHeaderBackground: menucaption,66		NavbarBackground: Navbarbg,67		ActiveItemBackground: activeitemtheme,68		SubItemBackground: 'theme2',69		menutype: menu_icon_style,70        freamtype: frametype,71		layouttype: layout_type,72		ActiveItemStyle: 'style1',73		ItemBorder: true,74		ItemBorderStyle: 'none',75		SubItemBorder: true,76		DropDownIconStyle: 'style1',77		FixedNavbarPosition: true,78		FixedHeaderPosition: true,79		horizontalNavIsCentered: false,80		horizontalstickynavigation: false,81		horizontalNavigationMenuIcon: true,82	});83	/* layout type Change function Start */84    function handlelayouttheme() {85        $('.theme-color > a.Layout-type').on("click", function() {86            var layout = $(this).attr("layout-type");87            $('.pcoded').attr("layout-type", layout);88            setCookie("layoutlayout", layout, noofdays);89            if (layout == 'dark') {90                $('.pcoded-header').attr("header-theme", "theme1");91                $('.pcoded-navbar').attr("navbar-theme", "theme1");92                $('.pcoded-navbar').attr("active-item-theme", "theme1");93                $('.pcoded').attr("fream-type", "theme1");94                $('body').addClass('dark');95                $('body').attr("themebg-pattern", "theme1");96                $('.pcoded-navigation-label').attr("menu-title-theme", "theme9");97                setCookie("header-theme", "theme1", noofdays);98                setCookie("NavbarBackground", "theme1", noofdays);99                setCookie("menu-title-theme", "theme1", noofdays);100                setCookie("themebg-pattern", "theme1", noofdays);101                setCookie("fream-type", "theme1", noofdays);102                setCookie("active-item-theme", "theme1", noofdays);103            }104            if (layout == 'light') {105                $('.pcoded-header').attr("header-theme", "theme1");106                $('.pcoded-navbar').attr("navbar-theme", "themelight1");107                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");108                $('.pcoded-navbar').attr("active-item-theme", "theme1");109                $('.pcoded').attr("fream-type", "theme1");110                $('body').removeClass('dark');111                $('body').attr("themebg-pattern", "theme1");112                setCookie("header-theme", "theme1", noofdays);113                setCookie("NavbarBackground", "themelight1", noofdays);114                setCookie("menu-title-theme", "theme1", noofdays);115                setCookie("themebg-pattern", "theme1", noofdays);116                setCookie("fream-type", "theme1", noofdays);117                setCookie("active-item-theme", "theme1", noofdays);118            }119            if (layout == 'reset') {120                setCookie("NavbarBackground", null, 0);121                setCookie("header-theme", null, 0);122                setCookie("menu-title-theme", null, 0);123                setCookie("themebg-pattern", null, 0);124                setCookie("active-item-theme", null, 0);125                setCookie("fream-type", null, 0);126                setCookie("layoutlayout", null, 0);127                setCookie("vertical-layout", null, 0);128                setCookie("vertical-effect", null, 0);129                location.reload();130            }131        });132    };133    handlelayouttheme();134    /* Left header Theme Change function Start */135    function handleleftheadertheme() {136        $('.theme-color > a.leftheader-theme').on("click", function() {137            var lheadertheme = $(this).attr("menu-caption");138            $('.pcoded-navigation-label').attr("menu-title-theme", lheadertheme);139            setCookie("menu-title-theme", lheadertheme, noofdays);140        });141    };142    handleleftheadertheme();143    /* Left header Theme Change function Close */144    /* header Theme Change function Start */145    function handleheadertheme() {146        $('.theme-color > a.header-theme').on("click", function() {147            var headertheme = $(this).attr("header-theme");148            var activeitem = $(this).attr("active-item-color");149            $('.pcoded-header').attr("header-theme", headertheme);150            $('.pcoded-navbar').attr("active-item-theme", activeitem);151            $('.pcoded').attr("fream-type", headertheme);152            $('.pcoded-navigation-label').attr("menu-title-theme", headertheme);153            $('body').attr("themebg-pattern", headertheme);154            // coockies155            setCookie("header-theme", headertheme, noofdays);156            setCookie("active-item-theme", activeitem, noofdays);157            setCookie("menu-title-theme", headertheme, noofdays);158            setCookie("themebg-pattern", headertheme, noofdays);159            setCookie("fream-type", headertheme, noofdays);160        });161    };162    handleheadertheme();163    /* header Theme Change function Close */164    /* Navbar Theme Change function Start */165    function handlenavbartheme() {166        $('.theme-color > a.navbar-theme').on("click", function() {167            var navbartheme = $(this).attr("navbar-theme");168            $('.pcoded-navbar').attr("navbar-theme", navbartheme);169            setCookie("NavbarBackground", navbartheme, noofdays);170            if (navbartheme == 'themelight1') {171                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");172                setCookie("menu-title-theme", "theme1", noofdays);173            }174            if (navbartheme == 'theme1') {175                $('.pcoded-navigation-label').attr("menu-title-theme", "theme9");176                setCookie("menu-title-theme", "theme9", noofdays);177            }178        });179    };180    handlenavbartheme();181    /* Navbar Theme Change function Close */182    /* Active Item Theme Change function Start */183    function handleactiveitemtheme() {184        $('.theme-color > a.active-item-theme').on("click", function() {185            var activeitemtheme = $(this).attr("active-item-theme");186            $('.pcoded-navbar').attr("active-item-theme", activeitemtheme);187            setCookie("active-item-theme", activeitemtheme, noofdays);188        });189    };190    handleactiveitemtheme();191    /* Active Item Theme Change function Close */192    /* Theme background pattren Change function Start */193    function handlethemebgpattern() {194        $('.theme-color > a.themebg-pattern').on("click", function() {195            var themebgpattern = $(this).attr("themebg-pattern");196            $('body').attr("themebg-pattern", themebgpattern);197            setCookie("themebg-pattern", themebgpattern, noofdays);198        });199    };200    handlethemebgpattern();201    /* Theme background pattren Change function Close */202    /* Theme Layout Change function start*/203    function handlethemeverticallayout() {204        $('#theme-layout').change(function() {205            if ($(this).is(":checked")) {206                $('.pcoded').attr('vertical-layout', "box");207                setCookie("vertical-layout", "box", noofdays);208                $('#bg-pattern-visiblity').removeClass('d-none');209            } else {210                $('.pcoded').attr('vertical-layout', "wide");211                setCookie("vertical-layout", "wide", noofdays);212                $('#bg-pattern-visiblity').addClass('d-none');213            }214        });215    };216    handlethemeverticallayout();217    /* Theme Layout Change function Close*/218    /* Menu effect change function start*/219    function handleverticalMenueffect() {220        $('#vertical-menu-effect').val('shrink').on('change', function(get_value) {221            get_value = $(this).val();222            $('.pcoded').attr('vertical-effect', get_value);223            setCookie("vertical-effect", get_value, noofdays);224        });225    };226    handleverticalMenueffect();227    /* Menu effect change function Close*/228    /* Vertical Item border Style change function Start*/229    function handleverticalboderstyle() {230        $('#vertical-border-style').val('solid').on('change', function(get_value) {231            get_value = $(this).val();232            $('.pcoded-navbar .pcoded-item').attr('item-border-style', get_value);233        });234    };235    handleverticalboderstyle();236    /* Vertical Item border Style change function Close*/237    /* Vertical Dropdown Icon change function Start*/238    function handleVerticalDropDownIconStyle() {239        $('#vertical-dropdown-icon').val('style1').on('change', function(get_value) {240            get_value = $(this).val();241            $('.pcoded-navbar .pcoded-hasmenu').attr('dropdown-icon', get_value);242        });243    };244    handleVerticalDropDownIconStyle();245    /* Vertical Dropdown Icon change function Close*/246    /* Vertical SubItem Icon change function Start*/247    function handleVerticalSubMenuItemIconStyle() {248        $('#vertical-subitem-icon').val('style5').on('change', function(get_value) {249            get_value = $(this).val();250            $('.pcoded-navbar .pcoded-hasmenu').attr('subitem-icon', get_value);251        });252    };253    handleVerticalSubMenuItemIconStyle();254    /* Vertical SubItem Icon change function Close*/255    /* Vertical Navbar Position change function Start*/256    function handlesidebarposition() {257        $('#sidebar-position').change(function() {258            if ($(this).is(":checked")) {259                $('.pcoded-navbar').attr("pcoded-navbar-position", 'fixed');260                $('.pcoded-header .pcoded-left-header').attr("pcoded-lheader-position", 'fixed');261            } else {262                $('.pcoded-navbar').attr("pcoded-navbar-position", 'absolute');263                $('.pcoded-header .pcoded-left-header').attr("pcoded-lheader-position", 'relative');264            }265        });266    };267    handlesidebarposition();268    /* Vertical Navbar Position change function Close*/269    /* Vertical Header Position change function Start*/270    function handleheaderposition() {271        $('#header-position').change(function() {272            if ($(this).is(":checked")) {273                $('.pcoded-header').attr("pcoded-header-position", 'fixed');274                $('.pcoded-navbar').attr("pcoded-header-position", 'fixed');275                $('.pcoded-main-container').css('margin-top', $(".pcoded-header").outerHeight());276            } else {277                $('.pcoded-header').attr("pcoded-header-position", 'relative');278                $('.pcoded-navbar').attr("pcoded-header-position", 'relative');279                $('.pcoded-main-container').css('margin-top', '0px');280            }281        });282    };283    handleheaderposition();284    /* Vertical Header Position change function Close*/285    /*  collapseable Left Header Change Function Start here*/286    function handlecollapseLeftHeader() {287        $('#collapse-left-header').change(function() {288            if ($(this).is(":checked")) {289                $('.pcoded-header, .pcoded ').removeClass('iscollapsed');290                $('.pcoded-header, .pcoded').addClass('nocollapsed');291            } else {292                $('.pcoded-header, .pcoded').addClass('iscollapsed');293                $('.pcoded-header, .pcoded').removeClass('nocollapsed');294            }295        });296    };297    handlecollapseLeftHeader();298    /*  collapseable Left Header Change Function Close here*/299});300function handlemenutype(get_value) {301	$('.pcoded').attr('nav-type', get_value);302};...

Full Screen

Full Screen

horizontal-layout.js

Source:horizontal-layout.js Github

copy

Full Screen

1"use strict!"2$( document ).ready(function() {3	// variable4    var noofdays = 1;                       //  total no of days cookie will store5    var Navbarbg = "themelight1";           //  navbar color                themelight1 / theme16    var headerbg = "theme1";                //  header color                theme1 / theme2 / theme3 / theme4 / theme5 / theme67    var menucaption = "theme1";             //  menu caption color          theme1 / theme2 / theme3 / theme4 / theme5 / theme6 / theme7 / theme8 / theme98    var bgpattern = "theme1";               //  background color            theme1 / theme2 / theme3 / theme4 / theme5 / theme69    var activeitemtheme = "theme1";         //  menu active color           theme1 / theme2 / theme3 / theme4 / theme5 / theme6 / theme7 / theme8 / theme9 / theme10 / theme11 / theme1210    var frametype = "theme1";               //  preset frame color          theme1 / theme2 / theme3 / theme4 / theme5 / theme611    var layout_type = "dark";              //  theme layout color          dark / light12    var layout_width = "wide";              //  theme layout size           wide / box13    var menu_effect_desktop = "shrink";     //  navbar effect in desktop    shrink / overlay / push14    var menu_effect_tablet = "overlay";     //  navbar effect in tablet     shrink / overlay / push15    var menu_effect_phone = "overlay";      //  navbar effect in phone      shrink / overlay / push16    var menu_icon_style = "st2";            //  navbar menu icon            st1 / st217    function setCookie(cname, cvalue, exdays) {18		var d = new Date();19        d.setTime(d.getTime() + (exdays*24*60*60*1000));20        var expires = "expires=" + d.toGMTString();21        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";22    }23    function getCookie(cname) {24        var name = cname + "=";25        var decodedCookie = decodeURIComponent(document.cookie);26        var ca = decodedCookie.split(';');27        for (var i = 0; i < ca.length; i++) {28            var c = ca[i];29            while (c.charAt(0) == ' ') {30                c = c.substring(noofdays);31            }32            if (c.indexOf(name) == 0) {33                return c.substring(name.length, c.length);34            }35        }36        return "";37    }38    function checkCookie() {39        Navbarbg = (getCookie("NavbarBackground") != "") ? getCookie("NavbarBackground"): Navbarbg;40        headerbg = (getCookie("header-theme") != "") ? getCookie("header-theme"): headerbg;41        menucaption = (getCookie("menu-title-theme") != "") ? getCookie("menu-title-theme"): menucaption;42        bgpattern = (getCookie("themebg-pattern") != "") ? getCookie("themebg-pattern"): bgpattern;43        activeitemtheme = (getCookie("active-item-theme") != "") ? getCookie("active-item-theme"): activeitemtheme;44        frametype = (getCookie("fream-type") != "") ? getCookie("fream-type"): frametype;45        layout_type = (getCookie("layoutlayout") != "") ? getCookie("layoutlayout"): layout_type;46        layout_width = (getCookie("vertical-layout") != "") ? getCookie("vertical-layout"): layout_width;47        menu_effect_desktop = (getCookie("vertical-effect") != "") ? getCookie("vertical-effect"): menu_effect_desktop;48        menu_icon_style = (getCookie("menu-icon-style") != "") ? getCookie("menu-icon-style"): menu_icon_style;49    }50    checkCookie();51	$('.pcoded-navbar .pcoded-hasmenu').attr('subitem-icon', 'style1');52	$( "#pcoded" ).pcodedmenu({53		themelayout: 'horizontal',54		horizontalMenuplacement: 'top',55		horizontalBrandItem: true,56		horizontalLeftNavItem: true,57		horizontalRightItem: true,58		horizontalSearchItem: true,59		horizontalMobileMenu: true,60		MenuTrigger: 'hover',61		SubMenuTrigger: 'hover',62		activeMenuClass: 'active',63		ThemeBackgroundPattern: bgpattern,64		HeaderBackground: headerbg,65        LHeaderBackground: menucaption,66		NavbarBackground: Navbarbg,67		ActiveItemBackground: activeitemtheme,68		SubItemBackground: 'theme2',69		menutype: menu_icon_style,70        freamtype: frametype,71		layouttype: layout_type,72		ActiveItemStyle: 'style1',73		ItemBorder: true,74		ItemBorderStyle: 'none',75		SubItemBorder: true,76		DropDownIconStyle: 'style1',77		FixedNavbarPosition: false,78		FixedHeaderPosition: false,79		horizontalNavIsCentered: false,80		horizontalstickynavigation: false,81		horizontalNavigationMenuIcon: true,82	});83	/* layout type Change function Start */84    function handlelayouttheme() {85        $('.theme-color > a.Layout-type').on("click", function() {86            var layout = $(this).attr("layout-type");87            $('.pcoded').attr("layout-type", layout);88            setCookie("layoutlayout", layout, noofdays);89            if (layout == 'dark') {90                $('.pcoded-header').attr("header-theme", "theme1");91                $('.pcoded-navbar').attr("navbar-theme", "theme1");92                $('.pcoded-navbar').attr("active-item-theme", "theme1");93                $('.pcoded').attr("fream-type", "theme1");94                $('body').addClass('dark');95                $('body').attr("themebg-pattern", "theme1");96                $('.pcoded-navigation-label').attr("menu-title-theme", "theme9");97                setCookie("header-theme", "theme1", noofdays);98                setCookie("NavbarBackground", "theme1", noofdays);99                setCookie("menu-title-theme", "theme1", noofdays);100                setCookie("themebg-pattern", "theme1", noofdays);101                setCookie("fream-type", "theme1", noofdays);102                setCookie("active-item-theme", "theme1", noofdays);103            }104            if (layout == 'light') {105                $('.pcoded-header').attr("header-theme", "theme1");106                $('.pcoded-navbar').attr("navbar-theme", "themelight1");107                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");108                $('.pcoded-navbar').attr("active-item-theme", "theme1");109                $('.pcoded').attr("fream-type", "theme1");110                $('body').removeClass('dark');111                $('body').attr("themebg-pattern", "theme1");112                setCookie("header-theme", "theme1", noofdays);113                setCookie("NavbarBackground", "themelight1", noofdays);114                setCookie("menu-title-theme", "theme1", noofdays);115                setCookie("themebg-pattern", "theme1", noofdays);116                setCookie("fream-type", "theme1", noofdays);117                setCookie("active-item-theme", "theme1", noofdays);118            }119            if (layout == 'reset') {120                setCookie("NavbarBackground", null, 0);121                setCookie("header-theme", null, 0);122                setCookie("menu-title-theme", null, 0);123                setCookie("themebg-pattern", null, 0);124                setCookie("active-item-theme", null, 0);125                setCookie("fream-type", null, 0);126                setCookie("layoutlayout", null, 0);127                setCookie("vertical-layout", null, 0);128                setCookie("vertical-effect", null, 0);129                location.reload();130            }131        });132    };133    handlelayouttheme();134    /* Left header Theme Change function Start */135    function handleleftheadertheme() {136        $('.theme-color > a.leftheader-theme').on("click", function() {137            var lheadertheme = $(this).attr("menu-caption");138            $('.pcoded-navigation-label').attr("menu-title-theme", lheadertheme);139            setCookie("menu-title-theme", lheadertheme, noofdays);140        });141    };142    handleleftheadertheme();143    /* Left header Theme Change function Close */144    /* header Theme Change function Start */145    function handleheadertheme() {146        $('.theme-color > a.header-theme').on("click", function() {147            var headertheme = $(this).attr("header-theme");148            var activeitem = $(this).attr("active-item-color");149            $('.pcoded-header').attr("header-theme", headertheme);150            $('.pcoded-navbar').attr("active-item-theme", activeitem);151            $('.pcoded').attr("fream-type", headertheme);152            $('.pcoded-navigation-label').attr("menu-title-theme", headertheme);153            $('body').attr("themebg-pattern", headertheme);154            // coockies155            setCookie("header-theme", headertheme, noofdays);156            setCookie("active-item-theme", activeitem, noofdays);157            setCookie("menu-title-theme", headertheme, noofdays);158            setCookie("themebg-pattern", headertheme, noofdays);159            setCookie("fream-type", headertheme, noofdays);160        });161    };162    handleheadertheme();163    /* header Theme Change function Close */164    /* Navbar Theme Change function Start */165    function handlenavbartheme() {166        $('.theme-color > a.navbar-theme').on("click", function() {167            var navbartheme = $(this).attr("navbar-theme");168            $('.pcoded-navbar').attr("navbar-theme", navbartheme);169            setCookie("NavbarBackground", navbartheme, noofdays);170            if (navbartheme == 'themelight1') {171                $('.pcoded-navigation-label').attr("menu-title-theme", "theme1");172                setCookie("menu-title-theme", "theme1", noofdays);173            }174            if (navbartheme == 'theme1') {175                $('.pcoded-navigation-label').attr("menu-title-theme", "theme9");176                setCookie("menu-title-theme", "theme9", noofdays);177            }178        });179    };180    handlenavbartheme();181    /* Navbar Theme Change function Close */182    /* Active Item Theme Change function Start */183    function handleactiveitemtheme() {184        $('.theme-color > a.active-item-theme').on("click", function() {185            var activeitemtheme = $(this).attr("active-item-theme");186            $('.pcoded-navbar').attr("active-item-theme", activeitemtheme);187            setCookie("active-item-theme", activeitemtheme, noofdays);188        });189    };190    handleactiveitemtheme();191    /* Active Item Theme Change function Close */192    /* Theme background pattren Change function Start */193    function handlethemebgpattern() {194        $('.theme-color > a.themebg-pattern').on("click", function() {195            var themebgpattern = $(this).attr("themebg-pattern");196            $('body').attr("themebg-pattern", themebgpattern);197            setCookie("themebg-pattern", themebgpattern, noofdays);198        });199    };200    handlethemebgpattern();201    /* Theme background pattren Change function Close */202    /* Theme Layout Change function start*/203    function handlethemeverticallayout() {204        $('#theme-layout').change(function() {205            if ($(this).is(":checked")) {206                $('.pcoded').attr('vertical-layout', "box");207                setCookie("vertical-layout", "box", noofdays);208                $('#bg-pattern-visiblity').removeClass('d-none');209            } else {210                $('.pcoded').attr('vertical-layout', "wide");211                setCookie("vertical-layout", "wide", noofdays);212                $('#bg-pattern-visiblity').addClass('d-none');213            }214        });215    };216    handlethemeverticallayout();217    /* Theme Layout Change function Close*/218    /* Menu effect change function start*/219    function handleverticalMenueffect() {220        $('#vertical-menu-effect').val('shrink').on('change', function(get_value) {221            get_value = $(this).val();222            $('.pcoded').attr('vertical-effect', get_value);223            setCookie("vertical-effect", get_value, noofdays);224        });225    };226    handleverticalMenueffect();227    /* Menu effect change function Close*/228    /* Vertical Item border Style change function Start*/229    function handleverticalboderstyle() {230        $('#vertical-border-style').val('solid').on('change', function(get_value) {231            get_value = $(this).val();232            $('.pcoded-navbar .pcoded-item').attr('item-border-style', get_value);233        });234    };235    handleverticalboderstyle();236    /* Vertical Item border Style change function Close*/237    /* Vertical Dropdown Icon change function Start*/238    function handleVerticalDropDownIconStyle() {239        $('#vertical-dropdown-icon').val('style1').on('change', function(get_value) {240            get_value = $(this).val();241            $('.pcoded-navbar .pcoded-hasmenu').attr('dropdown-icon', get_value);242        });243    };244    handleVerticalDropDownIconStyle();245    /* Vertical Dropdown Icon change function Close*/246    /* Vertical SubItem Icon change function Start*/247    function handleVerticalSubMenuItemIconStyle() {248        $('#vertical-subitem-icon').val('style5').on('change', function(get_value) {249            get_value = $(this).val();250            $('.pcoded-navbar .pcoded-hasmenu').attr('subitem-icon', get_value);251        });252    };253    handleVerticalSubMenuItemIconStyle();254    /* Vertical SubItem Icon change function Close*/255    /* Vertical Navbar Position change function Start*/256    function handlesidebarposition() {257        $('#sidebar-position').change(function() {258            if ($(this).is(":checked")) {259                $('.pcoded-navbar').attr("pcoded-navbar-position", 'fixed');260                $('.pcoded-header .pcoded-left-header').attr("pcoded-lheader-position", 'fixed');261            } else {262                $('.pcoded-navbar').attr("pcoded-navbar-position", 'absolute');263                $('.pcoded-header .pcoded-left-header').attr("pcoded-lheader-position", 'relative');264            }265        });266    };267    handlesidebarposition();268    /* Vertical Navbar Position change function Close*/269    /* Vertical Header Position change function Start*/270    function handleheaderposition() {271        $('#header-position').change(function() {272            if ($(this).is(":checked")) {273                $('.pcoded-header').attr("pcoded-header-position", 'fixed');274                $('.pcoded-navbar').attr("pcoded-header-position", 'fixed');275                $('.pcoded-main-container').css('margin-top', $(".pcoded-header").outerHeight());276            } else {277                $('.pcoded-header').attr("pcoded-header-position", 'relative');278                $('.pcoded-navbar').attr("pcoded-header-position", 'relative');279                $('.pcoded-main-container').css('margin-top', '0px');280            }281        });282    };283    handleheaderposition();284    /* Vertical Header Position change function Close*/285    /*  collapseable Left Header Change Function Start here*/286    function handlecollapseLeftHeader() {287        $('#collapse-left-header').change(function() {288            if ($(this).is(":checked")) {289                $('.pcoded-header, .pcoded ').removeClass('iscollapsed');290                $('.pcoded-header, .pcoded').addClass('nocollapsed');291            } else {292                $('.pcoded-header, .pcoded').addClass('iscollapsed');293                $('.pcoded-header, .pcoded').removeClass('nocollapsed');294            }295        });296    };297    handlecollapseLeftHeader();298});299/*  collapseable Left Header Change Function Close here*/300function handlemenutype(get_value) {301    $('.pcoded').attr('nav-type', get_value);302};...

Full Screen

Full Screen

newRefer.js

Source:newRefer.js Github

copy

Full Screen

1function SetCookie(name, value)//两个参数,一个是cookie的名子,2{3    var Days = 30; //此 cookie 将被保存 30天4    var exp = new Date();    //new Date("December 31, 9998");5    exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);6    document.cookie = name + "=" + encodeURIComponent(value) + ";domain=.ppdai.com" + ";expires=" + exp.toGMTString() + ";path=/";7}8function getCookie(name)//取cookies函数        9{10    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));11    if (arr != null) {12        var cookieValue=unescape(arr[2]);13            if(cookieValue!=undefined&& cookieValue.length>0)14            {15                return unescape(arr[2]); 16            } 17            return null;18        }19    return null;20}21function delCookie(name)//删除cookie22{23    var exp = new Date();24    exp.setTime(exp.getTime() - 1);25    var cval = getCookie(name);26    if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();27}28Date.prototype.format = function () {29    var d = new Date();30    var year = d.getFullYear();31    var month = d.getMonth() + 1;32    var day = d.getDate();33    var hours = d.getHours();34    var minutes = d.getMinutes();35    var seconds = d.getSeconds();36    return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;37}38function getRefer(currentUrl, fromUrl) {39    var referID = 0;40    var regSourceId = 0;41    if (fromUrl.indexOf("http://www.baidu") != -1 && (currentUrl == "http://www.ppdai.com/default.htm" || currentUrl == "http://www.ppdai.com/default.htm")) { //zhangyan modify42        regSourceId = 2;43    } else if (fromUrl.indexOf("http://www.google") != -1 && (currentUrl == "http://www.ppdai.com/default.htm" || currentUrl == "http://www.ppdai.com/default.htm")) { //zhangyan modify44        regSourceId = 1;45    } else if ((fromUrl.indexOf("http://www.sogou") != -1 || fromUrl.indexOf("http://so") != -1) && (currentUrl == "http://www.ppdai.com/default.htm" || currentUrl == "http://www.ppdai.com/default.htm")) {46	regSourceId = 4;47    }else if (currentUrl.indexOf("jifenbao.html") != -1) {48        referID = 176435;49        regSourceId = 21;50    } else if (fromUrl.indexOf("bidalipay.aspx") != -1) {51        referID = 176435;52        regSourceId = 21;53    } else if (currentUrl.indexOf("jfbsgsha.aspx") != -1) {54        referID = 176435;55        regSourceId = 21;56    } else if (currentUrl.indexOf("regsourceid=42") != -1) { //zhangyan add57        regSourceId = 42;58    } else if (currentUrl.indexOf("regsourceid=41") != -1) { //zhangyan add59        regSourceId = 41;60    } else if (currentUrl.indexOf("regsourceid=45") != -1) {61        regSourceId = 45;62    } else if (currentUrl.indexOf("regsourceid=46") != -1){63        regSourceId = 46;64    } else if (referID != 0 && referID != 179353) {65        regSourceId = 31;66    }else if(currentUrl.indexOf("landing14.html") != -1){67	regSourceId = 37;68    }69    return { ReferID: referID, RegSourceId: regSourceId };70}71function isFromLandingPage(url, landingPages) {72    var isLandingPage = false;73    for (var i = 0; i < landingPages.length; i++) {74        if (url.indexOf(landingPages[i]) != -1) {75            isLandingPage = true;76            break;77        }78    }79    return isLandingPage;80}81function init() {82    var fromUrl = document.referrer.toLowerCase();     //来源url地址83    var currentUrl = window.location.href.toLowerCase();84    var referValue = getRefer(currentUrl, fromUrl);85    var timestamp = new Date().format();86   // delCookie("currentUrl");//20150918 by frontend87    if(getCookie("regSourceId") == null ||getCookie("referID") == null ||getCookie("referDate") == null||getCookie("currentUrl") == null)88    {89         SetCookie("regSourceId", referValue.RegSourceId);90         SetCookie("referID", referValue.ReferID);91         SetCookie("fromUrl", fromUrl);92         SetCookie("referDate", timestamp);93         SetCookie("currentUrl", currentUrl);94    }95	96	if(getCookie("currentUrl").indexOf(currentUrl.split('?')[0])<0 || getCookie("currentUrl").indexOf(currentUrl.split('%3F')[0])<0){97		/* SetCookie("regSourceId", referValue.RegSourceId);98         SetCookie("referID", referValue.ReferID);99         SetCookie("fromUrl", fromUrl);100         SetCookie("referDate", timestamp);*/101         SetCookie("currentUrl", currentUrl);102	}103	104    if(currentUrl.indexOf("remarketing")>-1)105    {106          SetCookie("regSourceId", referValue.RegSourceId);107         SetCookie("referID", referValue.ReferID);108         SetCookie("fromUrl", fromUrl);109         SetCookie("referDate", timestamp);110         SetCookie("currentUrl", currentUrl);111    }112    if (fromUrl.length > 0 && fromUrl.indexOf("ppdai.com") < 0) {113        SetCookie("registerurl", currentUrl);114        SetCookie("registersourceurl", fromUrl);115    }116}...

Full Screen

Full Screen

cookie.test.js

Source:cookie.test.js Github

copy

Full Screen

1const mock = require('../../mock')2const load = require('../../../src/template/adapter')3const Cookie = load('Cookie')4test('cookie', async () => {5    const cookie = new Cookie()6    const url1 = 'http://sub.host.com/p/a/t/h?query=string#hash'7    const url2 = 'http://xxx.sub.host.com/p/a/t/h?query=string#hash'8    const url3 = 'http://sub2.host.com/p/a/t/h?query=string#hash'9    const url4 = 'https://sub.host.com/p/a/t/h?query=string#hash'10    // key-value11    cookie.setCookie('aaa=bbb', url1)12    expect(cookie.getCookie(url1)).toBe('aaa=bbb')13    cookie.setCookie('ccc=ddd\nasdf', url1)14    cookie.setCookie('eee=fff;asdf', url1)15    cookie.setCookie('ggg=;asdf', url1)16    cookie.setCookie('hhh\n=;asdf', url1)17    expect(cookie.getCookie(url1)).toBe('aaa=bbb; ccc=ddd; eee=fff; ggg=')18    cookie.setCookie('aaa=abc', url1)19    cookie.setCookie('ccc=cba\nasdf', url1)20    expect(cookie.getCookie(url1)).toBe('aaa=abc; ccc=cba; eee=fff; ggg=')21    // maxAge22    cookie.setCookie('aaa=bbb; max-age=1', url1)23    await new Promise((resolve, reject) => setTimeout(resolve, 2000))24    expect(cookie.getCookie(url1)).toBe('ccc=cba; eee=fff; ggg=')25    cookie.setCookie('ccc=ddd; max-age=-10', url1)26    expect(cookie.getCookie(url1)).toBe('eee=fff; ggg=')27    cookie.setCookie('eee=fff; max-age=', url1)28    expect(cookie.getCookie(url1)).toBe('eee=fff; ggg=')29    cookie.setCookie('eee=fff; max-age=abc', url1)30    expect(cookie.getCookie(url1)).toBe('eee=fff; ggg=')31    // expires32    cookie.setCookie(`eee=fff; expires=${(new Date(Date.now())).toUTCString()}`, url1)33    expect(cookie.getCookie(url1)).toBe('ggg=')34    cookie.setCookie(`ggg=fff; expires=${(new Date(Date.now() + 1000)).toUTCString()}`, url1)35    expect(cookie.getCookie(url1)).toBe('ggg=fff')36    await new Promise((resolve, reject) => setTimeout(resolve, 2000))37    expect(cookie.getCookie(url1)).toBe('')38    // max-age 优先于 expires39    cookie.setCookie(`aaa=bbb; max-age=1000; expires=${(new Date(Date.now())).toUTCString()}`, url1)40    expect(cookie.getCookie(url1)).toBe('aaa=bbb')41    cookie.setCookie(`aaa=bbb; max-age=0; expires=${(new Date(Date.now() + 1000 * 1000)).toUTCString()}`, url1)42    expect(cookie.getCookie(url1)).toBe('')43    // domain44    cookie.setCookie('aaa=bbb; domain=host.com', url1)45    cookie.setCookie('abc=cba; domain=sub.host.com', url1)46    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba')47    cookie.setCookie('ccc=ddd; domain=xxx.sub.host.com', url1) // 不符合 domain,不写入 cookie48    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba')49    cookie.setCookie('eee=fff; domain=xxx.sub.host.com', url2)50    cookie.setCookie('ggg=; domain=sub2.host.com', url3)51    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba')52    expect(cookie.getCookie(url2)).toBe('aaa=bbb; abc=cba; eee=fff')53    expect(cookie.getCookie(url3)).toBe('aaa=bbb; ggg=')54    // path55    cookie.setCookie('eee=fff; path=/p/a/t/x', url1)56    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba')57    cookie.setCookie('ggg=hhh; path=/p/a/t', url1)58    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba; ggg=hhh')59    cookie.setCookie('iii=jjj; path=/p/a/x', url1)60    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba; ggg=hhh')61    cookie.setCookie('kkk=lll; path=/p/a', url1)62    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll')63    64    // secure65    cookie.setCookie('mmm=nnn; secure', url1)66    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll')67    expect(cookie.getCookie(url4)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll; mmm=nnn')68    69    // httpOnly70    cookie.setCookie('ooo=ppp; httpOnly', url1)71    expect(cookie.getCookie(url1)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll; ooo=ppp')72    expect(cookie.getCookie(url4)).toBe('aaa=bbb; abc=cba; ggg=hhh; kkk=lll; mmm=nnn')...

Full Screen

Full Screen

logout.js

Source:logout.js Github

copy

Full Screen

1function LogOut() {2	window.alert('Hasta la proxima!');3	setCookie('username', '', -1);4	setCookie('name', '', -1);5	setCookie('password', '', -1);6	setCookie('email', '', -1);7	setCookie('groupid', '', -1);8	setCookie('troll', '', -1);9	setCookie('votedBy', '', -1);10	setCookie('vote', '', -1);11	setCookie('points', '', -1);12	setCookie('points_max', '', -1);13	window.location = "/index.html";14}15function setCookie(cname, cvalue, exdays) {16	var d = new Date();17	d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));18	var expires = "expires=" + d.toUTCString();19	document.cookie = cname + "=" + cvalue + "; " + expires;20}21function reloadCookies() {22	var u = getCookie('username');23	var p = getCookie('password');24	var url = API_BASE_URL + '/users/byUsername/' + u;25	$.ajax({26		headers : {27			'Authorization' : "Basic " + btoa(u + ':' + p)28		},29		url : url,30		type : 'GET',31		crossDomain : true,32		dataType : 'json',33		contentType : 'application/vnd.uTroll.api.user+json',34	}).done(function(data, status, jqxhr) {35		var uProf = data;36		// Cambiar por el uso de setCookie37		setCookie("name", uProf.name, 1);38		setCookie("email", uProf.email, 1);39		setCookie("points", uProf.points, 1);40		setCookie("points_max", uProf.points_max, 1);41		setCookie("troll", uProf.troll, 1);42		setCookie("votedBy", uProf.votedBy, 1);43		setCookie("vote", uProf.vote, 1);44		setCookie("groupid", uProf.groupid, 1);45	}).fail(function() {46		window.alert("ERROR: Cookies Error");47	});48}49function voteTroll(voted) {50	var u = getCookie('username');51	var p = getCookie('password');52	var url = API_BASE_URL + '/users/vote/' + voted;53	var data = JSON.stringify("");54	$.ajax({55		headers : {56			'Authorization' : "Basic " + btoa(u + ':' + p)57		},58		url : url,59		type : 'PUT',60		crossDomain : true,61		dataType : 'json',62		contentType : 'application/vnd.uTroll.api.user+json',63		data : data,64	}).done(function(data, status, jqxhr) {65		$("#comments_space").text('');66		getComments();67	}).fail(function() {68		window.alert("FAIL Vote");69	});70}71function getCookie(cname) {72	var name = cname + "=";73	var ca = document.cookie.split(';');74	for (var i = 0; i < ca.length; i++) {75		var c = ca[i];76		while (c.charAt(0) == ' ')77			c = c.substring(1);78		{79			if (c.indexOf(name) == 0)80				return c.substring(name.length, c.length);81			{82			}83		}84	}85	return "";...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.setCookie('name', 'value')2cy.setCookie('name', 'value', { domain: '.example.com' })3cy.setCookie('name', 'value', { domain: 'subdomain.example.com' })4cy.setCookie('name', 'value', { domain: 'example.com' })5cy.setCookie('name', 'value', { domain: 'localhost' })6cy.setCookie('name', 'value', { domain: '

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.setCookie('cookieName', 'cookieValue')2cy.getCookie('cookieName')3cy.clearCookies()4cy.clearLocalStorage()5cy.clearLocalStorageItem('localStorageItemName')6cy.getLocalStorage()7cy.getLocalStorageItem('localStorageItemName')8cy.setLocalStorage('localStorageItemName', 'localStorageItemValue')9cy.getLocation()10cy.getPath()11cy.getPort()12cy.getProtocol()13cy.getUrl()14cy.getUrlHash()15cy.getUrlSearch()16cy.getUrlPathname()17cy.getWindow()

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.setCookie('cookieName', 'cookieValue')2{3  "env": {4  }5}6Cypress.Cookies.defaults({7  preserve: (cookie) => {8  }9})10Cypress.Cookies.defaults({11  whitelist: (cookie) => {12  }13})14Cypress.Cookies.defaults({15  preserve: (cookie) => {16  }17})18Cypress.Cookies.defaults({19  whitelist: (cookie) => {20  }21})22Cypress.Cookies.defaults({23  preserve: (cookie) => {24    return cookie.name.startsWith('cookieName')25  }26})27Cypress.Cookies.defaults({28  whitelist: (cookie) => {29    return cookie.name.startsWith('cookieName')30  }31})32Cypress.Cookies.defaults({33  preserve: (cookie) => {34    return cookie.name.startsWith('cookieName') && cookie.name.endsWith('cookieValue')35  }36})37Cypress.Cookies.defaults({38  whitelist: (cookie) => {39    return cookie.name.startsWith('cookieName') && cookie.name.endsWith('cookieValue')40  }41})42Cypress.Cookies.defaults({43  preserve: (cookie) => {44    return cookie.name.startsWith('cookieName') && cookie.name.endsWith('cookieValue') && cookie.domain.startsWith('cookieDomain')45  }46})47Cypress.Cookies.defaults({48  whitelist: (cookie) => {49    return cookie.name.startsWith('cookieName') && cookie.name.endsWith

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.setCookie('cookieName', 'cookieValue')2cy.getCookie('cookieName').should('have.property', 'value', 'cookieValue')3describe('My First Test', function() {4  it('Does not do much!', function() {5    cy.contains('type').click()6    cy.url().should('include', '/commands/actions')7    cy.get('.action-email')8      .type('

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful