Browsing articles tagged with " Cdn"

Creating a lightbox using JQuery UI Dialog

Oct 13, 2011   //   by David Bates   //   All Post, Development, Hacking, Software, Web  //  2 Comments

$(“”"#I”").Love(“”"JQuery”");

I love JQuery and I love JQuery UI even more but what I love most about the combination of the two is that they are cross browser compatible, delivered over a CDN network, and open source. This means that I can use anything I build on top of these two very powerful platforms in any website I wish, including the enterprise ones.

I was recently tasked with building a lightbox element that would allow me to showcase Vimeo videos (or any other content) in a cross browser CDN enabled way. At first I scoured the web looking for the best jquery lightbox plugin. I tried fancybox, shadowbox, thickbox, slimbox, facebox, other younameit-box plugins but they all either catered to one type of content, failed in the cross browser arena, or had unknown or grey licensing.

On day two of my growing frustration a friend of mine suggested I look at JQuery UI and specifically the Dialog method. So I did and was instantly hooked, and while it didn’t provide all of the functionality you need from a lightbox it came pretty darn close. So I began hacking away until I got down to a pretty comprehensive lightbox solution for video and then wrote a little helper function to populate the content area on the fly and set the title. What follows is how to do that:

Step one: includes

So first you need to include JQuery and JQuery UI within your page. The easiest way to do this is use Google’s CDN by placing the following two lines in your head.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>

You will also need to include a JQuery UI theme you can use the starter theme hosted on Google’s CDN too!

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-darkness/jquery-ui.cs"
type="text/css" rel="Stylesheet" />

Again that needs to be placed in your head.

Step two: create a div

We need to create a div that will not only hold our dialog but also most of the embed code for the video’s we will want to play.
I would suggest adding this code near the footer of the page since it will load an iframe.

<div id="videoPlayerDiv">
<iframe id="theVideo" src="" width="640" height="360" frameborder="0" webkitallowfullscreen="" allowfullscreen=""></iframe>
</div>

Step three .dialog()

Now you need some JQuery magic on page load as well as creating the helper function
<script type="text/jscript">
$(document).ready(function () {
$('#videoPlayerDiv').dialog({ autoOpen: false, modal: true, title: "RFMD Video", width: 664, resizable: false });
$("#videoPlayerDiv").bind("dialogclose", function (event, ui) {
$('#theVideo').attr('src', '');
});

});
function SetVideo(source, title) {
$('#theVideo').attr('src', source);
$('#videoPlayerDiv').dialog("option", "title", title);
$('#videoPlayerDiv').dialog('open');
$('.ui-widget-overlay').click(function () { $('#videoPlayerDiv').dialog('close'); });
};
</script>

This can go in your header or wherever you might have already put the $(document).ready clause.

Final step: Call your helper function

So now all you need to do is call the helper function and pass it the src url for the video and the title

<a href="#" onclick="javascript:SetVideo('http://player.vimeo.com/video/18888136?title=0&byline=0&portrait=0&color=af0522"&autoplay=1', 'Courtesy Vimeo User 1024');return false;">Video</a>

You can prolly tell I use asp.net from the javascript surrounds and return false. If you don’t use .net you don’t need this.

Demo

Click to open demo

Bing Reported as Running on Linux

Aug 20, 2009   //   by David Bates   //   Uncategorized  //  43 Comments


When Frank Sandoval came to me with a screen shot proposing that Bing.com actually ran on Linux I was skeptical to say the least. No way Microsoft would do that… and why wouldn’t this be main news? I asked of him.

While I don’t know the why’s or what’s it is reported by netcraft.com that the ip addresses used to resolve http://www.bing.com is running on Linux OS. Screenshot, Live Page

Now, in Microsoft’s defense I cannot find another source to be sure as they use p3p in their html headers.
So the Linux OS could be netcraft reporting a load ballancer or who knows what… still you think if Microsoft was using one of it’s own technologies it would proudly be displayed on the home page.

Discuss below:
David Bates

@Rexm pointed out that StackOverflow had this question posted as well. Link

Another Note: It has been said to me many times that this probably Bing’s CDN and not Bing’s actual webserver. I wrote this post because if you type Bing.com into netcraft it says Linux is the server type. I do agree with many and even said that it is more than likely to be load balancers than bing itself… It turns out that it could be Akamai that has the linux servers than Bing being hosted on Linux servers… It should also be noted that Akamai is the worlds largest CDN, but I still find it interesting that Microsoft would have anything Linux related in their server platform even if it is the CDN.