<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WiseCodes &#187; OpenSource</title>
	<atom:link href="http://www.wisecodes.com/tag/opensource/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wisecodes.com</link>
	<description>Bringing You The Power of Code !!</description>
	<lastBuildDate>Wed, 01 Sep 2010 19:33:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>5 ways to use Ajax with jQuery</title>
		<link>http://www.wisecodes.com/2009/08/5-ways-to-use-ajax-with-jquery/</link>
		<comments>http://www.wisecodes.com/2009/08/5-ways-to-use-ajax-with-jquery/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 05:35:43 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Learn]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=804</guid>
		<description><![CDATA[The people of Nettuts publishes an interesting article on using  jQuery with Ajax. Specifically the 5 ways that jQuery allows us to send asynchronous requests. $.load() $.get() $.post() $.getJSON() $.getScript() $. load () This is the feature I like most about jQuery already makes one of the most common tasks of developing with Ajax is [...]]]></description>
			<content:encoded><![CDATA[<p>The people of <strong><a href="http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/" target="_blank">Nettuts publishes an interesting article</a></strong> on using  jQuery with Ajax. Specifically <strong><a href="http://docs.jquery.com/Ajax" target="_blank">the 5 ways that </a></strong><strong><a href="http://docs.jquery.com/Ajax" target="_blank">jQuery</a></strong><strong><a href="http://docs.jquery.com/Ajax" target="_blank"> allows us to send asynchronous requests.</a></strong></p>
<ul>
<li><em><span style="color: #993300;">$.load()</span></em></li>
<li><em><span style="color: #993300;">$.get()</span></em></li>
<li><em><span style="color: #993300;">$.post()</span></em></li>
<li><em><span style="color: #993300;">$.</span></em><em><span style="color: #993300;">getJSON</span></em><em><span style="color: #993300;">()</span></em></li>
<li><em><span style="color: #993300;">$.getScript()</span></em></li>
</ul>
<p><strong> </strong></p>
<h2>$. load ()</h2>
<p>This is the feature I like most about jQuery already makes one of the most common tasks of developing with Ajax is as simple and straightforward as we shall see in this example:</p>
<pre class="brush: jscript;">
$(&quot;#div_links&quot;).load(&quot;/Main_Page #jq-p-Getting-Started li&quot;);
</pre>
<p>This example brought to <strong><a href="http://docs.jquery.com/Ajax/load#urldatacallback" target="_blank">the documentation page on </a></strong><strong><a href="http://docs.jquery.com/Ajax/load#urldatacallback" target="_blank">jQuery</a></strong>, it manages to launch a request to the URL <span style="color: #993300;"><em>/Main_Page</em></span> (usa URL Rewrite) HTML response and take the <em><span style="color: #993300;">#jq-p-Getting-Started li</span></em> and inserted into <em><span style="color: #993300;">#div_links</span></em><br />
Just great, comfortable and fast.</p>
<h2><strong>$. get ()</strong></h2>
<p>This is the simple function with which we can launch the server via GET requests Ajax.</p>
<pre class="brush: jscript;">
$.get(&quot;test.cgi&quot;, { name: &quot;Venu&quot;, time: &quot;7pm&quot; },
  function(data){
    alert(&quot;Data Loaded: &quot; + data);
  });
</pre>
<p>By passing 3 options, 2 of which are options (rather conditional) you can request to launch the file (1) with parameters (2) and treat the response through a callback (3rd).</p>
<h2><strong>$. post ()</strong></h2>
<p>Like the above, this feature lets you send POST requests using Ajax.</p>
<pre class="brush: jscript;">
$.post(&quot;test.php&quot;, { name: &quot;Venu&quot;, time: &quot;7pm&quot; },
  function(data){
    alert(&quot;Data Loaded: &quot; + data);
  });
</pre>
<p>As easy as above.</p>
<h2><strong>$. </strong><strong>getJSON</strong><strong> ()</strong></h2>
<p>Although the above are able to specify the type of return, the best option is to use this method to obtain the response in JSON evaludada the callback function.</p>
<pre class="brush: jscript;">
$.getJSON(&quot;test.js&quot;, { name: &quot;Venu&quot;, time: &quot;7pm&quot; }, function(json){
  alert(&quot;JSON Data: &quot; + json.users[3].name);
});
</pre>
<p>Taking into account the browser, the object will use <strong><a href="http://www.wisecodes.com/2009/08/everything-you-ever-wanted-to-know-about-json/">native JSON</a></strong> or use a system based on <em><span style="color: #993300;">eval()</span></em>.</p>
<h2><strong>$. </strong><strong>getScript</strong><strong> ()</strong></h2>
<p>Although technically not an Ajax request is a request to the server and therefore has a place in the post.</p>
<pre class="brush: jscript;">
$.getScript(&quot;test.js&quot;, function(){
  alert(&quot;Script loaded and executed.&quot;);
});
</pre>
<p>With this method we can load a file asynchronously using JavaScript and the parameter (2) callback can execute Javascript code that is using the js file that we want to load (1).</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/5-ways-to-use-ajax-with-jquery/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/5-ways-to-use-ajax-with-jquery/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/5-ways-to-use-ajax-with-jquery/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>FTP connection with JAVA</title>
		<link>http://www.wisecodes.com/2009/08/ftp-connection-with-java/</link>
		<comments>http://www.wisecodes.com/2009/08/ftp-connection-with-java/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 19:29:39 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=806</guid>
		<description><![CDATA[Java again gives us another tool. What is FTP? FTP protocol that allows us to send or receive data from one point to another, be it a PC, server, or any other node that is connected to a network. Usually when you have a web host these accounts have FTP congratulate sending files from our pc [...]]]></description>
			<content:encoded><![CDATA[<p>Java again gives us another tool.</p>
<p><strong>What is FTP?</strong></p>
<p>FTP protocol that allows us to send or receive data from one point to another, be it a PC, server, or any other node that is connected to a network.</p>
<p>Usually when you have a web host these accounts have FTP congratulate sending files from our pc to the server that is hosting our site.</p>
<p>Investigating around I found a FTP client library very useful, I have tried it and going great. The library <strong><a href="http://jvftp.sourceforge.net/">JvFTP</a></strong><strong><a href="http://jvftp.sourceforge.net/"> Client</a></strong> provides interesting tasks, including:</p>
<ul>
<li>Uploading / downloading files</li>
<li>Uploading directories recursively</li>
<li>Concurrent data transfer</li>
<li>Data transfer mode passive / active</li>
<li>Swing components to display directories</li>
<li>Components AWTpara display directories</li>
</ul>
<p>This tool is available in <strong><a href="http://sourceforge.net/projects/jvftp/">jvftp</a></strong> and can be used in two ways, you run directly the jar, or do your own programming, including the libraries in your project.</p>
<p>If you want to program your own example here I leave a little guide on how you can do, let&#8217;s see &#8230;</p>
<p>&#8230; The first thing to do is incorporate the packages downloaded from jvftp in your project. Then you import the libraries to the class in which you make the connection:</p>
<pre class="brush: java;">
import cz.dhl.io.*;
import cz.dhl.ftp.*;
import java.io.IOException;
</pre>
<p>Now we create the connection, the connection to prepare the data before creating access the FTP site. Let&#8217;s start with the server:</p>
<pre class="brush: java;">
FtpConnect cn = FtpConnect.newConnect(&quot;ftp://ftp.domain.com&quot;);
</pre>
<p>ftp.domain.com value which is the server you are connecting. Each ftp account that include at least the server name, username and password. To log in using that account is something like this:</p>
<pre class="brush: java;">
// Username
cn.setUserName(&quot;username&quot;);

// Password
cn.setPassWord(&quot;password&quot;);
</pre>
<p>Then it creates an object of type FTP, which is responsible for rendering all the information from our FTP site.</p>
<pre class="brush: java;">
Ftp ftp1 = new Ftp();
</pre>
<p>Now the connection to the FTP site to begin processing the respective tasks</p>
<pre class="brush: java;">
ftp1.connect(cn);
</pre>
<p>A practical example to test the connection would be to show the current directory with their files:</p>
<pre class="brush: java;">
CoFile dir = new FtpFile(ftp1.pwd(), ftp1);

// Make a list of files that have the current directory
CoFile cfls[] = dir.listCoFiles();
if ( cfls != null )
        for (int n = 0; n &lt; cfls.length; n++)
                    System.out.println( cfls[n].getName() + (cfls[n].isDirectory() ? &quot;/&quot; : &quot;&quot;));
</pre>
<p>Finally, there is only close the connection.</p>
<pre class="brush: java;">
ftp1.disconnect();
</pre>
</pre>
<p>Download <a href="http://sourceforge.net/projects/jvftp/"><strong>jvftp</strong></a></p>
<p>Happy Programming!!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/ftp-connection-with-java/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/ftp-connection-with-java/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/ftp-connection-with-java/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Code in C# to create a backup of a database in SQL server and restore it</title>
		<link>http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/</link>
		<comments>http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 20:04:47 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[BackUp]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Restore]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=787</guid>
		<description><![CDATA[Here they left a code in C # very useful when making your applications with databases in SQL server can support the database and restore it. Support code for a button: private void btnBackUp_Click(object sender, EventArgs e) { bool bBackUpStatus = true; Cursor.Current = Cursors.WaitCursor; if (Directory.Exists(@&#34;c:\SQLBackup&#34;)) { if (File.Exists(@&#34;c:\SQLBackup\wcBackUp1.bak&#34;)) { if (MessageBox.Show(@&#34;Do you want [...]]]></description>
			<content:encoded><![CDATA[<p>Here they left a code in C # very useful when making your applications with databases in SQL server can support the database and restore it.</p>
<p>Support code for a button:</p>
<pre class="brush: csharp;">
private void btnBackUp_Click(object sender, EventArgs e)
{
    bool bBackUpStatus = true;

    Cursor.Current = Cursors.WaitCursor; 

     if (Directory.Exists(@&quot;c:\SQLBackup&quot;))
        {
            if (File.Exists(@&quot;c:\SQLBackup\wcBackUp1.bak&quot;))
            {
                if (MessageBox.Show(@&quot;Do you want to replace it?&quot;, &quot;Back&quot;, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    File.Delete(@&quot;c:\SQLBackup\wcBackUp1.bak&quot;);
                }
                else
                    bBackUpStatus = false;
            }
        }
        else
            Directory.CreateDirectory(@&quot;c:\SQLBackup&quot;);

        if (bFileStatus)
        {
            //Connect to DB
            SqlConnection connect;
            string con = &quot;Data Source = localhost; Initial Catalog=dbWiseCodes ;Integrated Security = True;&quot;;
            connect = new SqlConnection(con);
            connect.Open();
            //----------------------------------------------------------------------------------------------------

            //Execute SQL---------------
            SqlCommand command;
            command = new SqlCommand(@&quot;backup database dbWiseCodes to disk ='c:\SQLBackup\wcBackUp1.bak' with init,stats=10&quot;, connect);
            command.ExecuteNonQuery();
            //-------------------------------------------------------------------------------------------------------------------------------

            connect.Close();

            MessageBox.Show(&quot;The support of the database was successfully performed&quot;, &quot;Back&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
}
</pre>
<p>Code for a button to restore:</p>
<pre class="brush: csharp;">

private void btnRestore_Click(object sender, EventArgs e)
{

    Cursor.Current = Cursors.WaitCursor;

    try
    {
        if (File.Exists(@&quot;c:\SQLBackup\wcBackUp1.bak&quot;))
        {
            if (MessageBox.Show(&quot;Are you sure you restore?&quot;, &quot;Back&quot;, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                //Connect SQL-----------
                SqlConnection connect;
                string con = &quot;Data Source = localhost; Initial Catalog=master ;Integrated Security = True;&quot;;
                connect = new SqlConnection(con);
                connect.Open();
                //-----------------------------------------------------------------------------------------

                //Excute SQL----------------
                SqlCommand command;
          command = new SqlCommand(&quot;use master&quot;, connect);
            command.ExecuteNonQuery();
                command = new SqlCommand(@&quot;restore database dbWiseCodes01 from disk = 'c:\SQLBackup\wcBackUp1.bak'&quot;, connect);
                command.ExecuteNonQuery();
                //--------------------------------------------------------------------------------------------------------
                connect.Close();

                MessageBox.Show(&quot;Has been restored database&quot;, &quot;Restoration&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        else
            MessageBox.Show(@&quot;Do not make any endorsement above (or is not in the correct path)&quot;, &quot;Restoration&quot;, MessageBoxButtons.OK, MessageBoxIcon.Information);

    }
    catch (Exception exp)
    {
        MessageBox.Show(exp.Message);
    }

}
</pre>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/code-in-c-to-create-a-backup-of-a-database-in-sql-server-and-restore-it/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Print PDF with JPedal</title>
		<link>http://www.wisecodes.com/2009/08/print-pdf-with-jpedal/</link>
		<comments>http://www.wisecodes.com/2009/08/print-pdf-with-jpedal/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 16:08:43 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[JAVA]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[PDF]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=776</guid>
		<description><![CDATA[Researching a bit about the handling of a PDF document I found a library called JPedal for manipulating PDF documents from Java. Like other libraries I&#8217;ve seen among other iText and iReport, which are very comprehensive and allow you to do many tasks, including printing. Disadvantage that the latter is that you need to have [...]]]></description>
			<content:encoded><![CDATA[<p>Researching a bit about the handling of a PDF document I found a library called <strong><a href="http://www.jpedal.org/index.php">JPedal</a></strong> for manipulating PDF documents from Java.<br />
Like other libraries I&#8217;ve seen among other iText and iReport, which are very comprehensive and allow you to do many tasks, including printing. Disadvantage that the latter is that you need to have installed Acrobat Reader and for many users this is not possible.<br />
But even with JPedal lets you see the Acrobat Reader tools within the Java application, providing a task pane for the PDF to manipulate.</p>
<p>With PrinterJob.lookupPrintServices can get the services available and print them PrinterJob a concrete one.</p>
<pre class="brush: java;">
PrintService[] psService = PrinterJob.lookupPrintServices();
PrinterJob pjPrintJob = PrinterJob.getPrinterJob();
pjPrintJob.setPrintService(psService[0]);

// Assigns the size of the paper to A4.

Paper paper = new Paper();
paper.setSize(595, 842);
paper.setImageableArea(0, 0, 595, 842);
PageFormat pf = pjPrintJob.defaultPage();
pf.setPaper(paper);
</pre>
<p>Loads the PDF to be printed. The file is called wc_PDF.pdf printed and given format.</p>
<pre class="brush: java;">
PdfDecoder pdfD = null;
pdfD = new PdfDecoder(true);
pdfD.openPdfFile(&quot;wc_PDF.pdf&quot;);
pdfD.setPageFormat(pf);
</pre>
<p>It sends the file to print</p>
<pre class="brush: java;">
printJob.setPageable(pdfD);
printJob.print();
</pre>
<p>And to finalize the document is closed.</p>
<pre class="brush: java;">
pdf.closePdfFile();
</pre>
<p><strong><a href="http://www.jpedal.org/index.php">Download JPedal..</a></strong></p>
<p>The example would then complete as follows:</p>
<pre class="brush: java;">
import java.awt.print.Paper;
import java.awt.print.PrinterJob;
import java.awt.print.PageFormat;
import javax.print.PrintService;
import org.jpedal.PdfDecoder;

public final void wc_PrintPDF() {
    PdfDecoder pdfD = null;
    try {
        PrintService[] psService = PrinterJob.lookupPrintServices();
        PrinterJob pjPrintJob = PrinterJob.getPrinterJob();
        pjPrintJob.setPrintService(psService[0]);

        Paper paper = new Paper();
        paper.setSize(595, 842);
        paper.setImageableArea(0, 0, 595, 842);
        PageFormat pf = pjPrintJob.defaultPage();
        pf.setPaper(paper);

        pdfD = new PdfDecoder(true);
        pdfD.openPdfFile(&quot;wc_PDF.pdf&quot;);
        pdfD.setPageFormat(pf);

        pjPrintJob.setPageable(pdfD);
        pjPrintJob.print();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        pdfD.closePdfFile();
    }
}
</pre>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/print-pdf-with-jpedal/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/print-pdf-with-jpedal/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/print-pdf-with-jpedal/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ASP: Online Users Counter</title>
		<link>http://www.wisecodes.com/2009/08/asp-online-users-counter/</link>
		<comments>http://www.wisecodes.com/2009/08/asp-online-users-counter/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 18:16:05 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[VBScript]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=748</guid>
		<description><![CDATA[This popular script is found in almost all sites in ASP, used to count visitors assets (present at the time), is on our website. The code should be used in the file Global.asa. Must not be enclosed in must be unique and that has within it. (Well, not unique, but playing with Global.asa not recommend [...]]]></description>
			<content:encoded><![CDATA[<p>This popular script is found in almost all sites in ASP, used to count visitors assets (present at the time), is on our website. </p>
<p>The code should be used in the file Global.asa. Must not be enclosed in <% and%> must be unique and that has within it. (Well, not unique, but playing with Global.asa not recommend it). </p>
<p>Here&#8217;s the code that goes into the Global.asa </p>
<pre class="brush: xml;">
&lt;script language=vbscript runat=server&gt; 

Sub Application_OnStart
Application(&quot;Active&quot;) = 0
End Sub 

Sub Application_OnEnd
End Sub 

Sub Session_OnStart
Application.Lock
Application(&quot;Active&quot;) = Application(&quot;Active&quot;) + 1
Application.Unlock
End Sub 

Sub Session_OnEnd
Application.Lock
Application(&quot;Active&quot;) = Application(&quot;Active&quot;) - 1
Application.Unlock
End Sub 

&lt;/script&gt;
</pre>
<p>And to show the information which the Global.asa, or to show active users as I did in my example, they should put the following on the page displaying the data: </p>
<pre class="brush: xml;">
&lt;P&gt;There are currently &lt;%=Application(&quot;Active&quot;)%&gt; user's on our site&lt;/P&gt;
</pre>
<p>Happy Programming!!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/asp-online-users-counter/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/asp-online-users-counter/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/asp-online-users-counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Tic Tac Toe</title>
		<link>http://www.wisecodes.com/2009/08/javascript-tic-tac-toe/</link>
		<comments>http://www.wisecodes.com/2009/08/javascript-tic-tac-toe/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 15:17:33 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=741</guid>
		<description><![CDATA[View Demo Download Code [3.29 kb] Playing The computer always plays with circles ( &#8220;O&#8221;) and you with blades ( &#8220;X&#8221;). Start your. To put an X have to click on the button the bottom panel that corresponds to the position you want to put it. You can also hand-write it, always with capital letters [...]]]></description>
			<content:encoded><![CDATA[<h2><a href="http://wisecodes.com/Code/TicTacToeJavascript/TicTacToe.html" target="_blank"><img class="alignnone size-full wp-image-18" title="live_preview" src="http://www.wisecodes.com/wp-content/uploads/2009/02/live_preview.png" alt="live_preview" width="32" height="32" /> View Demo</a> <a href="http://wisecodes.com/Code/TicTacToeJavascript/TicTacToe.rar"><img class="alignnone size-full wp-image-29" title="download" src="http://www.wisecodes.com/wp-content/uploads/2009/02/download.gif" alt="download" width="32" height="35" />Download Code</a> [3.29 kb]</h2>
<h2>Playing</h2>
<p>The computer always plays with <em> circles </em> ( &#8220;O&#8221;) and you with <em> blades </em><br />
( &#8220;X&#8221;). Start your. To put an X <em> </em> have to click on the button<br />
the bottom panel that corresponds to the position you want to put it. You can<br />
also hand-write it, always with capital letters (without cheating, because the<br />
computer trusts you).</p>
<p>The computer will make its <em> redondel </em> every time you put your <em> X </em>.<br />
Never make a mistake, and if you neglect (and you do not cheat), you win. If you cheat, do not<br />
work correctly.</p>
<p>When the game ends, the computer shows the result and increase the counters<br />
lower. To play another game, press the button again <strong> Game </strong>, which<br />
Clean the panel game. To clear the counters, click the Clear button <strong>Clear</strong>.</p>
<p>This < head> between and <strong><</strong>/head>:</p>
<pre class="brush: xml;">
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
// Tic Tac Toe
// Version: 1 (10/08/2009)
// Venu Thomas
// This script and many others can
// download online for free
// in the code: [url = http://www.wisecodes.com] www.wisecodes.com [/ url] 

// To understand the explanations:
// Win - and win puts
// Game - and has put in a two-line 'O' and an empty box
// Defend - keep winning the next move in the opposite
// It makes no sense at first occupy the center if there is victory or play
// There must defend first and attack later. First look for the victory, then
// search and then defends move 

// global variable
var strPlaying = true   

//ROLE PLAY CHECK------------------------------------------------
function wc_fnCheckPlay(grid, record) {
    // check that it is possible to stripe 3 in a row, column or diagonal
     // returns the position where you have to put the record to do so and -1 if there is no gamble   

    var x, y   

    for(x = 0; x &lt; 9; x += 3) {      //Check the rows
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 1].value == record))
            if (grid.elements[x + 2].value == &quot;&quot;)
                return (x + 2)
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 2].value == record))
            if (grid.elements[x + 1].value == &quot;&quot;)
                return (x + 1)
        if ((grid.elements[x + 1].value == record) &amp;&amp; (grid.elements[x + 2].value == record))
            if (grid.elements[x].value == &quot;&quot;)
                return (x)
    }   

    for(x = 0; x &lt; 3; x++) {     //Check the columns
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 3].value == record))
            if (grid.elements[x + 6].value == &quot;&quot;)
                return (x + 6)
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 6].value == record))
            if (grid.elements[x + 3].value == &quot;&quot;)
                return (x + 3)
        if ((grid.elements[x + 3].value == record) &amp;&amp; (grid.elements[x + 6].value == record))
            if (grid.elements[x].value == &quot;&quot;)
                return (x)
    }   

    //check the diagonals
    if ((grid.elements[2].value == record) &amp;&amp; (grid.elements[4].value == record) &amp;&amp; (grid.elements[6].value == &quot;&quot;))
        return (6)
    if ((grid.elements[2].value == record) &amp;&amp; (grid.elements[4].value == &quot;&quot;) &amp;&amp; (grid.elements[6].value == record))
        return (4)
    if ((grid.elements[2].value == &quot;&quot;) &amp;&amp; (grid.elements[4].value == record) &amp;&amp; (grid.elements[6].value == record))
        return (2)
    if ((grid.elements[0].value == record) &amp;&amp; (grid.elements[4].value == record) &amp;&amp; (grid.elements[8].value == &quot;&quot;))
        return (8)
    if ((grid.elements[0].value == record) &amp;&amp; (grid.elements[4].value == &quot;&quot;) &amp;&amp; (grid.elements[8].value == record))
        return (4)
    if ((grid.elements[0].value == &quot;&quot;) &amp;&amp; (grid.elements[4].value == record) &amp;&amp; (grid.elements[8].value == record))
        return (0)   

    return -1
}   

//HORIZONTAL PARTNER ROLE
function wc_fnPartnerHorizontal(grid, record) {
    // check if it's possible to put 2 in a row, the other empty position ...
     //... same row
     // returns the row to do so, or -1 if not 

    var x, y   

    for(x = 0; x &lt; 9; x += 3) {      //Check the rows
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 1].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 2].value == &quot;&quot;))
            return (x)
        if ((grid.elements[x].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 1].value == record) &amp;&amp; (grid.elements[x + 2].value == &quot;&quot;))
            return (x + 1)
        if ((grid.elements[x].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 1].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 2].value == record))
            return (x + 2)
    }   

    return -1
}   

//VERTICAL PARTNER ROLE---------------------------------------------------
function wc_fnPartnerVertical(grid, record, playHtal) {
 // check if it's possible to put 2 in a column, the other empty position ...
     //... same column and taking into account whether that position is horizontal pair
     // returns the column if you do not allow horizontal pair, or -1 if not      

    var x, y   

    for(x = 0; x &lt; 3; x++) {         //check the columns
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 3].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 6].value == &quot;&quot;))
            if (x != playHtal)        //if partner not interested in horizontal and vertical
                return (x)
        if ((grid.elements[x].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 3].value == record) &amp;&amp; (grid.elements[x + 6].value == &quot;&quot;))
            if ((x + 3) != playHtal)
                return (x + 3)
        if ((grid.elements[x].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 3].value == &quot;&quot;) &amp;&amp; (grid.elements[x + 6].value == record))
            if ((x + 6) != playHtal)
                return (x + 6)
    }   

    return -1
}   

//Get POSITION\
function wc_fnGetPosition(playHtal, playVcal) {
 // Find the position that allows you move vertically and horizontally at the same time move
     // known row and column where couples can be

    var x, y, fila, columna
    var position = 0
    matrix = new Array(3)   

    for (x = 0; x &lt; 3; x++) {        //creates a matrix that assigns a row and column position
        matrix[x] = new Array(3)
        for (y = 0; y &lt; 3; y++) {
            matrix[x][y] = position
            position ++
        }
    }   

    for (x = 0; x &lt; 3; x++) {                    //looking for the row and column
        for (y = 0; y &lt; 3; y++) {
            if (matrix[x][y] == playHtal) //find the row
                fila = x
            if (matrix[x][y] == playVcal) //I found the column
                columna = y
        }
    }   

    return (matrix[fila][columna])          //move back position
}   

//FUNCION REDONDELA PUT-------------------------------------------------
function wc_fnPutRedondela(grid) {
    //the ordanador plays

    var play, playHtal, playVcal   

    //attacks and wins
    play = wc_fnCheckPlay(grid, &quot;O&quot;)
    if (play != -1) {
        grid.elements[play].value = &quot;O&quot;
        alert('I won!!!')
        document.scoreboard.missing.value++
        strPlaying = false
        return 1
    }   

    //advocates avoiding the rival wins
    play = wc_fnCheckPlay(grid, &quot;X&quot;)
    if (play != -1) {
        grid.elements[play].value = &quot;O&quot;
        return 1
    }   

    //attacks and win the next
    playHtal = wc_fnPartnerHorizontal(grid, &quot;O&quot;)
    playVcal = wc_fnPartnerVertical(grid, &quot;O&quot;, playHtal)
    if ((playHtal != -1) &amp;&amp; (playVcal != -1)) {     //you can put 2 and 2 in a row in column
        if ((playHtal != 4) || (playVcal != 4)) {       //is not the center
            play = wc_fnGetPosition(playHtal, playVcal)  //gets where it should put
            grid.elements[play].value = &quot;O&quot;
            return 1
        }
    }   

    //attacks and put two in a row
    if ((playHtal != -1) &amp;&amp; (playVcal == -1)) {
        if ((playHtal != 2) &amp;&amp; (playHtal != 5) &amp;&amp; (playHtal != 8))    //this is arbitrary
            grid.elements[playHtal + 1].value = &quot;O&quot;                        //puts the right
        else
            grid.elements[playHtal - 1].value = &quot;O&quot;                        //placed to the left
        return 1
    }   

    //attacks and put in two column
    if ((playHtal == -1) &amp;&amp; (playVcal != -1)) {
        if ((playVcal != 6) &amp;&amp; (playVcal != 7) &amp;&amp; (playVcal != 8))
            grid.elements[playVcal + 3].value = &quot;O&quot;        //put down
        else
            grid.elements[playVcal - 3].value = &quot;O&quot;        //puts up
        return 1
    }   

    //occupies the center
    if (grid.elements[4].value == &quot;&quot;) {
        grid.elements[4].value = &quot;O&quot;
        return 1
    }   

    //This took the first free
    for (x = 0; x &lt; 9; x++)
        if (grid.elements[x].value == &quot;&quot;) {
            grid.elements[x].value = &quot;O&quot;
            return 1
        }   

    alert('Draw...')
    document.scoreboard.draw.value++
    strPlaying = false
    return -1
}   

//FUNCION PUT ASPA
function wc_fnPutAspa(grid, position) {   

    //first check that this strPlaying
    if (strPlaying) {
        if (grid.elements[position].value != &quot;&quot;)     //empty box
            alert('That box is already occupied.')
        else {                                                  //empty box, you can put
            grid.elements[position].value = &quot;X&quot;  

            //Check if you have won
            if ( wc_fnNotesVictoria(grid, &quot;X&quot;) ) {
                alert('Congratulations! You win... <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ')
                document.scoreboard.won.value++
                strPlaying = false
            } else
                wc_fnPutRedondela(grid)
        }
    } else {
        alert('To start a new line \nClick Play again.')
    }
}   

//VICTORIA FUNCTION CHECK
function wc_fnNotesVictoria(grid, record) {   

    //Check if you have earned the record player that plays with  

    var x   

    for(x = 0; x &lt; 9; x += 3) {  //Check the rows
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 1].value == record) &amp;&amp; (grid.elements[x + 2].value == record))
            return true
    }   

    for(x = 0; x &lt; 3; x++) {     //check the columns
        if ((grid.elements[x].value == record) &amp;&amp; (grid.elements[x + 3].value == record) &amp;&amp; (grid.elements[x + 6].value == record))
            return true
    }   

    //check the diagonals
    if ((grid.elements[2].value == record) &amp;&amp; (grid.elements[4].value == record) &amp;&amp; (grid.elements[6].value == record))
        return true
    if ((grid.elements[0].value == record) &amp;&amp; (grid.elements[4].value == record) &amp;&amp; (grid.elements[8].value == record))
        return true   

    return false
}   

&lt;/script&gt;
</pre>
<p>And this from <strong><</strong>body> and <strong><</strong>/body> :</p>
<pre class="brush: xml;">
&lt;!-- To display the grid, and Accountants --&gt;
&lt;form name=&quot;grid&quot;&gt;
  &lt;div align=&quot;center&quot;&gt;&lt;center&gt;
  &lt;table border=&quot;0&quot; width=&quot;62%&quot; cellpadding=&quot;5&quot;&gt;
    &lt;tr&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T0&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T1&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T2&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot; align=&quot;right&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T3&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T4&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T5&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot; align=&quot;right&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T6&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T7&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;T8&quot; size=&quot;3&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot; align=&quot;right&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B0&quot; onClick=&quot;wc_fnPutAspa(grid, 0)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B1&quot; onClick=&quot;wc_fnPutAspa(grid, 1)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B2&quot; onClick=&quot;wc_fnPutAspa(grid, 2)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot;&gt;&lt;input type=&quot;reset&quot; value=&quot;New game&quot; name=&quot;new&quot; onClick=&quot;strPlaying=true&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=&quot;18%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B3&quot; onClick=&quot;wc_fnPutAspa(grid, 3)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;17%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B4&quot; onClick=&quot;wc_fnPutAspa(grid, 4)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;18%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B5&quot; onClick=&quot;wc_fnPutAspa(grid, 5)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=&quot;18%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B6&quot; onClick=&quot;wc_fnPutAspa(grid, 6)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;17%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B7&quot; onClick=&quot;wc_fnPutAspa(grid, 7)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;18%&quot;&gt;&lt;input type=&quot;button&quot; value=&quot; X &quot; name=&quot;B8&quot; onClick=&quot;wc_fnPutAspa(grid, 8)&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot; align=&quot;right&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/center&gt;&lt;/div&gt;
&lt;/form&gt;

&lt;form name=&quot;scoreboard&quot;&gt;
  &lt;div align=&quot;center&quot;&gt;&lt;center&gt;
  &lt;table border=&quot;0&quot; width=&quot;62%&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot;&gt;
    &lt;tr&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;small&gt;draw:&lt;br&gt;
      &lt;/small&gt;&lt;input type=&quot;text&quot; name=&quot;draw&quot; value=&quot;0&quot; size=&quot;6&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;small&gt;missing:&lt;br&gt;
      &lt;/small&gt;&lt;input type=&quot;text&quot; name=&quot;missing&quot; value=&quot;0&quot; size=&quot;6&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;20%&quot;&gt;&lt;small&gt;won:&lt;br&gt;
      &lt;/small&gt;&lt;input type=&quot;text&quot; name=&quot;won&quot; value=&quot;0&quot; size=&quot;6&quot;&gt;&lt;/td&gt;
      &lt;td width=&quot;85%&quot;&gt; &lt;br&gt;&lt;input type=&quot;reset&quot; value=&quot;Clear&quot; name=&quot;delete&quot; class=&quot;metal&quot;&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/center&gt;&lt;/div&gt;
&lt;/form&gt;

&lt;h2&gt;Playing&lt;/h2&gt;
&lt;p&gt;The computer always plays with &lt;em&gt; circles &lt;/em&gt; ( &quot;O&quot;) and you with &lt;em&gt; blades &lt;/em&gt;
( &quot;X&quot;). Start your. To put an X &lt;em&gt; &lt;/em&gt; have to click on the button
the bottom panel that corresponds to the position you want to put it. You can
also hand-write it, always with capital letters (without cheating, because the
computer trusts you).&lt;/p&gt;
&lt;p&gt;The computer will make its &lt;em&gt; redondel &lt;/em&gt; every time you put your &lt;em&gt; X &lt;/em&gt;.
Never make a mistake, and if you neglect (and you do not cheat), you win. If you cheat, do not
work correctly.&lt;/p&gt;
&lt;p&gt;When the game ends, the computer shows the result and increase the counters
lower. To play another game, press the button again &lt;strong&gt; Game &lt;/strong&gt;, which
Clean the panel game. To clear the counters, click the Clear button &lt;strong&gt;Clear&lt;/strong&gt;.&lt;/p&gt;
</pre>
<p>Happy Programming!!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/javascript-tic-tac-toe/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/javascript-tic-tac-toe/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/javascript-tic-tac-toe/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Multiline in JavaScript</title>
		<link>http://www.wisecodes.com/2009/08/javascript-multiline/</link>
		<comments>http://www.wisecodes.com/2009/08/javascript-multiline/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 19:52:41 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=717</guid>
		<description><![CDATA[Whenever you try to write a script in Javascript that requires a string of multiple lines get an error code that is poorly trained. That is a problem for these scripts to generate HTML content, because by having a clear line and we lose we do not see exactly what you&#8217;re painting. $('#ID').append( '&#60;div id=&#34;wcDIV&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Whenever you try to write a script in Javascript that requires a string of multiple lines get an error code that is poorly trained. That is a problem for these scripts to generate HTML content, because by having a clear line and we lose we do not see exactly what you&#8217;re painting.</p>
<pre class="brush: jscript;">
$('#ID').append(
   '&lt;div id=&quot;wcDIV&quot;&gt; \
      &lt;p&gt;Welcome to WiseCodes.Com!&lt;/p&gt; \
    &lt;/div&gt;'
);

var strWelcome = 'Welcome \
to WiseCodes.Com!'
</pre>
<p>The key is used (\) to indicate the line, that mysteriously causes the browser detects that it is a single line, making the job of uniting us.<br />
A curiosity of this language that helps us to make things easier and above all clear.</p>
<p>Happy Programming !!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/javascript-multiline/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/javascript-multiline/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/javascript-multiline/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The best way to load javascript</title>
		<link>http://www.wisecodes.com/2009/08/the-best-way-to-load-javascript/</link>
		<comments>http://www.wisecodes.com/2009/08/the-best-way-to-load-javascript/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 16:27:55 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=703</guid>
		<description><![CDATA[Nicholas C. Zakas has been thinking about the issue and has taken 3 points needed to be taken to improve the load javascript on our pages. * Create two files Javascript. In the first place you need to dynamically load another javascript file and the second with the code needed for our application. * Javascript [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/" target="_blank">Nicholas C. Zakas has been thinking about the issue</a></strong> and has taken 3 points needed to be taken to improve the load javascript on our pages.</p>
<p>* Create two files Javascript. In the first place you need to dynamically load another javascript file and the second with the code needed for our application.<br />
* Javascript includes the first end of the page just above <em>&lt; / body &gt;</em><br />
* Just below we create a second tag <em>&lt; script &gt;</em> where to call / the file / s needed.</p>
<p>Our HTML would be more or less like this:</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://your.cdn.com/first.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
loadScript(&quot;http://your.cdn.com/second.js&quot;, function(){
//initialization code
});
&lt;/script&gt;
</pre>
<h3>loadScript ()</h3>
<p>loadScript () function is responsible for loading the Javascript file in a dynamic and responsible for implementing the code as the second parameter to indicate when it is loaded correctly.</p>
<pre class="brush: jscript;">
function loadScript(url, callback){

var script = document.createElement(&quot;script&quot;)
script.type = &quot;text/javascript&quot;;

if (script.readyState){  //IE
script.onreadystatechange = function(){
if (script.readyState == &quot;loaded&quot; ||
script.readyState == &quot;complete&quot;){
script.onreadystatechange = null;
callback();
}
};
} else {  //Others
script.onload = function(){
callback();
};
}

script.src = url;
document.getElementsByTagName(&quot;head&quot;)[0].appendChild(script);
}
</pre>
<p>Clearly, these optimizations improve outcome, although we are talking about milliseconds (or seconds in the worst case). But it&#8217;s good to know how to improve our scripts and pulirlos well.</p>
<p>Happy Programming!!! <img src='http://www.wisecodes.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/the-best-way-to-load-javascript/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/08/the-best-way-to-load-javascript/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/08/the-best-way-to-load-javascript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Doodle.js, library for working with canvas</title>
		<link>http://www.wisecodes.com/2009/07/doodle-js-library-for-working-with-canvas/</link>
		<comments>http://www.wisecodes.com/2009/07/doodle-js-library-for-working-with-canvas/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 20:43:39 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[JAVASCRIPT]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=621</guid>
		<description><![CDATA[Doodle.js is a library that allows us to easily work with the element &#60;canvas /&#62; and everything that entails. With a similar aesthetic to jQuery, drawing on the canvas that is &#60;canvas /&#62; is as simple as this: &#60;head&#62; &#60;!--[if IE]&#62;&#60;script type=&#34;text/javascript&#34; src=&#34;http://explorercanvas.googlecode.com/svn/trunk/excanvas.js&#34;&#62;&#60;/script&#62;&#60;![endif]--&#62; &#60;script src=&#34;./doodle-0.1.js&#34; type=&#34;text/javascript&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34;&#62; function init() { (function(oo) { oo.canvas('#my_canvas'); oo.rect({x:25, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lamberta.org/blog/doodle/" target="_blank">Doodle.js</a> is a library that allows us to easily work with the element &lt;canvas /&gt; and <a href="http://www.wisecodes.com/2009/06/detection-of-faces-on-canvas-with-javascript/" target="_blank">everything that entails</a>. With a similar aesthetic to jQuery, <a href="http://www.wisecodes.com/tag/canvas/" target="_blank">drawing on the canvas that is</a> &lt;canvas /&gt; is as simple as this:</p>
<pre class="brush: xml;">

  &lt;head&gt;
  &lt;!--[if IE]&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;http://explorercanvas.googlecode.com/svn/trunk/excanvas.js&quot;&gt;&lt;/script&gt;&lt;![endif]--&gt;
  &lt;script src=&quot;./doodle-0.1.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
    function init() {
      (function(oo) {
  oo.canvas('#my_canvas');
  oo.rect({x:25, y:25, width:50, height:50}).draw();

})($doodle);

    };
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;!--init() is called when the canvas is ready for us.--&gt;
  &lt;body onload=&quot;javascript:init();&quot;&gt;
    &lt;canvas id=&quot;my_canvas&quot; width=&quot;600&quot; height=&quot;400&quot;&gt;
      &lt;p&gt;Fallback: Canvas element is not supported in this browser!&lt;/p&gt;
    &lt;/canvas&gt;
  &lt;/body&gt;
</pre>
<h4>Examples</h4>
<p>Do not miss some of the examples available on the homepage of the library:<br />
<a href="http://www.lamberta.org/demo/js/doodle/examples/01/spiral.html" target="_blank"> Spiral multicolor</a><br />
<a href="http://www.lamberta.org/demo/js/doodle/examples/01/bouncy.html" target="_blank"> Rebounds multiple</a></p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/07/doodle-js-library-for-working-with-canvas/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/07/doodle-js-library-for-working-with-canvas/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/07/doodle-js-library-for-working-with-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proposal subtitle for HTML5 video tag</title>
		<link>http://www.wisecodes.com/2009/07/proposal-subtitle-for-html5-video-tag/</link>
		<comments>http://www.wisecodes.com/2009/07/proposal-subtitle-for-html5-video-tag/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 18:44:05 +0000</pubDate>
		<dc:creator>Venu Thomas</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.wisecodes.com/?p=598</guid>
		<description><![CDATA[In Ginger&#8217;s Thoughts I read a very interesting proposal which I believe is that in just a proposal. Although the idea is very good and it might be interesting to have this in the new HTML5. The proposal is for December 2008 and so far no developments. The idea is to include the tag HTML5&#8242;s [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blog.gingertech.net/2008/12/12/attaching-subtitles-to-html5-video/" target="_blank">Ginger&#8217;s Thoughts I read a very interesting proposal</a> which I believe is that in just a proposal. Although the idea is very good and it might be interesting to have this in the new HTML5. The proposal is for December 2008 and so far no developments.<br />
The idea is to include the tag  HTML5&#8242;s ability to handle subtitles:</p>
<pre class="brush: xml;">
&lt;video src=&quot;http://example.com/video.ogv&quot; controls&gt;
&lt;text category=&quot;CC&quot; lang=&quot;en&quot; type=&quot;text/x-srt&quot; src=&quot;caption.srt&quot;&gt;&lt;/text&gt;
&lt;text category=&quot;SUB&quot; lang=&quot;de&quot; type=&quot;application/ttaf+xml&quot; src=&quot;german.dfxp&quot;&gt;&lt;/text&gt;
&lt;text category=&quot;SUB&quot; lang=&quot;jp&quot; type=&quot;application/smil&quot; src=&quot;japanese.smil&quot;&gt;&lt;/text&gt;
&lt;text category=&quot;SUB&quot; lang=&quot;fr&quot; type=&quot;text/x-srt&quot; src=&quot;translation_webservice/fr/caption.srt&quot;&gt;&lt;/text&gt;
&lt;/video&gt;
</pre>
<p>As we can see in the above code, we would be including the text tag  that would allow us to establish the lang attribute of the subtitle language and select it from your control in your browser (the preset default language of your browser) .</p>
<p><strong>The tag <span style="font-family: mceinline;">&lt;text /&gt;</span></strong><br />
Only indicate the location of the subtitle file to load src indicating the language lang and type type of a subtitle that we carry.</p>
<p><strong>For now &#8230;</strong><br />
At the moment <a href="http://www.w3.org/2008/12/dfxp-testsuite/web-framework/HTML5_player.js" target="_blank">we can make use of SRT jQuert</a> to <a href="http://www.bluishcoder.co.nz/2008/12/srt-subtitles-with-html5-video.html" target="_blank">simulate the result with Javascript</a>.</p>
<pre class="brush: xml;">
&lt;!-- Javascript --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.srt.js&quot;&gt;&lt;/script&gt;

&lt;!-- HTML  --&gt;
&lt;video src=&quot;http://example.com/video.ogv&quot; id=&quot;video&quot; controls&gt;
&lt;div class=&quot;srt&quot;
data-video=&quot;video&quot;
data-srt=&quot;http://example.com/video.srt&quot; /&gt;
</pre>
<p>The idea is interesting when the films arrive officially to the Internet. Huh?</p>
<p class="facebook"><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/07/proposal-subtitle-for-html5-video-tag/" target="_blank"><img src="http://www.wisecodes.com/wp-content/plugins/add-to-facebook-plugin/facebook_share_icon.gif" alt="Share on Facebook" title="Share on Facebook" /></a><a href="http://www.facebook.com/share.php?u=http://www.wisecodes.com/2009/07/proposal-subtitle-for-html5-video-tag/" target="_blank" title="Share on Facebook">Share on Facebook</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.wisecodes.com/2009/07/proposal-subtitle-for-html5-video-tag/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

