<?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>Well, at least we got the duck. &#187; javascript</title>
	<atom:link href="http://ingol.nl/blog/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://ingol.nl/blog</link>
	<description></description>
	<lastBuildDate>Fri, 27 Jan 2012 09:48:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Show the LIVE Status from an OWN3D.TV Livestream with a jQuery Plugin</title>
		<link>http://ingol.nl/blog/2011/06/16/show-the-live-status-from-an-own3d-tv-livestream-with-a-jquery-plugin/</link>
		<comments>http://ingol.nl/blog/2011/06/16/show-the-live-status-from-an-own3d-tv-livestream-with-a-jquery-plugin/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 21:19:23 +0000</pubDate>
		<dc:creator>Onno</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[livestream]]></category>
		<category><![CDATA[own3d]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[zendframework]]></category>

		<guid isPermaLink="false">http://ingol.nl/blog/?p=744</guid>
		<description><![CDATA[Demo
jQuery plug-in source at BitBucket
Examples of how to use the plug-in.
The jQuery OWN3D Plug-in Code.
A simple PHP &#8211; Zend Framework script to enable a cross domain request to the OWN3D API (the full project contains two, one for the live status and one for the channel information).
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ingol.nl/own3d/" target="_blank" style="font-size: 20px">Demo</a><br />
jQuery plug-in <a href="https://bitbucket.org/orlissenberg/jquery-own3d-plugin/src" target="_blank">source at BitBucket</a></p>
<p>Examples of how to use the plug-in.</p>
<pre class="brush: jscript; title: ; notranslate">
// global configuration options
$.own3d.liveurl = 'http://ingol.nl/own3d/live.php';
$.own3d.channelurl = 'http://ingol.nl/own3d/channel.php';

// A single stream
$('#own3d-cowclan').own3d({liveid:'1213', title:'COWCLAN'});
// A single stream with HD
$('#own3d-rebootgpf').own3d({liveid:'1208', title:'REBOOTGPF', hd:true});
// A single stream without title
$('#own3d-1208').own3d({liveid:'1208', hd:true, embed:true, channelid: 'orlissenberg'});
// A single channel, live streams only
$('#channel').own3d({channelid:'clgame', hd:true, embed:true});
// A single channel, live and offline streams
$('#channel-all').own3d({channelid:'clgame', hd:true, showall:true});
</pre>
<p>The jQuery OWN3D Plug-in Code.</p>
<pre class="brush: jscript; title: ; notranslate">
(function($){
  $.own3d = {
    liveurl : 'live.php',
    channelurl : 'channel.php'
  };

  $.fn.own3d = function(options) {
    return this.each(function(){
      var self = $(this);
      self.data('liveid', options.liveid);

      if (options &amp;amp;amp;&amp;amp;amp; options.liveid) {
        $.ajax({
            type: &amp;amp;quot;GET&amp;amp;quot;,
            async: true,
            data: {live_id:options.liveid},
            url: $.own3d.liveurl,
            dataType: &amp;amp;quot;jsonp&amp;amp;quot;,
            success: function(data){
              var title = (options.title) ? options.title : 'OWN3D CHANNEL ['+options.liveid+']';
              var liveclass = (options.hd) ? 'own3d-live-hd' : 'own3d-live';

              self.empty();
              self.addClass('own3d');

              var link = $('&amp;amp;lt;a/&amp;amp;gt;')
                  .attr('href','http://www.own3d.tv/live/'+options.liveid)
                  .attr('target','_blank');

              if (data.isLive &amp;amp;amp;&amp;amp;amp; data.isLive == 'true') {
                link.html(title+' - LIVE (viewers: '+data.liveViewers+' - duration: '+Math.round(parseInt(data.liveDuration) / 60)+' minutes)');

                if ((options.showthumbnail || options.embed) &amp;amp;amp;&amp;amp;amp; options.channelid) {
                  $.ajax({
                      type: &amp;amp;quot;GET&amp;amp;quot;,
                      async: true,
                      data: {channel_id : options.channelid, stream_guid : 'http://www.own3d.tv/live/'+options.liveid},
                      url: $.own3d.channelurl,
                      dataType: &amp;amp;quot;jsonp&amp;amp;quot;,
                      success: function(data){
                        if (options.showthumbnail &amp;amp;amp;&amp;amp;amp; data.thumbnail) {
                          var table = $('&amp;amp;lt;table/&amp;amp;gt;');

                          var status = $('&amp;amp;lt;td/&amp;amp;gt;').append($('&amp;amp;lt;div/&amp;amp;gt;').addClass(liveclass).append(link));
                          table.append($('&amp;amp;lt;tr/&amp;amp;gt;').append(status));

                          var thumbnail = $('&amp;amp;lt;td/&amp;amp;gt;').append($('&amp;amp;lt;img/&amp;amp;gt;').attr('src',data.thumbnail));
                          table.append($('&amp;amp;lt;tr/&amp;amp;gt;').append(thumbnail));

                          self.append(table);
                        } else if (options.embed &amp;amp;amp;&amp;amp;amp; data.title) {

                            var e = '&amp;amp;lt;iframe height=&amp;amp;quot;360&amp;amp;quot; width=&amp;amp;quot;640&amp;amp;quot; frameborder=&amp;amp;quot;0&amp;amp;quot; src=&amp;amp;quot;http://www.own3d.tv/liveembed/'+self.data('liveid')+'&amp;amp;quot;&amp;amp;gt;&amp;amp;lt;/iframe&amp;amp;gt;';
                            var table = $('&amp;amp;lt;table/&amp;amp;gt;');

                            var status = $('&amp;amp;lt;td/&amp;amp;gt;').append($('&amp;amp;lt;div/&amp;amp;gt;').addClass(liveclass).append(link));
                            table.append($('&amp;amp;lt;tr/&amp;amp;gt;').append(status));

                            var embeddedplayer = $('&amp;amp;lt;td/&amp;amp;gt;').html(e);
                            table.append($('&amp;amp;lt;tr/&amp;amp;gt;').append(embeddedplayer));

                            self.append(table);
                        };
                      },
                      error: function(XMLHttpRequest, textStatus, errorThrown){
                        // console.debug(errorThrown);
                      }
                  });
                } else {
                  self.append(link);
                  self.addClass(liveclass);
                }
              } else {
                link.html(title+' - OFFLINE');
                self.removeClass(liveclass);
                self.append(link);
              }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                // console.debug(errorThrown);
            }
        });
      } else if (options &amp;amp;amp;&amp;amp;amp; options.channelid) {
        var ajaxdata = {
          channel_id : options.channelid
        };
        if (options.showall) { ajaxdata.showall = 1; };

        $.ajax({
            type: &amp;amp;quot;GET&amp;amp;quot;,
            async: true,
            data: ajaxdata,
            url: $.own3d.channelurl,
            dataType: &amp;amp;quot;jsonp&amp;amp;quot;,
            success: function(data){
              self.empty();

              var embedded = true;
              for(var i=0;i&amp;amp;lt;data.streams.length;i++) {
                var stream = data.streams[i];

                var plugindata = {
                  liveid : stream.liveid,
                  title : stream.title,
                  channelid : options.channelid,
                  // embed the first, thumbnail the rest
                  showthumbnail : (options.showthumbnail) || (!(options.showthumbnail) &amp;amp;amp;&amp;amp;amp; options.embed &amp;amp;amp;&amp;amp;amp; !embedded) ? true : false,
                  embed : (options.embed) ? true &amp;amp;amp;&amp;amp;amp; embedded : false
                };

                // prevent opening multiple embedded players
                embedded = false;                

                self.append($('&amp;amp;lt;div/&amp;amp;gt;').own3d(plugindata));
              }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
              // console.debug(errorThrown);
            }
        });
      }
    });
  }
})(jQuery)
</pre>
<p>A simple PHP &#8211; Zend Framework script to enable a cross domain request to the OWN3D API (the full project contains two, one for the live status and one for the channel information).</p>
<pre class="brush: php; title: ; notranslate">
&amp;amp;lt;?php

// Define path to application directory
define('APPLICATION_PATH', realpath(dirname(__FILE__)));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../../apps/library'),
    get_include_path(),
)));

$liveid = isset($_GET['live_id']) ? intval($_GET['live_id']) : 0;

require_once 'Zend/Http/Client.php';
$client = new Zend_Http_Client('http://api.own3d.tv/liveCheck.php?live_id='.$liveid, array('adapter' =&amp;amp;gt; 'Zend_Http_Client_Adapter_Socket'));

$xmlstr = $client-&amp;amp;gt;request()-&amp;amp;gt;getBody();
$xml = new SimpleXMLElement($xmlstr);

require_once 'Zend/Json/Encoder.php';
header('Content-Type: application/json');

// JSONP
if (isset($_GET['callback'])) {
        echo $_GET['callback'].'('. Zend_Json_Encoder::encode(array(
        'isLive'=&amp;amp;gt;(string)$xml-&amp;amp;gt;liveEvent-&amp;amp;gt;isLive,
        'liveViewers'=&amp;amp;gt;(string)$xml-&amp;amp;gt;liveEvent-&amp;amp;gt;liveViewers,
        'liveDuration'=&amp;amp;gt;(string)$xml-&amp;amp;gt;liveEvent-&amp;amp;gt;liveDuration,
    )).')';
}
// JSON
else {
    echo Zend_Json_Encoder::encode(array(
        'isLive'=&amp;amp;gt;(string)$xml-&amp;amp;gt;liveEvent-&amp;amp;gt;isLive,
        'liveViewers'=&amp;amp;gt;(string)$xml-&amp;amp;gt;liveEvent-&amp;amp;gt;liveViewers,
        'liveDuration'=&amp;amp;gt;(string)$xml-&amp;amp;gt;liveEvent-&amp;amp;gt;liveDuration,
    ));
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ingol.nl/blog/2011/06/16/show-the-live-status-from-an-own3d-tv-livestream-with-a-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Use Secure HTTP for Google JQuery Javascript Include.</title>
		<link>http://ingol.nl/blog/2009/10/26/use-secure-http-for-google-jquery-javascript-include/</link>
		<comments>http://ingol.nl/blog/2009/10/26/use-secure-http-for-google-jquery-javascript-include/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 14:23:05 +0000</pubDate>
		<dc:creator>Onno</dc:creator>
				<category><![CDATA[Categorized]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://ingol.nl/blog/?p=270</guid>
		<description><![CDATA[It&#8217;s nice to include jquery from Google for performance, less load, etc. But use the secure link!
It prevents IE from nagging about insecure content. Anyway, I can also advice on not using IE altogether.
(Thanks Webpatser: http://www.god-object.com/)
]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s nice to include jquery from Google for performance, less load, etc. But use the secure link!</p>
<pre class="brush: xml; title: ; notranslate">

&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
</pre>
<p>It prevents IE from nagging about insecure content. Anyway, I can also advice on not using IE altogether.</p>
<p>(Thanks Webpatser: <a href="http://www.god-object.com/">http://www.god-object.com/</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://ingol.nl/blog/2009/10/26/use-secure-http-for-google-jquery-javascript-include/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

