Add “Email Subscription Form” to your blog

If are a new blogger,you may have seen an email subscrtiption form like the below one in other blogs while browsing.

It is delevered by FeedBurner.When people subscribe,they will recieve a email with your blog posts whenever your blog is updated.It is a very easy thing and make your visitors come back again and again to your blog.
So,Let’s see how to add a “Email Subscription form” like that in your blog:
1.First,Sign in to your FeedBurner account.If you don’t have a FeedBurner account yet,you can register it here
2.Click on the “My Feeds” link at the top of the page and next ,click on your blog name[look at the below screenshot]

3.Next,Click on the ‘Publicize‘ tab as shown below.

4.Select the “Email Subscriptions” option[look at the left sidebar]

5.Next, you will see like this

Click on ‘Activate
6.If you look at the sidebar now,there are a few more options under the Email Subscriptions column namely Subscription Management,Communication Preferences,Email Branding and Delivery options.Edit them according to your needs.
Now,Click on the Subscription Managemant option and copy the code they provide[see the below *screenshot*]
7.Um…………Finally,the last step
Sign in to your blogger dashboard>layout>add a page element>html/javascript
and paste the code and SAVE THE CHANGES.
That’s it!……….too long process know? No.Very simple process to do.

Creating configuration files for Flash development

The Flash 8 authoring tool sets a flag on your hard disk to identify
you as a developer to direct you to a specific developer-oriented
version of the Global Security Settings panel instead of a
user-oriented Global Security Settings panel. The flag is in the
FlashAuthor.cfg file on your hard disk, which installs automatically
when the Flash Basic 8 and Flash Professional 8 authoring tool installs.

The FlashAuthor.cfg file is located in the following approximate directories:

Windows  boot disk\Documents and Settings\<UserName>\Application Data\Macromedia\Flash Player\#Security

Macintosh /Users/<UserName>/Library/Preferences/Macromedia/Flash Player/#Security/

By default, this file is set to LocalSecurityPrompt=Author,
which means the warnings you see on your computer treat you as a Flash
developer as opposed to a user without the authoring tool installed.

You can test your local applications as an end user and see the
warning dialog boxes that an end user would encounter. To do so, open
FlashAuthor.cfg in a text editor, and change the LocalSecurityPrompt in
the FlashAuthor.cfg file to match the following:

LocalSecurityPrompt=User

You might want to provide a FlashAuthor.cfg file, with LocalSecurityPrompt set to Author,
to other developers in your design or development process or to users
who test Flash applications on their local hard disk and do not have
the Flash 8 authoring tool installed. This helps you mimic the end
user’s experience with your locally deployed content.

NOTE

 

If the FlashAuthor.cfg file is deleted, the file is recreated when you launch the Flash 8 authoring tool.

In the #Security directory on your hard disk, you can create a
FlashPlayerTrust directory where you can store unique configuration
files. Inside these files, you can specify directories or applications
to trust on your hard disk. This directory does not require
administrative access, so users without administrative permissions can
set permissions for SWF files and test applications.

If you do not specify a directory, your content might not function
as intended. Configuration files inside a FlashPlayerTrust directory
contain directory paths. The file can contain a list of several
directories, and you can append new paths to the file. Flash Player
expects one path per line in configuration files. Any line that begins
with a # punctuator (with no leading space before it) is treated as a comment.

To create a configuration file to trust a directory:

  1. Locate the #Security folder on your hard disk.
  2. Create a folder called FlashPlayerTrust inside the #Security folder.
  3. Create a new file in the FlashPlayerTrust directory using a text editor, and save it as myTrustFiles.cfg.

    You can use any unique name for your configuration file.

  4. Locate the directory where you test Flash applications.
  5. Type
    or paste each directory path (any directory path on your hard disk) on
    a new line in the file. You can paste multiple directory paths on
    separate lines. When you finish, your file looks similar to the
    following example:
    C:\Documents and Settings\<yourname>\My Documents\files\C:\Documents and Settings\<yourname>\My Documents\testapps\
  6. Save your changes to myTrustFiles.cfg.
  7. Test a document that accesses local and network files from the directory you added to the file.

    Flash applications saved in this directory can now access local files and the network.

