1/** 2 * autosave plugin 3 * 4 * Copyright (c) 2009-2016 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=" + Math.round(d.getTime()/1000); 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).on('unload', save_changed); 40 return this 41 .on('keyup', function() { 42 $(this).addClass('autosavechanged'); 43 }) 44 .on('change', function() { 45 $(this).addClass('autosavechanged'); 46 save_changed(); 47 }) 48 .on('submit',function() { 49 save_changed(); 50 /* trop agressif : exemple du submit previsu forum, ou des submit suivant/precedent d'un cvt multipage 51 on sauvegarde toujours, et le serveur videra quand il faudra */ 52 /*$(this).removeClass('autosavechanged')*/; 53 }); 54 } 55})(jQuery); 56
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.