Ok, I may be in over my head but if you are willing to read this lengthy post and help, thanks.
If you read my post from about a week ago, you know I have a real pain in the neck situation.
I have spent the last week getting my javascripting knowledge up to par and now need some help figuring out hopefully the last part of this site I am working on.
I am attempting to take the dynamically included content on this site I am working on, and strip it down to some more basic components and then reassemble it using my own styles and formating.
Below is the code I am using, first is one of the functions that are called in the second piece of code, also included below.
function ServerStatusMenu(){
document.write ("<style type='text/css'>");
document.write ("A \{font-size: 12px; color: #000000; text-decoration: none; \}");
document.write (".Menu \{position: absolute; left: 5px; top: 5px; \}");
document.write ("</style>");
document.write ("<table border='0' class='Menu' cellpadding='0' cellspacing='0'>");
document.write ("<tr>");
document.write ("<td class='MenuCat' align='center'>" + MenusTitle + "</td>");
document.write (StartContent);
document.write ("<td class='MenuChoice' align='left'>" + NewContent + "</td>");
document.write (EndContent);
document.write ("</tr>");
document.write ("</table>");
}
<script type="text/javascript" language="javascript">
var MenusTitle = "<!-- Menu:Title -->";
var change = MenusTitle.split(":");
var loggedin = (change[0]);
var NewContent = "<!-- Menu:StandAloneContent -->".replace(/\r/gm, " ");
var StartContent = "<!-- Menu:StartStandAlone -->";
var EndContent = "<!-- Menu:EndStandAlone -->";
var StartLists = "<!-- Menu:StartItemList -->";
var EndLists = "<!-- Menu:StartItemList -->";
var StartItems = "<!-- Menu:StartItem -->";
var EndItems = "<!-- Menu:EndItem -->";
var ItemsLink = "<!-- Menu:Link -->";
var ItemsPopup = "<!--Menu:Popup -->";
var LinksDesription = "<!-- Menu:LinkName -->";
if (MenusTitle == "Logged Out"){
LoggedOutMenu()
}
else if (loggedin == "Logged in"){
LoggedInMenu()
}
else if (MenusTitle == "Server Status"){
ServerStatusMenu()
}
else {
AllOtherMenus()
}
</script>
Now just in case you didn't know the <!-- Menu:Title --> are how the originall designer/host of the site is dynamically including content. And further I do not have access to the original files or the database nor can I use PHP.
Now below I have included what the code above looks like once it has been run on the site with the dynamic content included.
<script type="text/javascript" language="javascript">
var MenusTitle = "Logged In: Kriknosnah";
var change = MenusTitle.split(":");
var loggedin = (change[0]);
var NewContent = " <center style="font-size:8pt">
<i>Class Officer</i>
<a href='javascript:enablerankchallenge()' style='font-size:7.5pt;font-weight:normal'>Wrong?</a><br>
<A href="editprofile.php">Edit Your Account Info</a><br>
<A href="viewprofile.php?loginid=15">View your Account Profile</a>
<br><a href="myavailability.php">Edit your Availability for Raids</a>
</center>
<center style="font-size:8pt;font-weight:bold">My Character Profiles:</center>
<table cellspacing=0 cellpadding=0 border=0 align=center><tr><td class=plain style="font-size:7pt">
<a href='memberprofile.php?memberid=33'>Kriknosnah(70)</a><br><a href='memberprofile.php?memberid=42'>Zithril(50)</a><br> </td></tr></table> <center>
<a id=createchartext href="javascript:enablecreatechar(1)">[Create a Character]</A>
<div id=createcharform style="display:none">
<center>
Name:
<input type=text name=createname id=createname class=xsmall name=name value="" size=8>
<input type=button class=button value="Go" style="font-size:7pt" onClick="createchar()"><br>
<a href="javascript:enablecreatechar(0)">[Cancel]</a>
</center>
</div>
</center>
<center><a href="logout.php">Log out</a></center>
".replace(/\r /gm, " ");
var StartContent = "";
var EndContent = "";
var StartLists = "";
var EndLists = "";
var StartItems = "<!-- Menu:StartItem -->";
var EndItems = "<!-- Menu:EndItem -->";
var ItemsLink = "<!-- Menu:Link -->";
var ItemsPopup = "<!--Menu:Popup -->";
var LinksDesription = "<!-- Menu:LinkName -->";
if (MenusTitle == "Logged Out"){
LoggedOutMenu()
}
else if (loggedin == "Logged in"){
LoggedInMenu()
}
else if (MenusTitle == "Server Status"){
ServerStatusMenu()
}
else {
AllOtherMenus()
}
</script>
If you look at the "NewContent" variable you will probably guess my problem. I can easily change any part of the dynamically included content, using regex. But the problem is the code that the designer has is non-uniform in his techniques as in one place he will use double quotes (") and the next he will use single quotes (') and yet in a different spot he will use no quotes. So when I try to store his code in a variable the quotes I need to have around it are being overriden by the quotes in his code. Making it so I can not even get to the point that my code can start taking a part his code to make it look and work the way I want it to.
I am interested in finding another way to do this to get around the problem.
Also any sugestions on doing this a better way overall are welcome.