There can be numerous directory paths saved in each configuration
file, and numerous *.cfg files saved in the FlashPlayerTrust directory.

If you create applications that install on an end user’s hard disk,
you might need to create a configuration file in FlashPlayerTrust to
specify a trusted directory for your application. You can create
configuration files inside the FlashPlayerTrust directory that specify
the location of the trusted application. See the pervious procedure for
information on this directory and creating configuration files.

NOTE

 

An installer is run by a user with administrative permission on a computer.

You should develop a unique naming scheme to avoid conflicts with
other applications that might install files in this directory. For
example, you might want to use your unique company and software name in
the filename to avoid conflicts.

TIP

 

If
you do not want to use configuration files, you could publish your
Flash applications to a separate, testing server instead of providing
clients or other developers SWF files to run on their local hard disks.

For more information on configuration files, see www.macromedia.com/go/flashauthorcfg. You can also create a unique configuration file to trust one or more directories. For detailed information on security, see www.macromedia.com/devnet/security/and www.macromedia.com/software/flashplayer/security/.

Cool Domain Names

All of these are companies that didn’t spend quite enough time considering how their online names might appear – and be misread…

Who Represents is where you can find the name of the agent that represents any celebrity. Their Web site is
www.whorepresents.com/

Experts Exchange is a knowledge base where programmers can exchange Advice and views at
www.expertsexchange.com/

Looking for a pen? Look no further than Pen Island at
www.penisland.net/

Need a therapist? Try Therapist Finder at
www.therapistfinder.com/

There’s the Italian Power Generator company,
www.powergenitalia.com/

And don’t forget the Mole Station Native Nursery in New South Wales,
www.molestationnursery.com/

The First Cumming Methodist Church Web site is
www.cummingfirst.com/

And the designers at Speed of Art await you at their wacky Web site,
www.speedofart.com/

Rapidshare Download Manager JDownloader

JDownloader is a Rapidshare Download Manager that comes with a lot of functions to make downloading files from Rapidshare and dozens other file hosting websites a breeze.

The download manager has several benefits over manually downloading files from Rapidshare. The first is that you can simply add as many download links to it which will all be stored and processed one after the other. The image verification is filled in automatically by JDownloader which means that you can keep it running in the background all the time without having to actively manage the downloads.

Download links can be automatically added by making Jdownloader observe the clipboard. It offers a reconnect feature which has to be configured, an unpacker, a password list, selecting a favored server from each hoster and much more. There are several options that need some explanation though before you can start using it.

You should first realize that JDownloader needs Java, so make sure that is installed. After unpacking the application you need to execute the file JDownloader.jar to start the installation where you select a download location for the files. Files will be automatically updated during the setup as well.

Before you start to begin downloading files you need to accept the Terms of Service for all file hosters that you want to download from. Open the options, click on Hosts in there and check the TOS of the file hosters.

The language can be set to German and English but even if you select English it looks like a mix of German and English. Not to hard to figure out stuff because the most important elements are well translated.

Free Custom Flasher Control

Flash animation is a great way to grab people’s attention among the endless sea of look-alike Web pages on the Internet. It can present useful information, as well as provide functional interactivity. Embedding Flash animation within a Web page used to be simple. However, changing standards such as XHTML and ActiveX Activation have introduced significant complications. In this article, you’ll learn all you need to know to play and embed Flash animations within ASP.NET Web pages. Indeed, the custom Flasher control detailed in this article makes Flash animation easy again.

Standards Challenges

Adobe’s Web site recommends the HTML syntax shown in Figure 1 to instantiate their Flash player and display a Flash animation. The syntax is not pretty, but it works — sort of. It certainly used to work well, but these days it has issues. For one thing, it violates the HTML standard in several different ways. Browsers tend to be forgiving, so for now it still mostly works. However, every good Web developer should strive for standards-compliant code. One of the main reasons it’s non-compliant is because the Embed tag is contained within the Object tag, which is not allowed. However, it works anyway, but only because Internet Explorer (IE) uses the Object tag and ignores the internal Embed tag, and Mozilla-based browsers do the opposite.

<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0″ width=”550″ height=”400″ id=”OBJECT1″>

<param name=”movie” value=”myFlashMovie.swf”>

<param name=”quality” value=”high”>

