MET CS 601

MET CS 601 project, using "click relevency" for it's list, is still available here

Labels: , ,


Very simple wysiwyg console

I found this script at webmasterworld to write out HTML or JavaScript to an IFrame on the page; acts as a very simple wysiwyg console:

<title>HomeWork 1.0</title> 
<script type="text/javascript"><!-- 

function Txt2Frame() { 


<form name="test_form"> 
<textarea onChange="Javascript:Txt2Frame(CharT.value);" name="CharT" cols="10" rows="5"></textarea> 

<iframe frameborder="1" scrolling="0" name="my_frame" width="300" height="55"></iframe> 




Using SyntaxHighlighter on Blogger site

Using the SyntaxHighlighter on non Blogger sites is pretty straightforward - for my notes on use, please see Using SyntaxHighlighter.

However, I and other have run into a bug when trying to deploy to a Blogger site, namely that <br/> would be inserted in the code when displayed to the page and, in my case, line returns would be ignored, resulting in all the code being writtent to one line.

I was able to find a solution on the Tips for software engineer site. In essence, add the following JavaScript to the page just before the closing body tag:

<script class='javascript'>  
     function FindTagsByName(container, name, Tag)  
         var elements = document.getElementsByTagName(Tag);  
         for (var i = 0; i < elements.length; i++)  
             if (elements[i].getAttribute("name") == name)  
     var elements = [];  
     FindTagsByName(elements, "code", "pre");  
     FindTagsByName(elements, "code", "textarea");  
  for(var i=0; i < elements.length; i++) {  
   if(elements[i].nodeName.toUpperCase() == "TEXTAREA") {  
    var childNode = elements[i].childNodes[0];  
    var newNode = document.createTextNode(childNode.nodeValue.replace(/<br\s*\/?>/gi,'\n'));  
    elements[i].replaceChild(newNode, childNode);  
 else if(elements[i].nodeName.toUpperCase() == "PRE") {  
    brs = elements[i].getElementsByTagName("br");  
    for(var j = 0, brLength = brs.length; j < brLength; j++) {  
     var newNode = document.createTextNode("\n");  
     elements[i].replaceChild(newNode, brs[0]);  
   //clipboard does not work well, no line breaks  
   // dp.SyntaxHighlighter.ClipboardSwf =   
   //"http://[YOUR HOST]/clipboard.swf";  

Labels: , , ,


Using SyntaxHighlighter

Following provides details on adding the Google SyntaxHighlighter to a non Blogger site.

<link type="text/css" rel="stylesheet" href="/css/SyntaxHighlighter.css"></link>
<script language="javascript" src="/js/shCore.js"></script>
<script language="javascript" src="/js/shBrushCSharp.js"></script>
<script language="javascript" src="/js/shBrushXml.js"></script>
<script language="javascript">
dp.SyntaxHighlighter.ClipboardSwf = '/flash/clipboard.swf';

<pre name="code" class="c-sharp">
string [] s = {"a", "b", "c"};
for (int i = 0; i < s.Length; i++)

However, if using integrating with Blogger you may observe some problems - if so check out this article.

Labels: , ,


January 2007  |   March 2007  |   May 2007  |   February 2008  |   April 2008  |   July 2008  |   September 2008  |   October 2008  |   December 2008  |   January 2009  |   April 2009  |   May 2009  |   June 2009  |   December 2009  |   January 2010  |  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]