├── README.md ├── dependencies └── jquery-cookie.js ├── examples └── examples.js ├── sayt.jquery.json └── source ├── sayt.jquery.js └── sayt.min.jquery.js /README.md: -------------------------------------------------------------------------------- 1 | # Save As You Type 2 | 3 | * ##### Update v.1.4.5 ##### 4 | Added "id" to settings so you can allow several forms to share a common form save. 5 | 6 | * ##### Update v.1.4.4 ##### 7 | Various bug fixes have been implemented. Also, thanks to @npostman you can now specify a prefix to the cookie name to help you have greater control over your code. 8 | 9 | * ##### Update v.1.4.0 ##### 10 | Thanks to @BluntSporks this plugin will now utilize Local Storage if its available instead of a cookie, enabling the saved data stored to be of a much larger amount (~5mb). If local storage is not available it'll default back to a cookie. 11 | 12 | * ##### Update v.1.3.0 #### 13 | Thanks to @georgjaehnig you can now exclude certain fields from being included in the cookie. There are two ways to do this. 14 | 15 | #### Features #### 16 | 17 | This jQuery plugin autosaves (To either Local Storage or a cookie if it's not available) as you type, and autorecovers, form data. Auto saving will save as data is entered or changed. 18 | 19 | You have the ability to disable autosaving and auto recovering, and instead use manual calls for each. You can also manually call an erase cookie feature, and manually call to see if a form actually has saved data. 20 | 21 | Currently, the plugin works for the following form elements: 22 | 23 | * Text boxes 24 | * Text areas 25 | * Select (Single AND multiple) 26 | * Radio buttons 27 | * Check boxes 28 | * Hidden fields 29 | 30 | Tested as working in: 31 | 32 | * IE7 33 | * IE8 34 | * IE9 35 | * Chrome 36 | * Firefox 37 | * Safari 38 | * Opera 39 | 40 | ## Examples 41 | 42 | Default's: 43 | 44 | * autosave: true 45 | * savenow: false 46 | * days: 3 47 | * erase: false 48 | * recover: false 49 | * autorecover: true 50 | * checksaveexists: false - (Returns true or false) 51 | * id: this.attr('id') (defaults to form id) 52 | 53 | ```js 54 | $(function() 55 | { 56 | 57 | /** 58 | * When building your forms, you MUST make sure your form has an ID, and that it's unique 59 | * on the application. 60 | * 61 | * Ie, don't call all forms 'id="form"', even if they are on seperate pages. 62 | */ 63 | 64 | /* 65 | * Attach to a form with default settings 66 | */ 67 | $('#form_id').sayt(); 68 | 69 | 70 | /* 71 | * Attach to a form with custom settings 72 | * 73 | * Autosave disabled (Must use manual save to save anything) 74 | * Autorecover disabled (Must use a manual recover to recover anything) 75 | * Days 7 (Keeps the save cookie for 7 days) 76 | */ 77 | $('#form_id').sayt({'autosave': false, 'autorecover': false, 'days': 7}); 78 | 79 | /* 80 | * Override form id so multiple forms can share one save. 81 | * Useful for initialyzing fields in multiple forms or on different pages 82 | * Or "wizard" style forms where an initial form's values are carried forward 83 | * to the next form in the sequence. 84 | * 85 | * Example: 86 | * The first line will remember the fields typed in the first blank form of class "form_class". 87 | * The second and third line will remember the state of a specific form. 88 | * 89 | * When the second blank form is opened it is first initialized with "form_class" 90 | * and then by its own specific id which being blank does nothing but take on the 91 | * initial values. 92 | * From then on each form remembers it's own values because the second line always 93 | * overwrites the first line. 94 | */ 95 | $('.form_class').sayt({ 'id': 'common' }); //class specific cookie id = prefix + 'common' 96 | $('#form_id_1').sayt(); //id specific cookie id = prefix + 'form_id_1' 97 | $('#form_id_2').sayt(); //id specific cookie id = prefix + 'form_id_2' 98 | 99 | /* 100 | * Check to see if a form has a save 101 | */ 102 | if($('#form_id').sayt({'checksaveexists': true}) == true) 103 | { 104 | console.log('Form has an existing save cookie.'); 105 | } 106 | 107 | 108 | /* 109 | * Perform a manual save 110 | */ 111 | $('#forms_save_button').click(function() 112 | { 113 | $('#form_id').sayt({'savenow': true}); 114 | 115 | console.log('Form data has been saved.'); 116 | return false; 117 | }); 118 | 119 | 120 | /* 121 | * Perform a manual recover 122 | */ 123 | $('#forms_recover_button').click(function() 124 | { 125 | $('#form_id').sayt({'recover': true}); 126 | 127 | console.log('Form data has been recovered.'); 128 | return false; 129 | }); 130 | 131 | 132 | /* 133 | * To erase a forms cookie 134 | */ 135 | $('#forms_delete_save_button').click(function() 136 | { 137 | $('#form_id').sayt({'erase': true}); 138 | 139 | console.log('Form cookie was deleted.'); 140 | return false; 141 | }); 142 | 143 | }); 144 | ``` 145 | 146 | Cookies are saved with the name autosaveFormCookie-, and have the ID of the form on the end. For example, a form with the ID of "my_form", would result in a cookie named: autosaveFormCookie-my_form 147 | 148 | This is useful is you'd like to delete a cookie via a different method (IE With your server side code after saving a forms input). 149 | 150 | 151 | ## Excluding Fields 152 | 153 | Thanks to @georgjaehnig you can now exclude certain fields from being included in the cookie. There are two ways to do this. 154 | 155 | ### Adding an attribute on the form element 156 | 157 | By adding the `data-sayt-exclude` attribute on the form element, the element's value will not be saved in the cookie. Example: 158 | ``` 159 | 160 | 161 | ``` 162 | The value of the first element will not be saved, the value of the second will be. 163 | 164 | ### Providing a list of CSS selectors on the function call 165 | 166 | Alternatively, you may call the init function with the setting `exclude` containing a list of selectors that define elements to be excluded. This may be useful when having no access to the HTML source. For instance: 167 | ``` 168 | 169 | 170 | 171 | ``` 172 | ``` 173 | $('#form_id').sayt({'exclude': ['#dontSaveMe', '[name=second]']}); 174 | ``` 175 | The value of the first and second element will not be saved, the value of the third will be. 176 | 177 | ## Dependencies 178 | 179 | This plugin depends on the included jquery-cookie plugin. More information on that plugin can be found here: https://github.com/carhartl/jquery-cookie 180 | 181 | 182 | ## Author 183 | 184 | [Ben Griffiths] 185 | 186 | 187 | ## License 188 | 189 | Copyright (c) 2012 Ben Griffiths. Licensed under the MIT License. Redistributions of files must retain the above copyright notice. 190 | -------------------------------------------------------------------------------- /dependencies/jquery-cookie.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery Cookie plugin 3 | * 4 | * https://github.com/carhartl/jquery-cookie 5 | * 6 | * Copyright (c) 2010 Klaus Hartl (stilbuero.de) 7 | * Dual licensed under the MIT and GPL licenses: 8 | * http://www.opensource.org/licenses/mit-license.php 9 | * http://www.gnu.org/licenses/gpl.html 10 | * 11 | */ 12 | jQuery.cookie = function (key, value, options) { 13 | 14 | // key and at least value given, set cookie... 15 | if (arguments.length > 1 && String(value) !== "[object Object]") { 16 | options = jQuery.extend({}, options); 17 | 18 | if (value === null || value === undefined) { 19 | options.expires = -1; 20 | } 21 | 22 | if (typeof options.expires === 'number') { 23 | var days = options.expires, t = options.expires = new Date(); 24 | t.setDate(t.getDate() + days); 25 | } 26 | 27 | value = String(value); 28 | 29 | return (document.cookie = [ 30 | encodeURIComponent(key), '=', 31 | options.raw ? value : encodeURIComponent(value), 32 | options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE 33 | options.path ? '; path=' + options.path : '', 34 | options.domain ? '; domain=' + options.domain : '', 35 | options.secure ? '; secure' : '' 36 | ].join('')); 37 | } 38 | 39 | // key and possibly options given, get cookie... 40 | options = value || {}; 41 | var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; 42 | return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; 43 | }; -------------------------------------------------------------------------------- /examples/examples.js: -------------------------------------------------------------------------------- 1 | $(function() 2 | { 3 | 4 | /** 5 | * When building your forms, you MUST make sure your form has an ID, and that it's unique 6 | * on the application. 7 | * 8 | * Ie, don't call all forms 'id="form"', even if they are on seperate pages. 9 | */ 10 | 11 | /* 12 | * Attach to a form with default settings 13 | */ 14 | $('#form_id').sayt(); 15 | 16 | 17 | /* 18 | * Attach to a form with custom settings 19 | * 20 | * Autosave disabled (Must use manual save to save anything) 21 | * Autorecover disabled (Must use a manual recover to recover anything) 22 | * Days 7 (Keeps the save cookie for 7 days) 23 | */ 24 | $('#form_id').sayt({'autosave': false, 'autorecover': false, 'days': 7}); 25 | 26 | 27 | /* 28 | * Check to see if a form has a save 29 | */ 30 | if($('#form_id').sayt({'checksaveexists': true}) == true) 31 | { 32 | console.log('Form has an existing save cookie.'); 33 | } 34 | 35 | 36 | /* 37 | * Perform a manual save 38 | */ 39 | $('#forms_save_button').click(function() 40 | { 41 | $('#form_id').sayt({'savenow': true}); 42 | 43 | console.log('Form data has been saved.'); 44 | return false; 45 | }); 46 | 47 | 48 | /* 49 | * Perform a manual recover 50 | */ 51 | $('#forms_recover_button').click(function() 52 | { 53 | $('#form_id').sayt({'recover': true}); 54 | 55 | console.log('Form data has been recovered.'); 56 | return false; 57 | }); 58 | 59 | 60 | /* 61 | * To erase a forms cookie 62 | */ 63 | $('#forms_delete_save_button').click(function() 64 | { 65 | $('#form_id').sayt({'erase': true}); 66 | 67 | console.log('Form cookie was deleted.'); 68 | return false; 69 | }); 70 | 71 | }); -------------------------------------------------------------------------------- /sayt.jquery.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sayt", 3 | "version": "1.4.5", 4 | "title": "Save As You Type", 5 | "author": { 6 | "name": "Ben Griffiths", 7 | "email": "ben@ben-griffiths.com", 8 | "url": "http://www.ben-griffiths.com" 9 | }, 10 | "licenses": [ 11 | { 12 | "type": "MIT", 13 | "url": "http://www.opensource.org/licenses/mit-license.php" 14 | } 15 | ], 16 | "maintainers": [ 17 | { 18 | "name": "Ben Griffiths", 19 | "email": "ben@ben-griffiths.com", 20 | "url": "http://www.ben-griffiths.com" 21 | } 22 | ], 23 | "dependencies": { 24 | "jquery-cookie": ">=1.0.0", 25 | "jquery": ">=1.5" 26 | }, 27 | "description": "This jQuery plugin autosaves (To a cookie) as you type, and autorecovers, form data. Auto saving will save as data is entered or changed. You have the ability to disable autosaving and auto recovering, and instead use manual calls for each. You can also manually call an erase cookie feature, and manually call to see if a form actually has saved data. Works with the following elements so far: Text boxes, text areas, select (Single AND multiple), radio buttons and check boxes", 28 | "keywords": [ 29 | "autosave", 30 | "cookie" , 31 | "forms", 32 | "form", 33 | "input" 34 | ], 35 | "homepage": "https://github.com/BenGriffiths/jquery-save-as-you-type" 36 | } 37 | -------------------------------------------------------------------------------- /source/sayt.jquery.js: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * 4 | * sayt - Save As You Type 5 | * 6 | ******************************************************************************* 7 | * 8 | * This plugin autosaves form input as it is being entered by the 9 | * user. It is saved to a cookie during each keyup and change. 10 | * 11 | * When a page is reloaded for any reason, the form data is automatically 12 | * re-entered for the user by reading the cookie. The cookie can be deleted 13 | * on the fly by the plugin if required. 14 | * 15 | ******************************************************************************* 16 | * 17 | * Intructions: 18 | * By: Ben Griffiths, ben@ben-griffiths.com 19 | * Version: 1.4.3 20 | * 21 | * Dependencies: 22 | * 23 | * jquery-cookie 1.0.0 (Relies on the jQuery Cookie plugin https://github.com/carhartl/jquery-cookie) 24 | * - Included. 25 | * 26 | ******************************************************************************* 27 | * 28 | * Licensed under The MIT License (MIT) 29 | * you may not use this file except in compliance with the License. 30 | * You may obtain a copy of the License at 31 | * 32 | * http://www.opensource.org/licenses/mit-license.php 33 | * 34 | * Copyright (c) 2011 Ben Griffiths (mail@thecodefoundryltd.com) 35 | * 36 | * Permission is hereby granted, free of charge, to any person obtaining a 37 | * copy of this software and associated documentation files (the "Software"), 38 | * to deal in the Software without restriction, including without limitation 39 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 40 | * and/or sell copies of the Software, and to permit persons to whom the 41 | * Software is furnished to do so, subject to the following conditions: 42 | * 43 | * The above copyright notice and this permission notice shall be included 44 | * in all copies or substantial portions of the Software. 45 | * 46 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 47 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 52 | * THE SOFTWARE. 53 | * 54 | ******************************************************************************* 55 | */ 56 | (function($) 57 | { 58 | $.fn.sayt = function(options) 59 | { 60 | 61 | /* 62 | * Get/Set the settings 63 | */ 64 | var settings = $.extend( 65 | { 66 | 'prefix' : 'autosaveFormCookie-', 67 | 'erase' : false, 68 | 'days' : 3, 69 | 'autosave' : true, 70 | 'savenow' : false, 71 | 'recover' : false, 72 | 'autorecover' : true, 73 | 'checksaveexists': false, 74 | 'exclude' : [], 75 | 'id' : this.attr('id'), 76 | }, options); 77 | 78 | /* 79 | * Define the form 80 | */ 81 | var theform = this; 82 | 83 | /* 84 | * Define the cookie name 85 | */ 86 | var cookie_id = settings.prefix + settings.id; 87 | 88 | /* 89 | * Erase a cookie 90 | */ 91 | if(settings['erase'] == true) 92 | { 93 | $.cookie( cookie_id, null); 94 | if (typeof(Storage) !== "undefined") { 95 | localStorage.removeItem(cookie_id); 96 | } 97 | // else { 98 | // $.cookie(cookie_id, null); 99 | // } 100 | 101 | return true; 102 | } 103 | 104 | 105 | /* 106 | * Get the forms save cookie (if it has one of course) 107 | */ 108 | var autoSavedCookie; 109 | if (typeof(Storage) !== "undefined") { 110 | autoSavedCookie = localStorage.getItem(cookie_id); 111 | } 112 | else { 113 | autoSavedCookie = $.cookie(cookie_id); 114 | } 115 | 116 | 117 | 118 | /* 119 | * Check to see if a save exists 120 | */ 121 | if(settings['checksaveexists'] == true) 122 | { 123 | if(autoSavedCookie) 124 | { 125 | return true; 126 | } 127 | else 128 | { 129 | return false; 130 | } 131 | 132 | return false; 133 | } 134 | 135 | 136 | /* 137 | * Perform a manual save 138 | */ 139 | if(settings['savenow'] == true) 140 | { 141 | var form_data = getFormData(theform, settings['exclude']); 142 | autoSaveCookie(form_data); 143 | 144 | return true; 145 | } 146 | 147 | 148 | /* 149 | * Recover the form info from the cookie (if it has one) 150 | */ 151 | if(settings['autorecover'] == true || settings['recover'] == true) 152 | { 153 | if(autoSavedCookie) 154 | { 155 | var newCookieString = autoSavedCookie.split(':::--FORMSPLITTERFORVARS--:::'); 156 | 157 | var field_names_array = {}; 158 | 159 | $.each(newCookieString, function(i, field) 160 | { 161 | var fields_arr = field.split(':::--FIELDANDVARSPLITTER--:::'); 162 | 163 | if($.trim(fields_arr[0]) != '') 164 | { 165 | if($.trim(fields_arr[0]) in field_names_array) 166 | { 167 | field_names_array[$.trim(fields_arr[0])] = (field_names_array[$.trim(fields_arr[0])] + ':::--MULTISELECTSPLITTER--:::' + fields_arr[1]); 168 | } 169 | else 170 | { 171 | field_names_array[$.trim(fields_arr[0])] = fields_arr[1]; 172 | } 173 | } 174 | }); 175 | 176 | $.each(field_names_array, function(key, value) 177 | { 178 | if(strpos(value, ':::--MULTISELECTSPLITTER--:::') > 0) 179 | { 180 | var tmp_array = value.split(':::--MULTISELECTSPLITTER--:::'); 181 | 182 | $.each(tmp_array, function(tmp_key, tmp_value) 183 | { 184 | // added $(theform) to selectors 185 | $('input[name="' + key + '"], select[name="' + key + '"], textarea[name="' + key + '"]', $(theform) ).find('[value="' + tmp_value + '"]').prop('selected', true); 186 | $('input[name="' + key + '"][value="' + tmp_value + '"], select[name="' + key + '"][value="' + tmp_value + '"], textarea[name="' + key + '"][value="' + tmp_value + '"]', $(theform) ).prop('checked', true); 187 | }); 188 | } 189 | else 190 | { 191 | $('input[name="' + key + '"], select[name="' + key + '"], textarea[name="' + key + '"]', $(theform) ).val([value]); 192 | } 193 | }); 194 | } 195 | 196 | /* 197 | * if manual recover action, return 198 | */ 199 | if(settings['recover'] == true) 200 | { 201 | return true; 202 | } 203 | } 204 | 205 | 206 | /* 207 | * Autosave - on typing and changing 208 | */ 209 | if(settings['autosave'] == true) 210 | { 211 | this.find('input, select, textarea').each(function(index) 212 | { 213 | $(this).change(function() 214 | { 215 | var form_data = getFormData(theform, settings['exclude']); 216 | autoSaveCookie(form_data); 217 | }); 218 | 219 | $(this).keyup(function() 220 | { 221 | var form_data = getFormData(theform, settings['exclude']); 222 | autoSaveCookie(form_data); 223 | }); 224 | }); 225 | } 226 | 227 | 228 | /* 229 | * Save form data to a cookie 230 | */ 231 | function autoSaveCookie(data) 232 | { 233 | var cookieString = ''; 234 | 235 | jQuery.each(data, function(i, field) 236 | { 237 | cookieString = cookieString + field.name + ':::--FIELDANDVARSPLITTER--:::' + field.value + ':::--FORMSPLITTERFORVARS--:::'; 238 | }); 239 | 240 | // $.cookie(cookie_id, cookieString, { expires: settings['days'] }); 241 | if (typeof(Storage) !== "undefined") { 242 | localStorage.setItem(cookie_id, cookieString); 243 | } 244 | else { 245 | $.cookie(cookie_id, cookieString, { expires: settings['days'] }); 246 | } 247 | 248 | } 249 | 250 | /* 251 | * strpos - equiv to PHP's strpos 252 | */ 253 | function strpos(haystack, needle, offset) 254 | { 255 | var i = (haystack+'').indexOf(needle, (offset || 0)); 256 | return i === -1 ? false : i; 257 | } 258 | 259 | /* 260 | * Serialize the form data, omit excluded fields marked with data-sayt-exclude attribute. 261 | */ 262 | function getFormData(theform, excludeSelectors) 263 | { 264 | // 265 | // This is here because jQuery's clone method is basically borked. 266 | // 267 | // Once they fix that, we'll put it back. 268 | // 269 | var workingObject = $.extend({}, theform); 270 | 271 | var elementsToRemove = workingObject.find('[data-sayt-exclude]'); 272 | elementsToRemove.remove(); 273 | for (i in excludeSelectors) { 274 | elementsToRemove = workingObject.find(excludeSelectors[i]); 275 | elementsToRemove.remove(); 276 | } 277 | 278 | var form_data = workingObject.serializeArray(); 279 | return form_data; 280 | } 281 | }; 282 | })(jQuery); 283 | -------------------------------------------------------------------------------- /source/sayt.min.jquery.js: -------------------------------------------------------------------------------- 1 | /* 2 | ******************************************************************************* 3 | * 4 | * sayt - Save As You Type 5 | * 6 | ******************************************************************************* 7 | * 8 | * This plugin autosaves form input as it is being entered by the 9 | * user. It is saved to a cookie during each keyup and change. 10 | * 11 | * When a page is reloaded for any reason, the form data is automatically 12 | * re-entered for the user by reading the cookie. The cookie can be deleted 13 | * on the fly by the plugin if required. 14 | * 15 | ******************************************************************************* 16 | * 17 | * Intructions: 18 | * By: Ben Griffiths, ben@ben-griffiths.com 19 | * Version: 1.4.3 20 | * 21 | * Dependencies: 22 | * 23 | * jquery-cookie 1.0.0 (Relies on the jQuery Cookie plugin https://github.com/carhartl/jquery-cookie) 24 | * - Included. 25 | * 26 | ******************************************************************************* 27 | * 28 | * Licensed under The MIT License (MIT) 29 | * you may not use this file except in compliance with the License. 30 | * You may obtain a copy of the License at 31 | * 32 | * http://www.opensource.org/licenses/mit-license.php 33 | * 34 | * Copyright (c) 2011 Ben Griffiths (mail@thecodefoundryltd.com) 35 | * 36 | * Permission is hereby granted, free of charge, to any person obtaining a 37 | * copy of this software and associated documentation files (the "Software"), 38 | * to deal in the Software without restriction, including without limitation 39 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 40 | * and/or sell copies of the Software, and to permit persons to whom the 41 | * Software is furnished to do so, subject to the following conditions: 42 | * 43 | * The above copyright notice and this permission notice shall be included 44 | * in all copies or substantial portions of the Software. 45 | * 46 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 47 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 52 | * THE SOFTWARE. 53 | * 54 | ******************************************************************************* 55 | */ 56 | !function(a){a.fn.sayt=function(b){function k(b){var d="";jQuery.each(b,function(a,b){d=d+b.name+":::--FIELDANDVARSPLITTER--:::"+b.value+":::--FORMSPLITTERFORVARS--:::"}),"undefined"!=typeof Storage?localStorage.setItem(e,d):a.cookie(e,d,{expires:c.days})}function l(a,b,c){var d=(a+"").indexOf(b,c||0);return d!==-1&&d}function m(b,c){var d=a.extend({},b),e=d.find("[data-sayt-exclude]");e.remove();for(i in c)e=d.find(c[i]),e.remove();var f=d.serializeArray();return f}var c=a.extend({prefix:"autosaveFormCookie-",erase:!1,days:3,autosave:!0,savenow:!1,recover:!1,autorecover:!0,checksaveexists:!1,exclude:[],id:this.attr("id")},b),d=this,e=c.prefix+c.id;if(1==c.erase)return a.cookie(e,null),"undefined"!=typeof Storage&&localStorage.removeItem(e),!0;var f;if(f="undefined"!=typeof Storage?localStorage.getItem(e):a.cookie(e),1==c.checksaveexists)return!!f;if(1==c.savenow){var g=m(d,c.exclude);return k(g),!0}if(1==c.autorecover||1==c.recover){if(f){var h=f.split(":::--FORMSPLITTERFORVARS--:::"),j={};a.each(h,function(b,c){var d=c.split(":::--FIELDANDVARSPLITTER--:::");""!=a.trim(d[0])&&(a.trim(d[0])in j?j[a.trim(d[0])]=j[a.trim(d[0])]+":::--MULTISELECTSPLITTER--:::"+d[1]:j[a.trim(d[0])]=d[1])}),a.each(j,function(b,c){if(l(c,":::--MULTISELECTSPLITTER--:::")>0){var e=c.split(":::--MULTISELECTSPLITTER--:::");a.each(e,function(c,e){a('input[name="'+b+'"], select[name="'+b+'"], textarea[name="'+b+'"]',a(d)).find('[value="'+e+'"]').prop("selected",!0),a('input[name="'+b+'"][value="'+e+'"], select[name="'+b+'"][value="'+e+'"], textarea[name="'+b+'"][value="'+e+'"]',a(d)).prop("checked",!0)})}else a('input[name="'+b+'"], select[name="'+b+'"], textarea[name="'+b+'"]',a(d)).val([c])})}if(1==c.recover)return!0}1==c.autosave&&this.find("input, select, textarea").each(function(b){a(this).change(function(){var a=m(d,c.exclude);k(a)}),a(this).keyup(function(){var a=m(d,c.exclude);k(a)})})}}(jQuery); --------------------------------------------------------------------------------