<param name=”bgcolor” value=”#FFFFFF”>

<embed src=”/support/flash/ts/documents/myFlashMovie.swf”

quality=”high” bgcolor=”#FFFFFF” width=”550″ height=”400″

name=”myMovieName” align=”"

type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer”>

</embed>

</object>

Figure 1. Adobe’s web site recommends this non-standard HTML to play Flash animations in a web page.

The sad fact is that there is no single HTML or XHTML-compliant syntax that will allow a Flash animation to be played across all browsers. Therefore, Web developers are pretty much forced to output one syntax for IE users and another syntax for other browser types. That is one messy detail that’s encapsulated by the custom Flasher control included with this article, so you won’t need to worry about it (see end of article for download details). Essentially, the Flasher control outputs HTML syntax similar to that shown in Figure 2 for all browsers except IE.

<object

type=’application/x-shockwave-flash’

data=’anim.swf’

width=’550′

height=’400′

play=’true’

loop=’true’

quality=’AutoHigh’

/>

Figure 2. This HTML snippet will play a Flash file in all major browsers except Internet Explorer.

Conversely, the HTML in Figure 3 shows the syntax that works for IE. If that HTML is pasted into a Web page and references a valid Flash animation it will play just fine. However, an annoying message will appear to the user at run time.

<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″

width=”550″ height=”400″ id=”myMovieName”>

<param name=”movie” value=”anim.swf”>

<param name=”quality” value=”high”>

<param name=”bgcolor” value=”#FFFFFF”>

<param name=”loop” value=”true”>

</object>

Figure 3. This HTML snippet will play a Flash file in Internet Explorer — but ActiveX Activation will be required by the user upon every page load.

ActiveX Activation

The HTML in Figure 3 worked perfectly in 2005 — ah, the good old days. It turns out that a company named Eolas Technologies apparently has a patent on it. Microsoft’s stunning loss of the related lawsuit has had major repercussions for Web developers worldwide. Microsoft was forced to deploy patches for IE that now require the user to click (or press the spacebar) to activate any embedded software, such as ActiveX controls. Now users are presented with an annoying activation message for every Web site that still uses the old syntax (see Figure 4). It should be noted that the same issue also exists when trying to embed .NET Windows forms controls.


Figure 4. ActiveX Activation is a burden all Web developers must now deal with so their users don’t have to be annoyed by messages such as this.

To circumvent this problem, the only supported solutions (at the time of this writing) involve instantiating embedded ActiveX controls from an external JavaScript file (see this article for more information).

In short, if a Web developer wants standards-compliant code that plays Flash files in all browsers without requiring users to activate embedded ActiveX controls, there are quite a few hoops to jump through. All these issues have been addressed and resolved to drag-and-drop simplicity with the custom Flasher control described here.

(advertisement)
&lt;script type=’text/javascript’ src=’http://ads.aspalliance.com/displayad.aspx?t=1&amp;amp;m=72&amp;amp;target=_parent&amp;amp;js=1′&gt;&lt;/script&gt;

Flasher!

To use the cross-browser compatible Flasher control, download the sample code and add the included Flasher.DLL to your Visual Studio 2005 toolbox. Then drag it onto any WebForm and set its FlashFile property to any valid SWF file. That’s it! Run the project and the Flash animation will play in all browsers without any of the headaches mentioned previously. Of course, you can customize it with various properties, such as those shown in Figure 5.

Unique Flasher Properties

Description

FlashFile

(Required) The URL to a Flash (.swf) file.

ns=”urn:schemas-microsoft-com:office:smarttags” prefix=”st1″ ?>Loop

(Boolean) True will loop the animation infinitely; False will stop the animation at its end.

Menu

(Boolean) True to display an extended context (right-click) menu.

PlayImmediately

(Boolean) True to play the animation instantly upon page load.

Quality

(Enum) Allows different playback qualities for display devices of varying capabilities. (AutoHigh is default)

Figure 5. The Flasher control provides several useful properties that allow versatile configuration.

The ASPX declaration looks like this:

<cc1:Flasher ID=”Flasher1″ runat=”server”

FlashFile=”~/anim.swf” BackColor=”red”

Width=”550″ Height=”400″ Loop=”false” />

