diff --git a/wp-admin/js/upload.js b/wp-admin/js/upload.js index 7e0fa29e19..d114e04715 100644 --- a/wp-admin/js/upload.js +++ b/wp-admin/js/upload.js @@ -5,6 +5,38 @@ addLoadEvent( function() { tab: '', postID: 0, + // cookie create and read functions adapted from http://www.quirksmode.org/js/cookies.html + createCookie: function(name,value,days) { + if (days) { + var date = new Date(); + date.setTime(date.getTime()+(days*24*60*60*1000)); + var expires = "; expires="+date.toGMTString(); + } + else var expires = ""; + document.cookie = name+"="+value+expires+"; path=/"; + }, + + readCookie: function(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for(var i=0;i < ca.length;i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); + } + return null; + }, + + assignCookieOnChange: function() { + jQuery(this).bind("change", function(){ + theFileList.createCookie(jQuery(this).attr('name'),jQuery(this).attr('id'),365); + }); + }, + + checkCookieSetting: function(name, defaultSetting) { + return this.readCookie(name) ? this.readCookie(name) : defaultSetting; + }, + toQueryParams: function( s ) { var r = {}; if ( !s ) { return r; } var q = s.split('?'); if ( q[1] ) { s = q[1]; } @@ -114,12 +146,12 @@ addLoadEvent( function() { h += "