Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

jQuery bounding region plugin

While working on some javascript network visualization software I am coding for work I came up with a jQuery plugin function that calculates the bounding box around the query using offset() and width() and height() returning an object that has left,top,bottom, and right members.
(function() {
   jQuery.fn['bounds'] = function () {
     var bounds = {  left: Number.POSITIVE_INFINITY, 
                      top: Number.POSITIVE_INFINITY,
                    right: Number.NEGATIVE_INFINITY, 
                   bottom: Number.NEGATIVE_INFINITY};

     this.each(function (i,el) {
                 var elQ = $(el);
                 var off = elQ.offset();
                 off.right = off.left + $(elQ).width();
                 off.bottom = off.top + $(elQ).height();

                 if (off.left < bounds.left)
                   bounds.left = off.left;

                 if (off.top < bounds.top)
                   bounds.top = off.top;

                 if (off.right > bounds.right)
                   bounds.right = off.right;

                 if (off.bottom > bounds.bottom)
                   bounds.bottom = off.bottom;

               });
     return bounds;
   }
 })();

Building internal webapps

I couple months ago I picked up Enterprise Integration Patterns. It was a lot better then I thought it would be considering it contained the word enterprise in the title. The premise of the book is that using message queues/buses allows for easier integration of applications even spanning organizational boundaries.

This got me thinking about web services exposed through REST/http. One of the nice benefits of http is that it has clients in almost every language and environment. While exposing services and tools with a http interface can solve more than the immediate problem of feeding your ajax app it can also allow a larger set of people to leverage your service.

It seems like the smartest thing any organization that has lots of internal services could do would be to make a directory of such services maybe even use RDF. Of course the problem is the reliability of these services may vary depending on the needs of the original author and the maintainer. Requiring the author of every web service to make sure their service is up 24/7 might not be appropriate.