If desired, JavaScript can be added to the page to let the user or page developer control the animation via client-side code. The following ASPX page code provides links to let the user start and stop the playback of the Flash animation:

<div onclick=”Flasher1.Play();”>Play</div>
<div onclick=”Flasher1.Stop();”>Stop</div>

So How Does It Work?

Flasher inherits from the System.Web.UI.Control class and extends it with custom rendering functionality and the properties shown in Figure 5. The overridden Render method is shown here:

Protected Overrides Sub Render(ByVal w As HtmlTextWriter)

If Me.DesignMode Then Exit Sub

With Context.Request.Browser

If .Browser.ToString.ToUpper = “IE” Then

RenderForIE(w)

Else

RenderForAlt(w)

End If

End With

End Sub

At design time the Render method displays only a placeholder, as directed by the first line of code. The rest of the code simply branches to one run-time rendering routine for Internet Explorer users (RenderForIE) and another rendering routine for all other Web browsers (RenderForAlt).

The utilitarian RenderForAlt method shown in Figure 6 essentially uses a StringBuilder object to concatenate a string virtually identical to Figure 2 and renders it to the browser.

Private Sub RenderForAlt(ByVal output As HtmlTextWriter)

Dim sb As StringBuilder = New StringBuilder

sb.Append(“<object type=’application/x-shockwave-flash’”)

sb.Append(” data=’”)

sb.Append(Page.ResolveClientUrl(Me.FlashFile))

sb.Append(“‘ width=’”)

sb.Append(Me.Width.ToString)

sb.Append(“‘ height=’”)

sb.Append(Me.Height.ToString)

If Not Me.BackColor.IsEmpty Then

sb.Append(“‘ bgcolor=’”)

sb.Append(Color2Hex(Me.BackColor))

End If

sb.Append(“‘ play=’”)

sb.Append(Me.PlayImmediately.ToString.ToLower)

sb.Append(“‘ loop=’”)

sb.Append(Me.Loop.ToString.ToLower)

sb.Append(“‘ quality=’”)

sb.Append(Me.Quality.ToString)

sb.Append(“‘ />”)

output.Write(sb.ToString)

End Sub

Figure 6. The RenderForAlt method takes care of the rendering tasks for all browsers except Internet Explorer.

This code is simpler than the IE rendering method because other browsers are not currently subjected to the burden of activation (and the extra code required to deal with it effectively).

Private Sub RenderForIE(ByVal output As HtmlTextWriter)

Dim sb As StringBuilder = New StringBuilder

sb.Append(“CreateIEFlash(‘”)

sb.Append(Me.ClientID + “_obj”)

sb.Append(“‘,’”)

sb.Append(Page.ResolveClientUrl(Me.FlashFile))

sb.Append(“‘,”)

sb.Append(Me.Width.ToString)

sb.Append(“,”)

sb.Append(Me.Height.ToString)

sb.Append(“,’”)

If Not Me.BackColor.IsEmpty Then

sb.Append(Color2Hex(Me.BackColor))

End If

sb.Append(“‘,”)

sb.Append(Me.PlayImmediately.ToString.ToLower)

sb.Append(“,”)

sb.Append(Me.Loop.ToString.ToLower)

sb.Append(“,’”)

sb.Append(Me.Quality.ToString)

sb.Append(“‘);”)

output.Write(“<script language=’JavaScript’>”)

output.Write(sb.ToString)

output.Write(“</script>”)

End Sub

Figure 7. The Flasher control’s Internet Explorer rendering method outputs only a single line of JavaScript, which calls the CreateIEFlash JavaScript function (shown in Figure 8).

ASP.NET 2.0 Embedded Web Resources

The RenderForIE method listed in Figure 7 essentially concatenates together this JavaScript, which is output directly into the page:

