Post by michael2 on Dec 28, 2004 21:26:24 GMT
Here is a code i made it makes a page which can be edited in the admin area
Place this code in main header
Place this code in main footer
Place this code in main header
<script language="JavaScript">
/*
Create a page admin area editable
Coded by Michael Burrows
Main header
Use freely but do not post in other locations please
*/
var tT="New Page Table Title";
var bT="New Page Body Text";
var pT="New Page Window Title";
var pL="newpage";
if(location.href.indexOf('&type=editpage') != -1){
document.write('<table border="0" align="center" width="70%" cellspacing="1" class="bordercolor" cellpadding="1"><tr><td class="titlebg" align="left"><font color="Black">Edit Page</font><tr><td class="windowbg" align="center">Change the table title:<tr><td class="windowbg" align="center"><textarea name="tT" id="tT" cols="50" rows="10">'+tT.replace(/<br\/>/ig,"\b")+'</textarea><tr><td class="windowbg" align="center">Use <*br*> when you want to use a line break and take out the *<br\>Change the body text:<tr><td class="windowbg" align="center"><textarea name="bT" id="bT" cols="50" rows="10">'+bT.replace(/<br\/>/ig,"\b")+'</textarea><tr><td class="windowbg" align="center">Change the window title of your page:<tr><td class="windowbg" align="center"><textarea name="pT" id="pT" cols="50" rows="10">'+pT.replace(/<br\/>/ig,"\b")+'</textarea><tr><td class="windowbg" align="center">Change the URL of the page:<tr><td class="windowbg" align="center"><input type="textbox" name="pL" id="pL" value="'+pL.replace(/<br\/>/ig,"\b")+'"></input></td></tr></table>');
}
</script>
Place this code in main footer
<script language="JavaScript">
/*
Create a page admin area editable
Coded by Michael Burrows
Main footer
Use freely but do not post in other locations please
*/
if(location.href.indexOf('action=admin') != -1){
var vR = document.getElementsByTagName('TD');
for(o=0;o<vR.length;o++){
if(vR[o].width=='50%' && vR[o].vAlign=='top' && vR[o].innerHTML.match(/Modify Headers and Footers/i)){
vR[o].innerHTML = vR[o].innerHTML.replace(/Modify Headers and Footers/ig,'Modify Headers and Footers</a><br\><a href="index.cgi?action=headersfooters&type=editpage">Edit Page</a>');
}}}
if(location.href.indexOf('action='+pL+'') != -1){
document.title=""+pT+""
var fC = document.getElementsByTagName('TD');
for(i=0;i<fC.length;i++){
if(fC[i].width=='100%' && fC[i].vAlign=='top' && fC[i].innerHTML.match(/This feature is not complete yet./i)){
fC[i].innerHTML = fC[i].innerHTML.replace(/An Error Has Occurred!/i,''+tT+'')
fC[i].innerHTML = fC[i].innerHTML.replace(/This feature is not complete yet./i,''+bT+'')
}}}
if(document.referrer.indexOf('&type=editpage') != -1){
document.title = document.title.split('-')[0] + ' - Edit Page'
var zS = document.getElementsByTagName('TD');
for(u=0;u<zS.length;u++){
if(zS[u].width=='100%' && zS[u].vAlign=='top' && zS[u].innerHTML.match(/Edit Headers \/ Footers/i)){
zS[u].innerHTML = zS[u].innerHTML.replace(/Edit Headers \/ Footers/i,'Edit Page')
zS[u].innerHTML = zS[u].innerHTML.replace(/Your headers and footers have been edited successfully./i,'Your page has been successfully edited.<br\><br\>Your page can be found <a href="/index.cgi?action='+pL+'">here</a>')
}}}
if(location.href.indexOf('&type=editpage') != -1){
var xD = document.getElementsByTagName('table');
for(p=0;p<xD.length;p++){
if(xD[p].className=='bordercolor' && xD[p].cellPadding=='4'){
xD[p].style.display='none'
}}
for(v=0;v<document.forms.length;v++){
if(document.forms[v].action=='index.cgi?action=headersfooters2'){
var vRd = document.forms[v];
vRd.onsubmit=sPk;
vRd.getElementsByTagName('input')[0].style.display='none';
vRd.getElementsByTagName('input')[1].value='Save Page';
}}}
function sPk(){
var vC = vRd.getElementsByTagName('textarea');
for(f=0;f<vC.length;f++){
if(vC[f].name=='header'){
vC[f].value = vC[f].value.replace(/var tT=".*";/i,'var tT="'+document.getElementById("tT").value+'";');
vC[f].value = vC[f].value.replace(/var bT=".*";/i,'var bT="'+document.getElementById("bT").value+'";');
vC[f].value = vC[f].value.replace(/var pT=".*";/i,'var pT="'+document.getElementById("pT").value+'";');
vC[f].value = vC[f].value.replace(/var pL=".*";/i,'var pL="'+document.getElementById("pL").value+'";');
break;
}}}
</script>