Sat 11th Mar 2006
Better Display of HTML as Source
Posted early evening, filed under Blogsome , JavaScript.I spent hours last night working on this, and a fair bit of time today. I think I’ve got it pretty good, now. See my Templates page for an example.
Now, instead of trying to get the data to appear immediately, which I could not do, I have four buttons that the user can select between the various template files, and it shows them in the <textarea> underneath.
<script type="text/javascript"> var req1 = new XMLHttpRequest(); req1.open("GET", "/templates/index.html",true); req1.send(""); var req2 = new XMLHttpRequest(); req2.open("GET", "/templates/post.html",true); req2.send(""); var req3 = new XMLHttpRequest(); req3.open("GET", "/templates/comments.html",true); req3.send(""); var req4 = new XMLHttpRequest(); req4.open("GET", "/templates/wp-layout.css",true); req4.send(""); function Display(text){ document.getElementById('template').innerHTML = text; } </script> <p>This is the current, up to date version of my conversion of Patricia Müller's Connections Template for Blogsome.</p> <p>There are four files that Blogsome uses, you need to ensure that the correct data goes into each. Each one also has, by default some features enabled. There is commenting throughout that will enable you to disable that which you do not want.</p> <p><a class="button" onclick="Display(req1.responseText);">Main Page</a> <a class="button" onclick="Display(req2.responseText);">Post</a> <a class="button" onclick="Display(req3.responseText);">Comments</a> <a class="button" onclick="Display(req4.responseText);">Style Sheet</a></p> <p><textarea id="template" wrap="off" style='width:95%;height:500px;'>Click on a button above to display the template contents.</textarea></p>
I probably could have saved the data to variables, and reused the XMLHttpRequest item, but then I would have had to find some way to wait for the response code, and that kept failing for me.
Kissing You • Des’ree • ★★★½
Maestro:
¿Qué ha pasado?, ¿te has dado de baja de Blogsome?
Sin tus conocimientos, los usuarios de Blogsome tendrán grandes dificultades para utilizar este alojamiento.
Una pena.
Saludos desde España.
1 year, 5 months after the fact.
I’m flattered.
Yeah, I’ve stopped using Blogsome. I’ll continue to provide assistance to people if I can, but I really don’t have the time to continue it, and especially since I don’t use it, I’m not sure how much help I will be.
I’ve left all of my old pages related to Blogsome up (but moved server, so any comments will be added to my new site, where I will see them).
Good luck!
1 year, 5 months after the fact.