CreateIEFlash(‘Flasher’, ‘anim.swf’,

550,400,‘#FFFFFF’, true, true, ‘high’);

This code calls the custom JavaScript function (named CreateIEFlash) shown in Figure 8. The CreateIEFlash function essentially uses the document.write method to dynamically build and output HTML like that shown in Figure 3. To avoid ActiveX Activation, this function must be located in an external JavaScript file. Therefore, a reference to the external JavaScript file must be added to the page, such as this:

<script language=”javascript” src=”Flasher.js”></script>

Now, a person could try to remember to add this line to every page that uses the Flasher control, and a person could try to remember to deploy that JavaScript file to the proper location in every project that uses the Flasher control. However, it’s far more professional for the control to take care of these details itself.

// JavaScript File (flasher.js)

function CreateIEFlash(ID, Movie, Width, Height, BGC, Play, Loop , Qual)

{

var clsid=“clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″;

var codebase=“http://download.macromedia.com/pub/”;

codebase+=“shockwave/cabs/flash/swflash.cab”;

codebase+=“#version=6,0,40,0″;

document.write(‘<object classid=”‘ + clsid + ‘” ‘);

document.write(‘codebase=”‘+ codebase + ‘” ‘);

document.write(‘width=”‘+ Width + ‘” ‘);

document.write(‘height=”‘ + Height + ‘” ‘);

document.write(‘id=”‘ + ID + ‘”>’);

document.write(‘<param name=”movie” value=”‘+ Movie + ‘”‘);

document.write(‘<param name=”quality” value=”‘+Qual+‘”>’);

if (BGC.length>0)

document.write(‘<param name=”bgcolor” value=”‘+ BGC +‘>’);

document.write(‘<param name=”loop” value=”‘ + Loop + ‘”>’);

document.write(‘<param name=”play” value=”‘+ Play +‘”>’);

document.write(‘</object>’);

}

Figure 8. This external JavaScript function dynamically outputs HTML similar to Figure 3. This technique avoids ActiveX Activation hassles.

Therefore, the JavaScript file has been compiled into the control as an embedded resource. To embed a file inside an assembly, simply drag the file into the project inside Solution Explorer, then set its Build Action property to Embedded Resource. To access this resource dynamically from the Web (as is about to be done), the file must also be declared. In this case, that’s done at the top of the class file (before the class declaration) with this design-time attribute:

<Assembly: _

System.Web.UI.WebResource(“ControlFreak.flasher.js”, _

“text/javascript”)>

The new WebResource method available in ASP.NET 2.0 makes it possible for controls to manage their own resources to make deployment and maintenance easier. Its parameter accepts only the control’s namespace (ControlFreak), followed by a dot and then the filename with extension (flasher.js). The code in Figure 9 shows how the embedded JavaScript file is referenced dynamically at run time.

Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)

If Me.DesignMode Then Exit Sub

With Context.Request.Browser

If .Browser.ToString.ToUpper = “IE” Then

‘ Define the resource name and type.

Dim rstype As Type = Me.GetType

Dim rsname As String = “ControlFreak.flasher.js”

‘ Register the client resource with the page.

Dim cs As ClientScriptManager = Page.ClientScript

cs.RegisterClientScriptResource(rstype, rsname)

End If

End With

End Sub

Figure 9. ASP.NET 2.0 includes the capability for Web controls to manage their own resources, which can greatly simplify deployment and maintenance.

Using this technique, the control’s JavaScript file doesn’t need to be located in the Web application’s directory structure at all; therefore, you can’t forget to put it there or accidentally put it in the wrong place. Instead, it’s automatically retrieved from the control at run time. The RegisterClientScriptResource function makes this happen by building a URL that references the embedded resource through an automatically managed HTTP Handler. The resulting HTML script tag looks like this:

<script src=”/FlasherTest/WebResource.axd?d=t0e7oX8lfjsk…” type=”text/javascript”></script>

Fun with Hexadecimals

Adobe’s Flash control requires its background color be set via RGB Hexadecimal values only. Color names are not supported. Therefore, I patched together a utility function to translate the Flasher control’s BackgroundColor property to just such a Hexadecimal value. This function is shown in Figure 10. You may have noticed it being called from the RenderForIE and RenderForAlt methods.

Public Function Color2Hex(ByVal clr As Color) As String

Dim HexR, HexB, HexG As String

Try

‘Get Red Hex

HexR = Hex(clr.R)

If Len(HexR) < 2 Then HexR = “0″ & HexR

‘Get Green Hex

HexG = Hex(clr.G)

If Len(HexG) < 2 Then HexG = “0″ & HexG

‘Get Blue Hex

HexB = Hex(clr.B)

If Len(HexB) < 2 Then HexB = “0″ & HexB

