<?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>To Hell in a Handbasket &#187; javascript</title>
	<atom:link href="http://ericsilva.org/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericsilva.org</link>
	<description>General Views, Opinions, and Observations in the World Around Me by Eric Silva</description>
	<lastBuildDate>Mon, 05 Sep 2011 13:48:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Simple Calendar Control for Web Application</title>
		<link>http://ericsilva.org/2010/03/19/simple-calendar-control-for-web-application/</link>
		<comments>http://ericsilva.org/2010/03/19/simple-calendar-control-for-web-application/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 19:07:08 +0000</pubDate>
		<dc:creator>Eric Silva</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[InterWebNet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Calendar]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://ericsilva.org/?p=379</guid>
		<description><![CDATA[I originally did this back in 2007, but did not want to lose the content, so I decided to put it up here. I found a robust and relatively simple calendar control to use for web UIs. It can use a pop-up window or a floating &#60;div&#62; tag. I prefer the latter as it makes [...]]]></description>
			<content:encoded><![CDATA[<p>I originally did this back in 2007, but did not want to lose the content, so I decided to put it up here.</p>
<p>I found a robust and relatively simple calendar control to use for web UIs.  It can use a pop-up window or a floating <code>&lt;div&gt;</code> tag.  I prefer the latter as it makes the page look good and avoids a pop-up.</p>
<p>To use the control simply put the <a href='http://ericsilva.org/wp-content/uploads/2010/03/CalendarPopup.js'>CalendarPopup.js</a> file in your application&#8217;s &#8220;scripts&#8221; directory and be sure to include it in your JSP. <em>(I used this in a Java app, but you can apply it to any language.)</em></p>
<p>Download the <a href="http://ericsilva.org/wp-content/uploads/2010/03/cal.gif"><img src="http://ericsilva.org/wp-content/uploads/2010/03/cal.gif" alt="" title="cal.gif" width="16" height="16" /></a> and put it in your images directory.</p>
<p>Add the following lines to your application&#8217;s JavaScript file (or include on the same page if you don&#8217;t have an external JS file):</p>
<pre class="brush: jscript; title: ; notranslate">
// Set up Calendar control
var calObj = new CalendarPopup(&quot;calDiv&quot;);
calObj.showNavigationDropdowns();
calObj.setMonthNames('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');

// Handle the Calendar control
function doCalendar(destObjId, srcObj) {
    calObj.select(document.getElementById(destObjId),srcObj.id,'dd-MMM-yyyy');
}
</pre>
<p>Then add the following lines to your JSP:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script&gt;document.write(getCalendarStyles());&lt;/script&gt;
</pre>
<p>In your JSP, add the following HTML code where you want your date field and calendar control:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;input id=&quot;dateField&quot; style=&quot;width: auto;&quot; maxlength=&quot;11&quot; name=&quot;actualDate&quot; size=&quot;25&quot; type=&quot;text&quot; /&gt;
&lt;img id=&quot;imgCal&quot; onclick=&quot;doCalendar('dateField',this);return false;&quot; src=&quot;cal.gif&quot; border=&quot;0&quot; alt=&quot;&quot; /&gt;
</pre>
<p>That&#8217;s it!</p>
<p>In order to workaround IE 6&#8242;s inability to recognize the z-index attribute on the  tag, I made some modifications to the original JavaScript code. You will need to pass the an ID value to be used for the hidden  that will overlay the  box. </p>
<pre class="brush: jscript; title: ; notranslate">
var calObj = new CalendarPopup(&quot;calDiv&quot;, &quot;calFrame&quot;);
</pre>
<p>You will also need to specify the following styles in a stylesheet.  The ID values in the stylesheet must match the names of your DIV and IFRAME IDs on your page. </p>
<pre class="brush: css; title: ; notranslate">
div#calDiv {
    position:absolute; visibility:hidden;
    background-color:white;
    layer-background-color:white;
}
.select-free {
    position:absolute; z-index:10;/*any value*/
    overflow:hidden;/*must have*/
    width:152px;/*do not change value for calendar control */;
}
.select-free iframe#calFrame {
    display:none;/*sorry for IE5*/
    display:block;/*sorry for IE5*/
    position:absolute;/*must have*/
    top:0;/*must have*/
    left:0;/*must have*/
    z-index:-1;/*must have*/
    filter:mask();/*must have*/
    width:3000px;/*must have for any big value*/
    height:3000px/*must have for any big value*/;
}
</pre>
<p>Your JSP now needs the following line: </p>
<pre class="brush: xml; title: ; notranslate">
&lt;div id=&quot;calDiv&quot; class=&quot;select-free&quot;&gt;&lt;/div&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ericsilva.org/2010/03/19/simple-calendar-control-for-web-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome Frame</title>
		<link>http://ericsilva.org/2009/11/25/google-chrome-frame/</link>
		<comments>http://ericsilva.org/2009/11/25/google-chrome-frame/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 14:10:19 +0000</pubDate>
		<dc:creator>Eric Silva</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[InterWebNet]]></category>
		<category><![CDATA[Observations]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[LinkedIn]]></category>

		<guid isPermaLink="false">http://ericsilva.org/2009/11/25/google-chrome-frame/</guid>
		<description><![CDATA[I installed Google Chrome Frame about a month ago, and I am very impressed with how responsive and quick Internet Explorer is with JavaScript intensive web pages now.&#160; If you use a lot of JavaScript intensive websites, e.g., Facebook, Gmail, Google Maps, Google Calendar, etc., you will notice a significant improvement in performance when using [...]]]></description>
			<content:encoded><![CDATA[<p>I installed <a href="http://code.google.com/chrome/chromeframe/" target="_blank">Google Chrome Frame</a> about a month ago, and I am very impressed with how responsive and quick Internet Explorer is with JavaScript intensive web pages now.&#160; If you use a lot of JavaScript intensive websites, e.g., Facebook, Gmail, Google Maps, Google Calendar, etc., you will notice a significant improvement in performance when using IE with the Chome plug-in.</p>
<p>I was also interested to find out that the new <a href="http://wave.google.com/help/wave/about.html" target="_blank">Google Wave</a> application only works with IE if you have the plug-in installed.</p>
<p>The plug-in works in Internet Explorer 6, 7, and 8, and requires you to have Windows XP, Vista, or Windows 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericsilva.org/2009/11/25/google-chrome-frame/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Bulk File Move Script</title>
		<link>http://ericsilva.org/2009/10/13/windows-bulk-file-move-script/</link>
		<comments>http://ericsilva.org/2009/10/13/windows-bulk-file-move-script/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 16:37:41 +0000</pubDate>
		<dc:creator>Eric Silva</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[wsh]]></category>

		<guid isPermaLink="false">http://ericsilva.org/?p=316</guid>
		<description><![CDATA[We have some applications that leave files sitting in a folder location out on some file server.  Eventually the disk space gets used up, or Windows starts choking because there are too many files in a directory, etc.  To delete the &#8216;old&#8217; files, a support technician will try to connect to the file share, sort [...]]]></description>
			<content:encoded><![CDATA[<p>We have some applications that leave files sitting in a folder location out on some file server.  Eventually the disk space gets used up, or Windows starts choking because there are too many files in a directory, etc.  To delete the &#8216;old&#8217; files, a support technician will try to connect to the file share, sort the files by date, and delete the files within a date range, e.g., older than a year.</p>
<p><span style="background-color: #ffffff;">What can happen, especially on a Window server, is that the operating system will attempt to load all the file information into memory, so that you can see it, and then tell it to sort all those files by date, which in turn, increases the time and memory needed by the OS to accomplish this.  If the file size/quantity is too great, the problem that caused you to want to clean up the disk space will reappear and choke Windows once more.</span></p>
<p><span style="background-color: #ffffff;">After going through this more than twice, I decided to write a JavaScript and execute it using the <a href="http://en.wikipedia.org/wiki/Windows_Script_Host" target="_blank">Windows Scripting Host (WSH)</a>.  The script performs very well and was able to iterate through a directory of 700,000+ files in a matter of an hour.  This was including the log statements from being enabled.  Disabling the &#8216;Echo&#8217; statements may increase performance.</span></p>
<p><span style="background-color: #ffffff;">Here is the script:</span></p>
<pre class="brush: jscript; gutter: true; title: ; toolbar: true; notranslate">
var fso = new ActiveXObject('Scripting.FileSystemObject');
var argArray = new Array(WScript.Arguments.Named(&quot;src&quot;), WScript.Arguments.Named(&quot;s&quot;), &quot;.&quot;);
var inSrcDirName = coalesceArray(argArray);

argArray = new Array(WScript.Arguments.Named(&quot;dest&quot;), WScript.Arguments.Named(&quot;d&quot;));
var archiveDir = coalesceArray(argArray);

argArray = new Array(WScript.Arguments.Named(&quot;year&quot;), WScript.Arguments.Named(&quot;y&quot;));
var beforeYear = coalesceArray(argArray);

if (archiveDir != null) {
	if (!fso.FolderExists(archiveDir)) {
		fso.CreateFolder(archiveDir);
	} else {
		fso.CreateFolder(archiveDir + &quot;1&quot;);
	}
}

var gfldr = fso.GetFolder(inSrcDirName);

ArchiveFiles(gfldr);

function ArchiveFiles(fldr) {
	var i, bias;

	WScript.Echo(&quot;Loading all files...&quot;);
	for (files = new Enumerator(fldr.files); !files.atEnd(); files.moveNext()) {
		f = files.item();
		dt = new Date(f.DateCreated);
		bias = dt.getTimezoneOffset();

		dt.setMinutes(dt.getMinutes() - bias);

		fileYear = dt.getFullYear();
		//WScript.Echo(f.Name + &quot;:&quot; + fileYear);
		if (beforeYear &gt; fileYear) {
			WScript.Echo(&quot;Moving \&quot;&quot; + f.Name + &quot;\&quot; with year &quot; + fileYear + &quot; to &quot; + archiveDir);
			f.Move(archiveDir+&quot;\\&quot; + f.Name)
		} else {
			WScript.Echo(&quot;Skipping \&quot;&quot; + f.Name + &quot;\&quot; with year &quot; + fileYear);
		}
	}
	WScript.Echo(&quot;Done loading files.&quot;);

}

function coalesceArray(arr) {
	var i;
	for (i = 0; i &lt; arr.length; i++) {
		if (arr[i] != null) {
			return arr[i];
		}
	}
	return null;
}
</pre>
<p><span style="background-color: #ffffff;">Executing the script is performed by passing a source directory, destination directory (to move the files to), and a year to mark the year that all files must be equal to or younger than to not be moved as parameters.</span></p>
<p><span style="background-color: #ffffff;">Example:</span></p>
<pre class="brush: plain; gutter: false; light: true; title: ; toolbar: false; notranslate">cscript movefiles.js /s:c:\myapp\data /d:c:\backup\archive_2006 /y:2007</pre>
<p><span style="background-color: #ffffff;">This will move all files from the c:\myapp\data folder that were created before January 1, 2007 to the c:\backup\archive_2006 folder.  The script can be easily modified to use the &#8216;modified&#8217; or &#8216;accessed&#8217; date instead.</span></p>
<p><span style="background-color: #ffffff;">Hope this helps someone else as much as it helped me.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://ericsilva.org/2009/10/13/windows-bulk-file-move-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

