User:Dschwen/saveasdraft.js

// // Script to embed Coordinate template generation in MediaWiki's edit page

// // defaults // var sad_draft_folder = 'User:Dschwen/Drafts/'; var sad_max_cookie_len = 8000;

// globals var save_as_draft_menu = null;

// // Insert the coordinate Form into the edit box. // function saveasdraftInstall { if (document.getElementById('editpage-copywarn')) { var oldPreview = document.getElementById('wpPreview'); var newPreview = document.createElement('input'); newPreview.setAttribute('type', 'button'); newPreview.setAttribute('style', 'font-style: italic'); newPreview.setAttribute('value', 'Save as draft'); newPreview.setAttribute('onclick', "saveAsDraft"); oldPreview.parentNode.insertBefore(newPreview, oldPreview); //oldPreview.parentNode.innerHTML += ' '; //oldPreview.value = 'Classic Preview'; }

var toolboxitem = document.getElementById('t-whatlinkshere'); if( toolboxitem && save_as_draft_menu == null ) {   // link toolboxitem.parentNode.innerHTML += 'My drafts'

// menubox save_as_draft_menu = document.createElement('div'); save_as_draft_menu.setAttribute('style', 'background-color: lightyellow; padding: 0.5em; font-size:small; border: 1px solid gray'); // save_as_draft_menu.setAttribute('style', 'position:absolute; width:100px; background-color: lightyellow; padding: 0.5em; font-size:small; visibility: visible; border: 1px solid gray'); toolboxitem.parentNode.appendChild(save_as_draft_menu);

save_as_draft_menu.innerHTML += 'Hallo!'; } }

// // Hook up instalation function // $(saveasdraftInstall);

// // Coordinate interpretation // function saveAsDraft { var editbox = document.getElementById('wpTextbox1'); var editbox_content = editbox.value; editbox.value = "__DRAFT__\n" + editbox_content;

var editform = document.getElementById('editform'); // "/w/index.php?title=" "&amp;action=submit" }

function SADSetCookie(cookieName,cookieValue,nDays) { var today = new Date; var expire = new Date; if (nDays==null || nDays==0) nDays=1; expire.setTime(today.getTime + 3600000*24*nDays); document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString; }

function toggleSADMenu { alert("kaschiiing!"); if(save_as_draft_menu.style.visibility != "visible") {  save_as_draft_menu.style.visibility="visible"; } else {  save_as_draft_menu.style.visibility="hidden"; }

return false; } //