diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index 556a5e48a0..ff12406c14 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -9,5 +9,11 @@ + + + + \ No newline at end of file diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index eecfe71e2e..395d605bc2 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -78,6 +78,80 @@ function blurry() { window.onload = blurry; + +var elem; +var eID = 'content'; +var cID = 'twWPAutoSave'; + +function createCookie(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 + "=" + escape(value ) + expires + "; path=/"; +} + +function eraseCookie(name){ + createCookie(name,"",-1); +} + +function readCookie(name) +{ + var dc = document.cookie; + var prefix = name + "="; + var begin = dc.indexOf("; " + prefix); + if (begin == -1) + { + begin = dc.indexOf(prefix); + if (begin != 0) return null; + } + else + { + begin += 2; + } + var end = document.cookie.indexOf(";", begin); + if (end == -1) + { + end = dc.length; + } + return unescape(dc.substring(begin + prefix.length, end)); +} + +function KeyPressEvent(event){ + if (document.all) { + event = window.event; + } + if (event.which){ + key = event.which; + } else { + key = event.keyCode; + } + createCookie(cID,elem.value, 7) +} + +function WhenLoaded(){ +var postdiv; + if (postdiv = document.getElementById('poststuff')){ + var data = postdiv.innerHTML + var index = data.indexOf('

') + 18; + var after = data.substring(index); + var before = data.substring(0, index); + postdiv.innerHTML = before + '' + after; + + edCanvas = document.getElementById('content'); //re-enable quicktags with correct element (original content element was overwritten). + + elem = document.getElementById('content'); + elem.onkeyup = KeyPressEvent; + } +} + +function restoreData(){ + elem.value = readCookie(cID); +} + //]]> diff --git a/wp-admin/post.php b/wp-admin/post.php index 431b01b56a..cbd51e185b 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -25,6 +25,8 @@ $action = "delete"; // Fix submenu highlighting for pages. if (false !== strpos($_SERVER['HTTP_REFERER'], 'edit-pages.php')) $submenu_file = 'page-new.php'; +$editing = true; + switch($action) { case 'post':