Catch ex As Exception

Return “”

End Try

Return “#” & HexR & HexG & HexB ‘Output complete hex

End Function

Figure 10. The Color2Hex function converts a color object into an RGB Hexadecimal value because that’s what Adobe’s Flash player requires.

This function extracts the Red, Green, and Blue (RGB) values from the Color object, then converts them in turn to hexadecimal values. Then the final line recombines them into a familiar string color value, such as this:

#FF0099

Wrap Up

Using the ASP.NET 2.0 WebResources techniques (shown here) and the GetWebResources method (not shown here), you can easily embed scripts, images, icons, strings, and other items on which a Web control might depend. Web controls can now control their own dependencies, thereby easing deployment and maintenance chores (see Figure 11).


Figure 11. The Flasher control plays Flash animations consistently across all major browsers so you don’t have to worry about development annoyances, such as ActiveX Activation or varying browser support.

The Flasher control makes playing Flash animations easy again. Now you can generate standards-compliant output that works in all browsers, and avoid user annoyances such as ActiveX Activation.

The source code for the Flasher control is available for download here.

JavaScript Stopwatch

The objective

I know there are a lot of examples on the web on how to achieve stopwatch type functionality, but none seemed to be separated from the UI, so I decided to write my own object that could be included into any page without being tied into the user interface.

The goal

To create a JavaScript stopwatch that will work similar to the .NET StopWatch class. The object should not depend on any UI element, and should be added as easily as possible to any web page.

The code

Constructor

I first created the JavaScript object as follows:

function StopWatch(){
}//yes this is how to define a class in JavaScript 

Variables

The next step was to sort out what variables would be needed to accomplish our task. We know we need timestamps for when we start and when we stop, and a state variable to determine if we are currently running.

function StopWatch(){

  var startTime = null;
  var stopTime = null;
  var running = false;
  ....
}

Methods

Now, the methods; we know we will need methods to start, stop, and set the duration. I know some implementations of stopwatches containing reset methods, but in this implementation, let’s infer the call to start to also be the reset.

TimeStamp method

I needed a private method in my object to return the timestamp for a given point in time. The getTime function of a Date object returns the number of milliseconds since Jan 1, 1970.

function getTime(){
  var day = new Date();
  return day.getTime();
}

Start method

The call to start should verify that we are not already running, and should set the startTime variable.

this.start = function(){ 

if (running == true)
    return;
else if (startTime != null)
    stopTime = null; 

running = true;
startTime = getTime();

}

Stop method

The call to stop should verify we are currently running, and should set the stopTime variable.

this.stop = function(){ 

if (running == false)
    return;    

stopTime = getTime();
running = false; 

}

Duration method

This method should determine we have both a start and stop timestamp, and return the duration between the two, in terms of seconds.

this.duration = function(){ 

if(startTime == null || stopTime == null)
   return 'Undefined';
else
   return (stopTime - startTime) / 1000;

}

Using the stopwatch object

To use the object, you need to include the StopWatch.js file or its logic into your own .js file, and create an instance of a StopWatch as follows:

var _StopWatch = new StopWatch();

To start the stopwatch, you simply call Start.

_StopWatch.start();

To stop the stopwatch, you simply call Stop.

_StopWatch.stop();

To get the duration, you simply call Duration.

alert(_StopWatch.duration());
//example return: 3.567(seconds)

How to Close Child Windows When the Parent Window Closes

The Motivation

When moving an application from Windows to web, I noticed that certain functionality available only in a Windows Form is expected to be carried over to the web form. Unfortunately, sometimes, achieving the said functionality can be a bit more difficult than expected.

The Objective

Being object oriented in nature, I wanted a drop in solution on the client side to achieve closing child windows. Doing a bit of research told me that the call to window.open would return a window object that I could then (at a later time) call close on. The question to be answered was how to store each window object upon opening, and how to detect the browser closing in order to close the child windows.

Note: There are more than a few articles out there on creating objects in JavaScript, and it is beyond the scope of this article.

The Code

Persisting Window Handles

The first thing, persist the window object returned by the open function call. I achieved this by storing it as a private Array within my object.

function windowController(){
  //Note: The absence of “this” indicates private
  var loadedWindows = new Array()
  …..
} //Note: Yes, in JavaScript an object
  // is declared similar to a function.

