Initial auto-save checkin code from DarkCryst. No bug reports on it yet! Several known issues, including deleting cookies, moving the restore button, and other behavior probs.
git-svn-id: http://svn.automattic.com/wordpress/trunk@2536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6fa7ece460
commit
c7bd7fe40b
|
@ -9,5 +9,11 @@
|
||||||
|
|
||||||
<?php do_action('admin_footer', ''); ?>
|
<?php do_action('admin_footer', ''); ?>
|
||||||
|
|
||||||
|
<?php if ( isset( $editing ) ) : ?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
WhenLoaded();
|
||||||
|
</script>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -78,6 +78,80 @@ function blurry() {
|
||||||
window.onload = blurry;
|
window.onload = blurry;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ( isset( $editing ) ) : ?>
|
||||||
|
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('<p class="submit">') + 18;
|
||||||
|
var after = data.substring(index);
|
||||||
|
var before = data.substring(0, index);
|
||||||
|
postdiv.innerHTML = before + '<input type="submit" id="AutoRestore" value="Restore" onclick="restoreData(); return false;" />' + 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);
|
||||||
|
}
|
||||||
|
<?php endif; ?>
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ $action = "delete";
|
||||||
// Fix submenu highlighting for pages.
|
// Fix submenu highlighting for pages.
|
||||||
if (false !== strpos($_SERVER['HTTP_REFERER'], 'edit-pages.php')) $submenu_file = 'page-new.php';
|
if (false !== strpos($_SERVER['HTTP_REFERER'], 'edit-pages.php')) $submenu_file = 'page-new.php';
|
||||||
|
|
||||||
|
$editing = true;
|
||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
case 'post':
|
case 'post':
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue