UNPKG

soocrate-core

Version:

this is the core of soocrate application

133 lines (112 loc) 5.78 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <base data-ice="baseUrl" href="../../"> <title data-ice="title">controller/statesheader.js | jquery-crate</title> <link type="text/css" rel="stylesheet" href="css/style.css"> <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css"> <script src="script/prettify/prettify.js"></script> <script src="script/manual.js"></script> <meta name="description" content="Cratify tool that turns a division into a distributed and decentralized collaborative editor"><meta property="twitter:card" content="summary"><meta property="twitter:title" content="jquery-crate"><meta property="twitter:description" content="Cratify tool that turns a division into a distributed and decentralized collaborative editor"></head> <body class="layout-container" data-ice="rootContainer"> <header> <a href="./">Home</a> <a href="identifiers.html">Reference</a> <a href="source.html">Source</a> <div class="search-box"> <span> <img src="./image/search.png"> <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span> </span> <ul class="search-result"></ul> </div> <a style="position:relative; top:3px;" href="https://github.com/haouarin/jquery-crate.git"><img width="20px" src="./image/github.png"></a></header> <nav class="navigation" data-ice="nav"><div> <ul> <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/controller/editor.js~EditorController.html">EditorController</a></span></span></li> <li data-ice="doc"><span data-ice="kind" class="kind-function">F</span><span data-ice="name"><span><a href="function/index.html#static-function-StatesHeader">StatesHeader</a></span></span></li> </ul> </div> </nav> <div class="content" data-ice="content"><h1 data-ice="title">controller/statesheader.js</h1> <pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">require(&apos;jquery-qrcode&apos;); function StatesHeader(model, statesView, linkView, shareView){ var self = this; this.model = model; this.statesView = statesView; this.startSharingText = &apos;&lt;i class=&quot;fa fa-link fa-2x ficon2&quot;&gt;&lt;/i&gt;&apos;; this.startSharingTooltip = &apos;start sharing&apos;; this.stopSharingText = &apos;&lt;i class=&quot;fa fa-unlink fa-2x ficon2&quot;&gt;&lt;/i&gt;&apos;; this.stopSharingTooltip = &apos;stop sharing&apos;; model.rps.on(&quot;statechange&quot;, function(state){ switch (state){ case &apos;connected&apos;: statesView.setNetworkState(&apos;connected&apos;); break; case &apos;partially connected&apos;: statesView.setNetworkState(&apos;partiallyConnected&apos;); break; case &apos;disconnected&apos;: statesView.setNetworkState(&apos;disconnected&apos;); break; }; }); shareView.click( function(){ var socket, action, client; if (model.signaling.startedSocket){ model.signaling.stopSharing(); return ; // ugly as hell }; // #0 create the proper call to the server socket = model.signaling.startSharing(); statesView.setSignalingState(&quot;waitSignaling&quot;); socket.on(&quot;connect&quot;, function(){ shareView.removeAttr(&quot;disabled&quot;); statesView.setSignalingState(&quot;waitJoiners&quot;); shareView.html(self.stopSharingText); shareView.attr(&apos;title&apos;, self.stopSharingTooltip) .tooltip(&apos;fixTitle&apos;); }); socket.on(&quot;disconnect&quot;, function(){ shareView.html(self.startSharingText); shareView.attr(&apos;title&apos;, self.startSharingTooltip) .tooltip(&apos;fixTitle&apos;); jQuery(&quot;#linkContainer&quot;).hide(); }); shareView.attr(&quot;disabled&quot;,&quot;disabled&quot;); // #1 modify the view // #A clean the address from args if (model.signaling.startedSocket){ // #B add the new argument var address = (window.location.href).split(&apos;?&apos;)[0]; action = linkView.printLink(address +&quot;?&quot;+ model.signalingOptions.session); }; }); linkView.qrcode.click(function(){ var address = (window.location.href).split(&apos;?&apos;)[0]; address = address + &quot;?&quot; + model.signalingOptions.session; linkView.qrcodeCanvas.html(&quot;&quot;); linkView.qrcodeCanvas.qrcode({ size:400, text:address }); }); }; StatesHeader.prototype.startJoining = function(signalingOptions){ var socket = this.model.signaling.startJoining(signalingOptions); this.statesView.setSignalingState(&apos;waitSignaling&apos;); var self = this; socket.on(&apos;connect&apos;, function(){ self.statesView.setSignalingState(&apos;waitSharer&apos;); }); }; module.exports = StatesHeader; </code></pre> </div> <footer class="footer"> Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(1.0.4)</span><img src="./image/esdoc-logo-mini-black.png"></a> </footer> <script src="script/search_index.js"></script> <script src="script/search.js"></script> <script src="script/pretty-print.js"></script> <script src="script/inherited-summary.js"></script> <script src="script/test-summary.js"></script> <script src="script/inner-link.js"></script> <script src="script/patch-for-local.js"></script> </body> </html>