Encapsulate window.open

Now that I have a nifty array, I need a public method that would wrap the window.open function to capture the returned object and add to my array.

this.popUpWindow = function(wndUrl, wndName, wndWidth, wndHeight){
var windObj = null;
try
{
  //set default width 
  if(typeof wndWidth == 'undefined') wndWidth=500;
  //set default height
  if(typeof wndHeight == 'undefined') wndHeight=250;
  windObj = window.open(wndUrl,
    //misc options to open a window, again mostly optional 
    wndName, 'toolbar=0,menubar=0,resizable=0,location=0,
    directories=0,width='+wndWidth+',height='+wndHeight);
  windObj.registerID = wndName; //this is the key to the window
  loadedWindows[loadedWindows.length] = windObj;
  //add the window to our collection.
}
catch(ex) {
  alert('WindowController.popUpWindow: ' +
        'Exception occured, message: ' + ex.message)
} //oops, looks like we are cross domain scripting.
return windObj;
}

Further Enhance Encapsulation

Since I am wrapping window.open, I decided to only allow a single instance of each handle ID to be opened, by checking the ID against each window handle already loaded, and if it exists, I simply call focus (this is similar to what is expected from Windows Forms).

this.popUpWindow = function(wndUrl, wndName, wndWidth, wndHeight){
  var windObj = null;
  try{
    windObj = findWindow(wndName);
    if (windObj != null)
    {
      windObj.focus();
    }
    else
    {
     ......
    }

where the findWindow function simply iterates the array, and returns null if not found.

function findWindow(winHandle){
  for (var i=0; i< loadedWindows.length; i++){
  if (loadedWindows[i].closed == true){
    loadedWindows.splice(i,1);
    i--;
  }
  else{
    if (loadedWindows[i].registerID == winHandle)
      return loadedWindows[i];
    }
  }
  return null;
}

Pulling it all Together

Finally, I needed a way to know when the browser was closing in order to close all my child windows. Of course, IE, compared to other browsers, has different ways to register to events, so I created a generic method to achieve this.

function WireEvent(elem,target,func){
  if (elem.addEventListener)
    elem.addEventListener(target, func, false); //FF
  else if (elem.attachEvent)
    elem.attachEvent(target, func); //IE
  }
  WireEvent(window,'onunload',_windowController.closeAllWindows);

where the onunload function is handled as follows:

this.closeAllWindows = function(){
  for(var x = 0; x < loadedWindows.length; x++){
    try{
      loadedWindows[x].close();
    }
    catch(err) {
      alert('WindowController.closeAllWindows: ' +
            'Exception occured, message: ' + err.message)
    }
  } //oops, cross domain scripting or window already closed etc...
}

Looks like all is in place, the last thing I needed was the ability to init the object so it would be available from code, so I added the call at the top of the js file, as follows….

var _windowController = new windowController();

Using the Object

Now, if the file is included, we have access to the window controller, so as long as all opened child windows are done through this object, we can be certain they will close upon browser exit as long as we are not cross domain.

_windowController.popUpWindow('ChildForm.aspx', 'ChildForm');

WordPress post through email

If you know this feature already , skip this article. But i have to ask a single question at the end of this section .

For wordpress version less than 2.3 , Go to Optionswriting, and  for greater than 2.3, Go to settings > writing

What you have to do is create an email account with pop3 support

You can see the heading “Post via e-mail” there.

Enter your email server (by replacing mail.example.com)

Enter your pop3 port. (110 by default)

Enter your email login and password.

Choose a category to for the email entry posts

Finally Press update option Button

What you have done above is only the settings. For grabbing or pulling the content from email, you need to call/trigger an url.

That url is: http://yourblogdomain/wordpressinstalldir/wp-mail.php

Either you can call it manually. Or you can set up a cron job for that url by call the url using wget or like functions

Another simple mechanism to call this email trigger is use a hidden iframe in your blog template. (anywhere)

<iframe width=”0″ height=”0″  style=”display:none”  src=”http://yourblogdomain/wordpressinstalldir/wp-mail.php“></iframe>

The problem with this email posting is , it strips all the html tags before entering into wordpress database.

The is no way to find the attachments from an email.

So I decided to start a wordpress plugin which does the above missing properties. If there is any ‘working’ plugin available, please let me know, so that  I can avoid the re-inventing of wheel .

Thanks,

Thomas K Joseph

LogicManse

LogicManse

LogicManse is a Canadian based R & D company that provides innovative technology solutions for Entrepreneurs worldwide.

Starting from Prototype Development to Revenue Model integration, LogicManse (www.logicmanse.com) has a complete technology package for Entrepreneurs who wants to establish revenue generating global internet brands. LogicManse assist entrepreneurs by providing FREE consulting on the business & Revenue models and also gets involved with active participation for great ideas.

LogicManse is entirely different from traditional web I Mob development companies. We stand firmly for Entrepreneurs who wish to transform an Idea into a live Prototype that speaks volumes to investors. We enhance ideas to create sustainable prototypes for a nominal fee and work along with the Entrepreneur as a technology partner.

LogicManse address the challenges that Entrepreneurs face today: changing ideas into prototypes for securing funds from investors. LogicManse enable the Entrepreneur to start working from Day 1 by allocating the right team for the concepts and working in the true startup spirit.

LogicManse is an abode of technology with the right blend of business and innovation. We believe in the business revolution through SMBs and are eager in the success of every SMB/ startup we work with. Our clientele includes small webstores to the next generation search engines. The verticals range from e-commerce to social networking, Wireless Apps to Streaming networks.

For more details send an email to info@logicmanse.com

Create a Blogger Tag Cloud Widget

Installation:

If you already have a Labels page element installed, skip to step 2.

Step 1: Install the Labels page element by browsing to your template settings:

Click “Add a Page Element” in the column you wish:

Then find the Labels page element and click “Add to Blog”:

Step 2: Replace the Labels page element widget code with the custom tag cloud code above.

First navigate to your templates source under your template settings:

Then check off “Expand Widget Templates”:

Search for the Label page element you are replacing by searching for widget code. It will look something like this

<b:widget id=’Label1′ locked=’false’ title=’Tags’ type=’Label’>

but id and title maybe different, so use your browser’s search tool and look for type=’Label’.

Delete the Label widget code from the start to the end marked by

</b:widget>

and replace with the custom Tag Cloud code from below..

Code:

<b:widget id='TagCloud' locked='false' title='Tags' type='Label'>
<b:includable id='main'>
<b:if cond='data:title'>
  <h2><data:title/></h2>
</b:if>
<div class='widget-content' style='text-align: justify;'>
 <script type="text/javascript">
/*
Simple Blogger Tag Cloud Widget
by Raymond May Jr.
http://www.compender.com
Released to the Public Domain
*/
//Variables:
var max = 150; //max css size (in percent)
var min = 50; //min css size (...)
var showCount = 1;  // show counts? 1 for yes
var minCount = 1;  // what is the minimum count for a Tag to be shown? 1 for all.

//Begin code:
var range = max - min;

//Build label Array
var labels = new Array();
 <b:loop values='data:labels' var='label'>
   labels.push("<data:label.name/>");
 </b:loop>

//URLs
var urls = new Array();
 <b:loop values='data:labels' var='label'>
   urls.push("<data:label.url/>");
 </b:loop>

//Counts
var counts = new Array();
 <b:loop values='data:labels' var='label'>
   counts.push("<data:label.count/>");
 </b:loop>

//Number sort funtion (high to low)
function sortNumber(a, b)
{
 return b - a;
}

//Make an independant copy of counts for sorting
var sorted = counts.slice();

//Find the largest tag count
var most = sorted.sort(sortNumber)[0];

//Begin HTML output
for (x in labels)
{
 if(x != "peek" &amp;&amp; x != "forEach" &amp;&amp; counts[x] >= minCount)
 {
  //Calculate textSize
  var textSize = min + Math.floor((counts[x]/most) * range);
  //Show counts?
  if(showCount == 1)
  {
   var count = "(" + counts[x] + ")";
  }else{
   var count = "";
  }
  //Output
  document.write("<span style='font-size:" + textSize + "%'><a href='" + urls[x] + "'>" + labels[x] + count + "</a></span> " );
 }
}
</script>
</div>
</b:includable>
</b:widget>