Classes and Dojo are very cool

Tonight I am looking for a way to make different presentation styles in the attachment viewer.  I figure I would look into making the different presentations with JavaScript classes and with a little bit of inheritance to boot.   Unfortunately JavaScript does not support classes very well and there are a thousand ways to accomplish this, just Google it and you will see.  I of course chose Dojo to get this done because it was dead simple!

I want to have three presentation styles to start – film strip (default), thumbnails, and slide-show.

The main reason  I wanted to have this be like a class hierarchy is because the title part (where it is File: filename) needs to be re-used and eventually I will have common actions under the title like “open“, “save“, “share“.  So I need a base method in a shared class that can be inherited by the subclasses.  Using dojo.declare, the base class is the following:

dojo.declare("showStyle", null, {
 showHeader : function(id){
 },
 showAttachment : function(id, att, idx){
 },
 showTitle : function(id, att){
     var title = document.createElement("div");
     title.innerHTML = "<b>File:</b> <i>" + att.name + "</i><br>    ";
     title.innerHTML += "<small><a href=\"#\" onclick=\"openAttachment('" + att.file_url + "');return true;\" title=\"Open this file\">open</a></small> ";
     title.innerHTML += "<small><a href=\"#\" onclick=\"viewAttachment('" + att.content_url + "');return true;\" title=\"View this file\">view</a></small> ";
     title.innerHTML += "<small><a href=\"#\" onclick=\"viewAttachment('http://www.facebook.com/sharer.php?u=" + att.content_url + "');return true;\" title=\"Share this file on Facebook\">share</a>";
     title.innerHTML += "</small><br><hr>";                  

     dojo.byId(id).appendChild(title);
 },
 showFooter : function(id){
 }
});

Pretty basic right?  The two parameters in showtitle() are the DOM id the HTML will be inserted into and the “att” is the attachment JSON object. The other methods are stubbed out but I could have default implementations of them in the future.

Now for a subclass!   I won’t go into the details but each subclass will implement a showHeader(), showAttachment(), showFooter() and will be called by the framework.  Here is the reworked original code and put into the “filmStrip” subclass.   Notice the statement in red below.  This tells JavaScript to call the showTitle() method which is implemented in the base class.

dojo.declare("filmStrip", showStyle, {    
    showAttachment : function(id, att, idx){
    var codeArea = document.getElementById("code");    

    this.showTitle(id, att);

    if (att.content_url != null && att.content_url.length > 0){

        var node = document.createElement("div");
        node.setAttribute('id','attachment_' + idx);
        node.setAttribute('class','attachment');

        node.appendChild(document.createElement("hr"));
        document.getElementById(id).appendChild(node);

        var xhrArgs = {
            id : 'attachment_' + idx,
            type : att.type,
            preview_url : att.preview_url,
            url : att.content_url,
            handleAs : "text",
            preventCache: true,
            content: {
            id: 'attachment_' + idx
       },

        load : function(response, args){
           document.getElementById(this.id).innerHTML = response;

           var func = getScript(this.type);

           if (func != null)
               func(this.id, this.preview_url);
           }    
        };

     dojo.xhrGet(xhrArgs);

 }else{
     if (statusArea != null)
         statusArea.innerHTML = "<br>Item not recognized: " + att.name;            
     }

 }
});

The end result is, because of inheritance, the code just processes the object like its a base “showStyle” object.

var style = null;

if (_showStyle == 1)
      style = new slideShow();
else (_showStyle == 2)
      style = new tileSyle();
else
      style = new filmStrip();

if (style.showHeader){
      style.showHeader('attachmentArea');
}
 for (var a = 0; a < attachments.length; a++) {
      var att = attachments[a];
      if (att.type && att.type == "attachment"){
           style.showAttachment('attachmentArea', att.data, a);
      }
 }
 if (style.showFooter){
      style.showFooter('attachmentArea');
 }

CouchDB scales, it's not a slogan, its science!

Check out this impressive write-up about CouchDb.   Remember Dr. Cox at Lotusphere 2010 and the CERN project?

Metson says the learning curve for CouchDB is quite shallow. In fact, DMWM had a summer intern with some programming experience, but no experience in CouchDB, who was able to build a simple data quality evaluation application using the database. The only drawback, Metson says, is that you may need to do a lot of unlearning if you’re well versed in SQL. “The more you know Oracle, the harder it is to pick up,” he says.

Link:  Why Large Hadron Collider Scientists are Using CouchDB

The Cloud, is it a platform or just more of the same?

