Tuesday, June 17, 2008

javascript get all link in page

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function LinkList() {
var myheader = "<head><title>Links In "+document.title+"</title></head>";
myheader = myheader + "<body>";
var myfont = "<font style="font: 8pt Verdana, Arial, Helvetica, Sans-serif; line-height:18pt;" face="verdana, tahoma, geneva" size="-1" >";
var mytext = "<center><b>Links in " + document.title + "</b><ol></center>";
var myendfont = "</font>";
var myendheader = "</body>";

windowprops = "menubars=no,location=no,toolbars=no,scrollbars=yes,"+"width=350,height=400,top=50,left=50";
self.name = "main";

if(document.all) {
for (i=0; i<document.links.length; i++) {
if(document.links[i].innerText)
if(document.links[i].innerText != " ")
mytext += "<li><a target='_new' href="+document.links[i]+">"+document.links[i].innerText+"</a><br>";
else
mytext += "<li><a target='_new' href="+document.links[i]+">"+document.links[i]+"</a><br>" ;
   }
}
else {
for (i=0; i<document.links.length; i++) {
if(document.links[i].text) {
if(((document.links[i].text).indexOf("javascript:")) == -1) {
mytext += "<li><a target='_new' href="+document.links[i]+">"+document.links[i].text+"</a><br>" ;
   }
}
else { }
   }
}
mytext = mytext + "</ol><center><a href='javascript:window.close()'>close</a></center><BR>";

linkswin = window.open("","",windowprops);
with (linkswin.document) {
open();
write(myheader + myfont + mytext + myendfont + myendheader);
close();
   }
}
//  End -->
</script>
From : The JavaScript Source!!

Sunday, June 08, 2008

prettifier javascript sourcecode syntax highlighter for blogger

easy as it does not much to configure with prettifier highlighter
1.download and see the instruction here
2. copy these code and paste befor </head>

<link href='YOUR_SITE/prettify.css' rel='stylesheet' type='text/css'/>
<script src='YOUR_SITE/prettify.js' type='text/javascript'/>
3) Wrap your code and Remember to replace < with <lt; , & with &amp;
<pre class="prettyprint">
<?php
    //comment start here
    /*and can start here*/
    #and here
    class Highlighters() {
        function result($highlighter) {
            switch ($highlighter) {
               case "chili":
               default:
                  return "FTL";
               case "syntaxhighlighter":
                  return "FTW";
            }
        }
    }
 for($i=0;$i<10;$i++){
  print_r($_POST[$i])
  return true;
  return null;
 }
    $highlighters = new Highlighters();
    printf("Chili is a nice effort, but just not for me.  Chili %s", $highlighters->result("chili"));
    printf("I am going to give SyntaxHighlighter a shot.  SyntaxHighlighter %s", $highlighters->result("syntaxhighlighter"));
?>
<HTML>
<BODY onload='init();'>
TESTING HELLO WORLD
</BODY>
</HTML>
</pre>
the css is not pretty as its name but you can modify is yourself From: http://code.google.com/p/google-code-prettify/

Saturday, June 07, 2008

javascript sourcecode syntax highlighter for blogger

I've got new things what i've find for a while HOW to user SyntaxHighlighter easy 3 step to complete this highlighter
1) Include the core files and the brushes for any language you want. Your paths may be different.

    <script type="text/javascript" src="/syntaxhighlighter/js/shCore.js"></script>
    <script type="text/javascript" src="/syntaxhighlighter/js/shBrushPhp.js"></script>
    <script type="text/javascript" src="/syntaxhighlighter/js/shBrushJScript.js"></script>
    <script type="text/javascript" src="/syntaxhighlighter/js/shBrushXml.js"></script>
2) Put this at the end of your file. If you put it before the code you want highlighted it won’t work.
<script class="javascript">
dp.SyntaxHighlighter.ClipboardSwf = "syntaxhighlighter/js/clipboard.swf";
dp.SyntaxHighlighter.HighlightAll("code");
</script>
3) Wrap your code and tell SyntaxHighlighter which brush to use. Remember to replace < with &lt; , & with &amp;
<pre name="code"  class="php">
<?php
    class Highlighters() {
        function result($highlighter) {
            switch ($highlighter) {
               case "chili":
               default:
                  return "FTL";
               case "syntaxhighlighter":
                  return "FTW";
            }
        }
    }
 for($i=0;$i<10;$i++){
  print_r($_POST[$i])
 }
    $highlighters = new Highlighters();
    printf("Chili is a nice effort, but just not for me.  Chili %s", $highlighters->result("chili"));
    printf("I am going to give SyntaxHighlighter a shot.  SyntaxHighlighter %s", $highlighters->result("syntaxhighlighter"));
?>
<HTML>
<BODY onload='init();'>
TESTING HELLO WORLD
</BODY>
</HTML>
</pre>
From : http://www.pseudocoder.com/ For blogger.com following this link

Thursday, June 05, 2008

create DIV element on page

these script are to create DIV element on page with javascript
that can be define you size of header and navigator pane
by these variable headerHeight ,menuWidth
for future AJAX request to build your website


function createBlankpage(){
    var totalWidth = 0, totalHeight = 0;
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        totalWidth = window.innerWidth;
        totalHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        totalWidth = document.documentElement.clientWidth;
        totalHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        totalWidth = document.body.clientWidth;
        totalHeight = document.body.clientHeight;
    }
    var headerHeight = 150;
    var menuWidth = 170;
    var menuTop = headerHeight+'px';
    var menuHeight = totalHeight-headerHeight+'px';
    var mainTop =menuTop;
    var mainLeft = menuWidth;
    var mainWidth = totalWidth-menuWidth+'px';
    var mainHeight = menuHeight;
    createDiv('headerDIV','0px','0px',totalWidth,headerHeight);
    createDiv('menuDIV','0px',menuTop,menuWidth,menuHeight);
    createDiv('mainDIV',mainLeft,mainTop,mainWidth,mainHeight);
}

function createDiv(id,left,top,width,height,color){
    var id,top,left,height,width,visible;
    var creatingDiv = document.createElement("DIV");
    creatingDiv.id = id;
    creatingDiv.style.position="absolute";
    creatingDiv.style.left= left;
    creatingDiv.style.top= top;
    creatingDiv.style.width= width;
    creatingDiv.style.height= height;
    creatingDiv.style.verticalAlign="middle";
    creatingDiv.style.zIndex=5;
    creatingDiv.style.visibility = "visible";
    creatingDiv.innerHTML = "";
    document.body.appendChild(creatingDiv);
}