1/** 2 * autosave plugin 3 * 4 * Copyright (c) 2009-2014 Fil ([email protected]) 5 * Dual licensed under the MIT and GPL licenses: 6 * http://www.opensource.org/licenses/mit-license.php 7 * http://www.gnu.org/licenses/gpl.html 8 * 9 */ 10 11/* 12 * Usage: $("form").autosave({options...}); 13 * to use with SPIP's action/session.php 14 */ 15 16(function($){ 17 $.fn.autosave = function(opt) { 18 opt = $.extend({ 19 url: window.location, 20 confirm: false, 21 confirmstring: 'Sauvegarder ?' 22 },opt); 23 var save_changed = function(){ 24 $('form.autosavechanged') 25 .each(function(){ 26 if (!opt.confirm || confirm(opt.confirmstring)) { 27 var contenu = $(this).serialize(); 28 // ajoutons un timestamp 29 var d=new Date(); 30 contenu = contenu + "&__timestamp=" + d.getTime(); 31 $.post(opt.url, { 32 'action': 'session', 33 'var': 'autosave_' + $('input[name=autosave]', this).val(), 34 'val': contenu 35 }); 36 } 37 }).removeClass('autosavechanged'); 38 } 39 $(window) 40 .bind('unload',save_changed); 41 return this 42 .bind('keyup', function() { 43 $(this).addClass('autosavechanged'); 44 }) 45 .bind('change', function() { 46 $(this).addClass('autosavechanged'); 47 save_changed(); 48 }) 49 .bind('submit',function() { 50 save_changed(); 51 /* trop agressif : exemple du submit previsu forum, ou des submit suivant/precedent d'un cvt multipage 52 on sauvegarde toujours, et le serveur videra quand il faudra */ 53 /*$(this).removeClass('autosavechanged')*/; 54 }); 55 } 56})(jQuery); 57
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.