I have been digging into the various “cloud” offerings on the net and trying to see if there is a common ground in this space and as usual it appears the usual players are making bets on their “cloud” offerings. When you start seeing sites like SalesForce.com, LinkedIn, Facebook, or API’s like Microsofts Azure, all using different technologies to provide applications within “their cloud” it quickly shows people are off in their own camps.   I have been reading up on the DeltaCloud (Many clouds. One API. No problem) which is attempting to solve this disparity with a wrapper approach. As long as you have a particular clouds “module” installed on the server, your code can connect to and participate in that cloud. The API’s seem to be very basic out of the gate but I think the direction is worth watching.  Amazon has a huge web presence and companies like Eucalyptus have even standardized on its API’s for their own back-end so it makes me wonder if there will be camps but not many camps in the end.

Using the same application programming interfaces (APIs) that Amazon deploys for its Amazon Web Services (AWS), Eucalyptus allows users to set up their own private clouds and move workloads among internal servers, or to and from AWS. The software is available both as free, open-source code and as a paid version. – PC World

Do we need the same for collaboration?  Open Social (Many sites, one API - sound familiar?) is suppose to fix that but it isn’t totally adopted by all players either.

A common API means you have less to learn to build for multiple websites. OpenSocial is currently being developed by a broad set of members of the web community. The ultimate goal is for any social website to be able to implement the API and host 3rd party social applications. – OpenSocial

If we really want a true cloud then there is going to have to be some level of common API, data model, and interfaces across the players otherwise developers and IT will be needed for the integration points.  As more and more stuff moves to the cloud you may see more and more job openings for “SalesForce.com developer” or “OpenSocial developer” or “AWS experience a plus”.

I think this is a frontier of opportunity for any IT person or developer – which is one of the reasons I love this industry.  It is forever changing and challenging.

What is your web site worth?

Just playing around tonight I noticed a section of a site I hit that showed the “value” of their site. This intrigued me because I wondered how they could possibly know that? So I scoured the net and looked for as many services as I could to see my sites value and it clearly looks like this is not a scientific approach by no means. My highest value is $46,000 and my lowest is $98, that’s useful…


My site is worth $17,367.
How much is yours worth?



My site is worth $119.
How much is yours worth?



My blog is worth $564.54.
How much is your blog worth?

Poll: Do you or your customers develop or use applications on salesforce.com?

I have been checking out developer.force.com this week and it is a pretty extensive cloud based solution for developing, deploying, and using applications in the cloud.  I checked out their Eclipse based development videos and the development environment looks pretty comprehensive.  I would like to hear if anyone who reads this blog has any real experiences they would like to share about it.  I am also interested to hear how many of my readers have real exposure to SalesForce.com.

If you use SalesForce.com in any manner, application use, develop for, deploy on, integrate with or any of the above please take some time to post your answer below and possibly a comment on your experiences.

If you are a Lotus customer I would like to hear how you integrate your XPages, Domino or Notes applications with SalesForce.com.

Thanks in advance!

[poll id="14"]

New Attachment viewer with ODF thumbnails and JAR file support

As promised in the last post, here is a new updated widget for the attachment viewer. You can download the latest source files from the OpenNTF project.  If you want to learn how to install this into Notes 8.5.1 and above check out the video I posted to show how to do that.

Here is a summary of the support and you can also watch a video here or below:

- ODF thumbnail support added, .odp, .odt, .docx, .dotx, .docm, .dotm, .xlsx, .xlsm, .xltx, .xltm, .pptx, .pptm, .potx
- Modified Zip file to limit embedded text files to show only first 20K
- JAR file support – extended the ZIP provider to include Jar files
- New Text File support – .mf, .properties

Continue reading

Why BrowserFunction is so cool

If you are familiar with the embedded browser in the Lotus products you may or may not have heard of BrowserFunction, most likely not!  The problem is this class is not very well documented and was part of E4 and is scheduled for Eclipse 3.6.  Notes 8.5.2 does however support this SWT class so you can begin to play with it once 8.5.2 is available.

Why is this so important?  Well, just imagine, now you can completely communicate between Java and JavaScript using this.  You can use the SWT Browsers execute() or evaluate() methods to execute JavaScript from Java and now you can execute Java from JavaScript using BrowserFunction.

This implies you could potentially write all of your UI using HTML/CSS/JavaScript technologies!

The Attachment viewer is such an application, you can check out the code on OpenNTF.  I don’t use the BrowserFunction in the OpenNTF version but I have already begun to make an Lotus Notes 8.5.2 version of the plugin that has much better integration with the Notes client.  If you are writing side bar plugins and want to standardize on writing in a single technology you should check out the SWT Browser and the BrowserFunction support.

I think I hate GMail email threads and the reply history

I am not sure if I am on this island alone but when there are a lot of responses in an email thread the GMail UI gets unbearable!  I quickly get lost on where a reply is, to what section of the thread, etc.  And navigating down the thread is just cumbersome.  Unfortunately I have been using GMail for a couple of years and this has not gotten any better.  Is there a way to not thread messages in this way?  I did not see a setting.