Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.91 KB | None | 0 0
  1. // ==UserScript==
  2. // @name ELTP Live Boxscore (new layout)
  3. // @version 1.2
  4. // @include http://*.koalabeast.com/groups/*
  5. // @include http://*.jukejuice.com/groups/*
  6. // @include http://*.newcompte.*/groups/*
  7. // @author RonSpawnson and modified by Chuck_Finley
  8. // @grant GM_addStyle
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  10. // ==/UserScript==
  11.  
  12.  
  13. /*jshint multistr: true */
  14. var redHalfScoreBackgroundLoc = "http://i.imgur.com/eJRCXTo.png";
  15. //var redAggregateScoreBackgroundLoc = "http://i.imgur.com/ZgYryxg.png"; //GREEN
  16. //var redAggregateScoreBackgroundLoc = "http://i.imgur.com/YQbcwL2.png"; //ORANGE
  17. var redAggregateScoreBackgroundLoc = "http://i.imgur.com/eJQNO3U.png"; //RED
  18. //var redAggregateScoreBackgroundLoc = "http://i.imgur.com/lFB87vJ.png";//BLUE
  19. var blueHalfScoreBackgroundLoc = "http://i.imgur.com/eJRCXTo.png";
  20. var blueAggregateScoreBackgroundLoc = "http://i.imgur.com/lFB87vJ.png"; //BLUE
  21. //var blueAggregateScoreBackgroundLoc = "http://imgur.com/O9IDRyp.png"; //BLACK
  22. var redAggregateScoreBgLoc = "http://i.imgur.com/LbvoXUR.png";
  23. var blueAggregateScoreBgLoc = "http://i.imgur.com/LbvoXUR.png";
  24.  
  25. var boxscoreFontSize = "86px";
  26. var boxscoreTeamFontSize = "70px";
  27.  
  28. var domain = ".koalabeast.com";
  29. //var domain = ".newcompte.fr";
  30.  
  31. // Insert google font
  32. //element = document.getElementsByTagName('head');
  33. //newElement = "<link href='http://fonts.googleapis.com/css?family=//Play' rel='stylesheet' type='text/css'>";
  34. //element[0].insertAdjacentHTML('afterend', newElement);
  35.  
  36. //Modifies group page to fit scoreboard
  37. GM_addStyle(
  38. '.header {padding-top: 0px}' +
  39. '.container header-main .header-top {display: none}' +
  40. '.header-top {display: none}' +
  41. '.header-title {display: none}' +
  42. '.group .group-exit {margin-top: 0; margin-left: 4px;}' +
  43. '#group { width:auto; height: 646px; overflow-y: auto;}' +
  44. 'body {margin-bottom: 0px;}' +
  45. '#header {margin-bottom: 0px;}' +
  46. '#red-team {width:50%;}' +
  47. '#blue-team {width:50%;}' +
  48. '#spectators {width:100%;}' +
  49. '#waiting {width:100%;}' +
  50. '.col-md-7 {width:33%;}' +
  51. '.col-md-5 {width:33%;}' +
  52. '#private-settings {position: absolute; left: 100%; width: 100%; top:-380px}'+
  53. '.chat-log {height: 330px !important}' +
  54. '.footer {display:none}' +
  55. '.group .player-options {display: none}' +
  56. '.group .player-options.open {display: inherit}'
  57. );
  58.  
  59. jQuery(".group .group-exit").detach().prependTo('.group .group-settings');
  60.  
  61. initJqueryCookiePlugin();
  62. createContainer();
  63. createTeamEntrySection();
  64. setupTeamEntryEventListeners();
  65. createTeamInversionSection();
  66. createBoxscoreSection();
  67. loadInversions();
  68. saveInversions();
  69. loadBoxscores();
  70. setupBoxscoreEventListeners();
  71.  
  72.  
  73. function createContainer() {
  74. var element = document.getElementById("group");
  75. var newElement = '<div id="boxscoreOutline" style="display:block;position:;left:0px;top:0px;width:1900px;border:0px solid rgba(255,255,255,0.20)"></div>';
  76. element.insertAdjacentHTML( 'afterend', newElement );
  77.  
  78. element = document.getElementById("boxscoreOutline");
  79. newElement = '<div id="boxscoreContainer" style="margin-left:10px;margin-top:12px"></div>';
  80. element.insertAdjacentHTML( 'beforeend', newElement );
  81. }
  82.  
  83. function createTeamEntrySection() {
  84. var element = document.getElementById("boxscoreContainer");
  85. var newElement = '<div id="teamEntry" style="margin-bottom:180px"> \
  86. <label for="redTeamName">Red Team: </label><input class="teamNameInput" id="redTeamName" name="redTeamName" style="margin-left:2px; color: black;"/>\
  87. <label for="blueTeamName"> Blue Team: </label><input class="teamNameInput" id="blueTeamName" name="blueTeamName" style="margin-top:10px; color: black;"/>\
  88. </div>';
  89. element.insertAdjacentHTML( 'beforeend', newElement );
  90. }
  91.  
  92. function createTeamInversionSection() {
  93. var element = document.getElementById("teamEntry");
  94. var newElement = '<div id="teamInversionSelection" style="margin-bottom:-240px">Red team is blue in: \
  95. <input type="checkbox" name="teamInversionSelection" id="g1h1Inversion" value="g1h1Inversion">g1h1\
  96. <input type="checkbox" name="teamInversionSelection" id="g1h2Inversion" value="g1h2Inversion" checked="checked">g1h2 \
  97. <input type="checkbox" name="teamInversionSelection" id="g2h1Inversion" value="g2h1Inversion">g2h1 \
  98. <input type="checkbox" name="teamInversionSelection" id="g2h2Inversion" value="g2h2Inversion" checked="checked">g2h2 \
  99. <input type="checkbox" name="teamInversionSelection" id="g3h1Inversion" value="g3h1Inversion">g3h1 \
  100. <input type="checkbox" name="teamInversionSelection" id="g3h2Inversion" value="g3h2Inversion" checked="checked">g3h2 \</div>';
  101. element.insertAdjacentHTML( 'afterend', newElement );
  102.  
  103. $("input[name='teamInversionSelection']").each(function () {
  104. $(this).change(function() {
  105. saveInversions();
  106. loadBoxscores();
  107. });
  108. });
  109. }
  110.  
  111.  
  112. function createBoxscoreSection() {
  113. var element = document.getElementById("boxscoreContainer");
  114. var newElement = '<div id="boxscore" style="margin-top:20px margin-left:320px"><table style="width:30%"> \
  115. <tr style="vertical-align:top"> \
  116. <td vertical-align:top"></td> \
  117. ' + generateBoxscoreInput("g1h1.RedScoreInput", "", true) + ' \
  118. ' + generateBoxscoreInput("g1h2.RedScoreInput", "", true) + ' \
  119. ' + generateBoxscoreInput("g1aggregate.RedScoreInput", "", false) + ' \
  120. ' + generateBoxscoreInput("g2h1.RedScoreInput", "", true) + ' \
  121. ' + generateBoxscoreInput("g2h2.RedScoreInput", "", true) + ' \
  122. ' + generateBoxscoreInput("g2aggregate.RedScoreInput", "", false) + ' \
  123. ' + generateBoxscoreInput("g3h1.RedScoreInput", "", true) + ' \
  124. ' + generateBoxscoreInput("g3h2.RedScoreInput", "", true) + ' \
  125. ' + generateBoxscoreInput("g3aggregate.RedScoreInput", "", false) + ' \
  126. </tr> \
  127. <tr> \
  128. ' + generateTeamnameEntryRed($.cookie("redTeamName"), redAggregateScoreBackgroundLoc) + ' \
  129. ' + generateBoxscoreEntryRed2("g1h1.RedScore", redHalfScoreBackgroundLoc, redAggregateScoreBgLoc, "") + ' \
  130. ' + generateBoxscoreEntryRed("g1h2.RedScore", redHalfScoreBackgroundLoc, redAggregateScoreBgLoc, "") + ' \
  131. ' + generateBoxscoreEntryRed("g1aggregate.RedScore", redAggregateScoreBackgroundLoc, redAggregateScoreBackgroundLoc, "") + ' \
  132. ' + generateBoxscoreEntryRed2("g2h1.RedScore", redHalfScoreBackgroundLoc, redAggregateScoreBgLoc, "") + ' \
  133. ' + generateBoxscoreEntryRed("g2h2.RedScore", redHalfScoreBackgroundLoc, redAggregateScoreBgLoc, "") + ' \
  134. ' + generateBoxscoreEntryRed("g2aggregate.RedScore", redAggregateScoreBackgroundLoc, redAggregateScoreBackgroundLoc, "") + ' \
  135. ' + generateBoxscoreEntryRed2("g3h1.RedScore", redHalfScoreBackgroundLoc, redAggregateScoreBgLoc, "") + ' \
  136. ' + generateBoxscoreEntryRed("g3h2.RedScore", redHalfScoreBackgroundLoc, redAggregateScoreBgLoc, "") + ' \
  137. ' + generateBoxscoreEntryRed("g3aggregate.RedScore", redAggregateScoreBackgroundLoc, redAggregateScoreBackgroundLoc, "") + ' \
  138. </tr> \
  139. <tr> \
  140. ' + generateTeamnameEntryBlue($.cookie("blueTeamName"), blueAggregateScoreBackgroundLoc) + ' \
  141. ' + generateBoxscoreEntryBlue2("g1h1.BlueScore", blueHalfScoreBackgroundLoc, blueAggregateScoreBgLoc, "") + ' \
  142. ' + generateBoxscoreEntryBlue("g1h2.BlueScore", blueHalfScoreBackgroundLoc, blueAggregateScoreBgLoc, "") + ' \
  143. ' + generateBoxscoreEntryBlue("g1aggregate.BlueScore", blueAggregateScoreBackgroundLoc, blueAggregateScoreBackgroundLoc, "") + ' \
  144. ' + generateBoxscoreEntryBlue2("g2h1.BlueScore", blueHalfScoreBackgroundLoc, blueAggregateScoreBgLoc, "") + ' \
  145. ' + generateBoxscoreEntryBlue("g2h2.BlueScore", blueHalfScoreBackgroundLoc, blueAggregateScoreBgLoc, "") + ' \
  146. ' + generateBoxscoreEntryBlue("g2aggregate.BlueScore", blueAggregateScoreBackgroundLoc, blueAggregateScoreBackgroundLoc, "") + ' \
  147. ' + generateBoxscoreEntryBlue2("g3h1.BlueScore", blueHalfScoreBackgroundLoc, blueAggregateScoreBgLoc, "") + ' \
  148. ' + generateBoxscoreEntryBlue("g3h2.BlueScore", blueHalfScoreBackgroundLoc, blueAggregateScoreBgLoc, "") + ' \
  149. ' + generateBoxscoreEntryBlue("g3aggregate.BlueScore", blueAggregateScoreBackgroundLoc, blueAggregateScoreBackgroundLoc, "") + ' \
  150. </tr> \
  151. <tr> \
  152. <td vertical-align:top"></td> \
  153. ' + generateBoxscoreInput("g1h1.BlueScoreInput", "", true) + ' \
  154. ' + generateBoxscoreInput("g1h2.BlueScoreInput", "", true) + ' \
  155. ' + generateBoxscoreInput("g1aggregate.BlueScoreInput", "", false) + ' \
  156. ' + generateBoxscoreInput("g2h1.BlueScoreInput", "", true) + ' \
  157. ' + generateBoxscoreInput("g2h2.BlueScoreInput", "", true) + ' \
  158. ' + generateBoxscoreInput("g2aggregate.BlueScoreInput", "", false) + ' \
  159. ' + generateBoxscoreInput("g3h1.BlueScoreInput", "", true) + ' \
  160. ' + generateBoxscoreInput("g3h2.BlueScoreInput", "", true) + ' \
  161. ' + generateBoxscoreInput("g3aggregate.BlueScoreInput", "", false) + ' \
  162. </tr> \
  163. </table></div>';
  164. element.insertAdjacentHTML( 'beforeend', newElement );
  165. }
  166.  
  167. function generateBoxscoreEntryRed(id, imageLoc, imagebgLoc, score) {
  168. return '<td style="width:80px;vertical-align:top;background-color: #ff0000; background-image: url(' + imagebgLoc + ')"><div id="' + id + '" style="margin-left:0px; width:110px; height:0px; line-height:90px; background-image: url(' + imagebgLoc + ');">' + createFontElement(score, boxscoreFontSize) + '</div></td>';
  169. }
  170. function generateBoxscoreEntryBlue(id, imageLoc, imagebgLoc, score) {
  171. return '<td style="width:80px;vertical-align:top;background-color: #0000ff; background-image: url(' + imagebgLoc + ')"><div id="' + id + '" style="margin-left:0px; width:110px; height:0px; line-height:90px; background-image: url(' + imagebgLoc + ');">' + createFontElement(score, boxscoreFontSize) + '</div></td>';
  172. }
  173.  
  174. function generateBoxscoreEntryRed2(id, imageLoc, imagebgLoc, score) {
  175. return '<td style="width:80px;vertical-align:top;background-color: #ff0000; background-image: url(' + imagebgLoc + ')"><div id="' + id + '" style="margin-left:0px; width:109px; height:0px; line-height:90px; background-image: url(' + imagebgLoc + ');">' + createFontElement(score, boxscoreFontSize) + '</div></td>';
  176. }
  177. function generateBoxscoreEntryBlue2(id, imageLoc, imagebgLoc, score) {
  178. return '<td style="width:80px;vertical-align:top;background-color: #0000ff; background-image: url(' + imagebgLoc + ')"><div id="' + id + '" style="margin-left:0px; width:109px; height:0px; line-height:90px; background-image: url(' + imagebgLoc + ');">' + createFontElement(score, boxscoreFontSize) + '</div></td>';
  179. }
  180.  
  181. function generateTeamnameEntryRed(id, imageLoc) {
  182. return '<td style="vertical-align:top;background-color: #ff0000;background-image: url(' + imageLoc + ')"><div id="' + id + '" style="margin-left:0px; width:800px; height:90px; line-height:90px;">' + createFontElementAggr(id, boxscoreTeamFontSize) + '</div></td>';
  183. }
  184.  
  185. function generateTeamnameEntryBlue(id, imageLoc) {
  186. return '<td style="vertical-align:top;background-color: #0000ff;background-image: url(' + imageLoc + ')"><div id="' + id + '" style="margin-left:0px; width:800px; height:90px; line-height:90px;">' + createFontElementAggr(id, boxscoreTeamFontSize) + '</div></td>';
  187. }
  188.  
  189. function createFontElement(num, size) {
  190. return '<p style="text-align:center; font-weight:normal; color: black; margin-top:-4px; font-family:\'Play\'; font-size:' + size + '">' + num + '</p>';
  191. }
  192.  
  193. function createFontElementAggr(num, size) {
  194. return '<p style="text-align:center; font-weight:normal; margin-top:-4px; font-family:\'Play\'; font-size:' + size + '">' + num + '</p>';
  195. }
  196.  
  197. function generateBoxscoreInput(id, value, enabled) {
  198. var disabledSection = enabled ? "" : "disabled";
  199. return '<td style="width:91px; color: black; vertical-align:top"><div class="boxscoreInput" id="teamBoxscoreInputs" style="margin-left:15px; margin-top:5px; margin-bottom:5px; width:0px"><input type="text" id=' + id + ' name="' + id + '" value="' + value + '" style="width:77px;text-align:center" ' + disabledSection + '></div></td>';
  200. }
  201.  
  202. function setupTeamEntryEventListeners() {
  203. $(".teamNameInput").change(overrideTeamName);
  204. }
  205.  
  206. function overrideTeamName(obj) {
  207. var name = obj.target.name;
  208. var value = obj.target.value;
  209.  
  210. console.log("Name is: " + name);
  211. console.log("Value is: " + value);
  212.  
  213. // add new cookie
  214. var options = {
  215. domain: domain,
  216. path: '/'
  217. };
  218.  
  219. //console.log("replacing " + nameWithoutInput + " with " + obj.target.value);
  220. $.cookie(name, value, options);
  221. }
  222.  
  223. function setupBoxscoreEventListeners() {
  224. $(".boxscoreInput").change(overrideBoxscore);
  225. }
  226.  
  227. function overrideBoxscore(obj) {
  228. // Remove "input" from id and escape period
  229. var nameWithoutInput = obj.target.name.replace("Input", "");
  230.  
  231. var sections = nameWithoutInput.split(".");
  232. var period = sections[0];
  233. var teamColor = sections[1].replace("Score", "");
  234.  
  235. var invert = $.cookie(period + "Inversion");
  236. if (invert == "true") {
  237. teamColor = invertTeamColor(teamColor);
  238. }
  239. nameWithoutInput = period + "." + teamColor + "Score";
  240.  
  241. var name = nameWithoutInput.replace(".", "\\.");
  242.  
  243. $("#" + name).html(createFontElement(obj.target.value, boxscoreFontSize));
  244.  
  245. // add new cookie
  246. var options = {
  247. domain: domain,
  248. path: '/'
  249. };
  250.  
  251. //console.log("replacing " + nameWithoutInput + " with " + obj.target.value);
  252. $.cookie(nameWithoutInput, obj.target.value, options);
  253. loadBoxscores();
  254. }
  255.  
  256. function loadBoxscores() {
  257. for (game = 1; game < 4; game++) {
  258. for (half = 1; half < 3; half++) {
  259. var invert = $.cookie("g" + game + "h" + half + "Inversion");
  260. updateScore("Red", invert);
  261. updateScore("Blue", invert);
  262. }
  263. // calculate aggregate
  264. updateAggregate("Red", game);
  265. updateAggregate("Blue", game);
  266. }
  267.  
  268. setupBoxscoreEventListeners();
  269. }
  270.  
  271. function updateScore(teamColor, invert) {
  272. var scoreName = "g" + game + "h" + half + "." + teamColor + "Score";
  273. var invertedScoreName = "g" + game + "h" + half + "." + invertTeamColor(teamColor) + "Score";
  274. if (invert == "true") {
  275. var score = $.cookie(invertedScoreName);
  276. } else {
  277. var score = $.cookie(scoreName);
  278. }
  279.  
  280. if (score !== undefined) {
  281. // escape period
  282. var escapedScoreName = scoreName.replace(".", "\\.");
  283.  
  284. // update score
  285. $("#" + escapedScoreName).html(createFontElement(score, boxscoreFontSize));
  286. //console.log("Setting " + teamColor + " score to " + score);
  287.  
  288. // update score input
  289. $("#" + escapedScoreName + "Input").parent().parent().replaceWith(generateBoxscoreInput(scoreName + "Input", score, true));
  290. }
  291. }
  292.  
  293. function updateAggregate(teamColor, game) {
  294. console.log("***Updating aggregate for game " + game + " and teamColor: " + teamColor);
  295. var aggregateScoreName = "g" + game + "aggregate." + teamColor + "Score";
  296.  
  297. var score = ""; // starts blank
  298. for (var half = 1; half < 3; half++) {
  299. // If either half scores are undefined for this game, exit
  300. if (($.cookie("g" + game + "h1" + "." + teamColor + "Score") === undefined) || ($.cookie("g" + game + "h2" + "." + teamColor + "Score") === undefined)) {
  301. continue;
  302. }
  303.  
  304. var invert = $.cookie("g" + game + "h" + half + "Inversion");
  305. console.log("invert is: " + invert);
  306. var tempTeamColor = teamColor;
  307. if (invert == "true") {
  308. tempTeamColor = invertTeamColor(teamColor);
  309. }
  310. var halfScore = $.cookie("g" + game + "h" + half + "." + tempTeamColor + "Score");
  311. console.log("Half score for g" + game + "h" + half + "." + tempTeamColor + "Score: " + halfScore);
  312.  
  313. if (halfScore !== undefined) {
  314. // If we are saving a score and the score is blank, set it to 0.
  315. if (score === "") {
  316. score = 0;
  317. }
  318. score = score + parseInt(halfScore);
  319. }
  320. }
  321. var escapedScoreName = aggregateScoreName.replace(".", "\\.");
  322. $("#" + escapedScoreName).html(createFontElementAggr(score, boxscoreFontSize));
  323.  
  324. // persist aggregate score to cookie
  325. var options = {
  326. domain: domain,
  327. path: '/'
  328. }
  329. ;
  330. $.cookie(aggregateScoreName, score, options);
  331.  
  332. }
  333.  
  334. function invertTeamColor(teamColor) {
  335. if (teamColor == "Red") {
  336. return "Blue";
  337. } else {
  338. return "Red";
  339. }
  340. }
  341.  
  342. function loadInversions() {
  343. for (game = 1; game < 3; game++) {
  344. for (half = 1; half < 3; half++) {
  345. var name = "g" + game + "h" + half + "Inversion";
  346. var invert = $.cookie(name);
  347.  
  348. if (invert !== undefined) {
  349. $("#" + name).prop('checked', invert === "true"); // Check the box if invert is true, else unchecked
  350. }
  351. // console.log("name: " + name + " invert: " + invert);
  352. }
  353. }
  354. }
  355.  
  356. function saveInversions() {
  357. // add new cookie
  358. var options = {
  359. domain: domain,
  360. path: '/'
  361. };
  362.  
  363. $("input[name='teamInversionSelection']").each(function () {
  364. $.cookie(this.value, this.checked, options);
  365. });
  366. }
  367.  
  368. //////////////////////////////////
  369. // JQUERY COOKIE PLUGIN FOLLOWS //
  370. //////////////////////////////////
  371. function initJqueryCookiePlugin() {
  372.  
  373. (function (factory) {
  374. if (typeof define === 'function' && define.amd) {
  375. // AMD (Register as an anonymous module)
  376. define(['jquery'], factory);
  377. } else if (typeof exports === 'object') {
  378. // Node/CommonJS
  379. module.exports = factory(require('jquery'));
  380. } else {
  381. // Browser globals
  382. factory(jQuery);
  383. }
  384. }(function ($) {
  385.  
  386. var pluses = /\+/g;
  387.  
  388. function encode(s) {
  389. return config.raw ? s : encodeURIComponent(s);
  390. }
  391.  
  392. function decode(s) {
  393. return config.raw ? s : decodeURIComponent(s);
  394. }
  395.  
  396. function stringifyCookieValue(value) {
  397. return encode(config.json ? JSON.stringify(value) : String(value));
  398. }
  399.  
  400. function parseCookieValue(s) {
  401. if (s.indexOf('"') === 0) {
  402. // This is a quoted cookie as according to RFC2068, unescape...
  403. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  404. }
  405.  
  406. try {
  407. // Replace server-side written pluses with spaces.
  408. // If we can't decode the cookie, ignore it, it's unusable.
  409. // If we can't parse the cookie, ignore it, it's unusable.
  410. s = decodeURIComponent(s.replace(pluses, ' '));
  411. return config.json ? JSON.parse(s) : s;
  412. } catch(e) {}
  413. }
  414.  
  415. function read(s, converter) {
  416. var value = config.raw ? s : parseCookieValue(s);
  417. return $.isFunction(converter) ? converter(value) : value;
  418. }
  419.  
  420. var config = $.cookie = function (key, value, options) {
  421.  
  422. // Write
  423.  
  424. if (arguments.length > 1 && !$.isFunction(value)) {
  425. options = $.extend({}, config.defaults, options);
  426.  
  427. if (typeof options.expires === 'number') {
  428. var days = options.expires, t = options.expires = new Date();
  429. t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
  430. }
  431.  
  432. return (document.cookie = [
  433. encode(key), '=', stringifyCookieValue(value),
  434. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  435. options.path ? '; path=' + options.path : '',
  436. options.domain ? '; domain=' + options.domain : '',
  437. options.secure ? '; secure' : ''
  438. ].join(''));
  439. }
  440.  
  441. // Read
  442.  
  443. var result = key ? undefined : {},
  444. // To prevent the for loop in the first place assign an empty array
  445. // in case there are no cookies at all. Also prevents odd result when
  446. // calling $.cookie().
  447. cookies = document.cookie ? document.cookie.split('; ') : [],
  448. i = 0,
  449. l = cookies.length;
  450.  
  451. for (; i < l; i++) {
  452. var parts = cookies[i].split('='),
  453. name = decode(parts.shift()),
  454. cookie = parts.join('=');
  455.  
  456. if (key === name) {
  457. // If second argument (value) is a function it's a converter...
  458. result = read(cookie, value);
  459. break;
  460. }
  461.  
  462. // Prevent storing a cookie that we couldn't decode.
  463. if (!key && (cookie = read(cookie)) !== undefined) {
  464. result[name] = cookie;
  465. }
  466. }
  467.  
  468. return result;
  469. };
  470.  
  471. config.defaults = {};
  472.  
  473. $.removeCookie = function (key, options) {
  474. // Must not alter options, thus extending a fresh object...
  475. $.cookie(key, '', $.extend({}, options, { expires: -1 }));
  476. return !$.cookie(key);
  477. };
  478.  
  479. }));
  480. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement