Widget / Channel

App Engine channels

by chilipeppr

HTML

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://www.chilipeppr.com/js/require.js"></script>
<!-- <script type="text/javascript" src="http://chilipeppr.com/_ah/channel/jsapi"></script> -->
<div id="com-chilipeppr-widget-channel" class="panel panel-default">
    <div class="panel-heading">
        <div class="btn-toolbar pull-right" role="toolbar">
            <div class="btn-group">
                <button type="button" class="btn btn-xs btn-default disconnect"><span class="glyphicon glyphicon-off"></span></button>
            </div>
            <div class="btn-group">
                <button type="button" class="btn btn-xs btn-default hidebody"><span class="glyphicon glyphicon-chevron-up"></span></button>
            </div>

            <div class="btn-group">
                <div class="dropdown">
                    <button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
                </div>
            </div>
        </div> 
        <span class="panel-title" data-toggle="popover">Channels</span>
        <!-- <span style="font-size:10px">Your id: </span> -->
        <!-- <span id="my-id">...</span> -->

    </div>
    <div id="com-chilipeppr-widget-channel-body" class="panel-body">
        
        
            
    </div>
    <div id="com-chilipeppr-widget-channel-ftr" class="panel-footer hidden">
        
    </div>
</div>

CSS

#com-chilipeppr-widget-webrtc-body {
    padding:0;
}
#my-video {
    /* margin-top: 15px; */
    width:100%;
  /* width: 280px; */
    height: auto;
    background-color: #eee;
}

#com-chilipeppr-widget-webrtc-client #their-video {
  width: 100%;
  height: 100%;
  /* max-height: 480px; */
  background-color: #eee;
}

#com-chilipeppr-widget-webrtc-client #video-container {
    padding: 0;
    text-align: center;
    margin-bottom:-5px;
}

#step1-error, #step2, #step3 {
    display: none;
}
#step1-error {
    padding-top:10px;
}
#my-id {
  font-weight: bold;
}

#com-chilipeppr-widget-webrtc-client .pure-u-1-3-wrapper-relative{
    /* position:relative; */
}
#com-chilipeppr-widget-webrtc-client .alert {
    margin-bottom:0;
}
#com-chilipeppr-widget-webrtc-client .pure-u-1-3 {
    /* position:absolute; */
    left:10px;
    top:10px;
    right:10px;
}
#com-chilipeppr-widget-webrtc-body:after {
    content:none;
}

JavaScript

requirejs.config({
    paths: {
        peerJs: 'http://cdn.peerjs.com/0.3/peer',
        jqueryui: '//chilipeppr.com/js/jquery-ui-1.10.4/ui/jquery.ui.core',
        jqueryuiWidget: '//chilipeppr.com/js/jquery-ui-1.10.4/ui/jquery.ui.widget',
        jqueryuiMouse: '//chilipeppr.com/js/jquery-ui-1.10.4/ui/jquery.ui.mouse',
        jqueryuiResizeable: '//chilipeppr.com/js/jquery-ui-1.10.4/ui/jquery.ui.resizable',
        googleChannel: 'https://talkgadget.google.com/talkgadget/channel'
    },
    shim: {
        jqueryuiWidget: ['jqueryui'],
        jqueryuiMouse: ['jqueryuiWidget'],
        jqueryuiResizeable: ['jqueryuiMouse' ]
    }
});

// Test this element. This code is auto-removed by the chilipeppr.load()
cprequire_test(["inline:com-chilipeppr-widget-channel"], function (hello) {
    console.log("test running of " + hello.id);
    hello.init();
} /*end_test*/ );

cpdefine("inline:com-chilipeppr-widget-channel", ["chilipeppr_ready", "peerJs", "jquerycookie", 'jqueryuiResizeable', 'googleChannel'], function () {
    
    return {
        id: "com-chilipeppr-widget-channel",
        url: "http://fiddle.jshell.net/chilipeppr/P2ge6/show/light/",
        fiddleurl: "http://jsfiddle.net/chilipeppr/P2ge6/",
        name: "Widget / Channel",
        desc: "Talks to Google App Engine's channels API",
        publish: {},
        subscribe: {},
        foreignPublish: {},
        foreignSubscribe: {},
        init: function () {

            this.configBodyFromCookie();
            
            /*
            //this.setupWebRtc();
            $('.com-chilipeppr-widget-webrtc-retry').click(this.connectToServer.bind(this));
            $('.com-chilipeppr-widget-webrtc-retryhello').click(this.connAskForStreamAgain.bind(this));
            
            $('#com-chilipeppr-widget-webrtc-client .disconnect').click(this.toggleConnect.bind(this));
            this.setupPeerJs();
            //this.makeCall('tvfzz2donnbwewmi');
            */
            
           ...