Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: c8886a55b0
Fetching contributors…

Cannot retrieve contributors at this time

112 lines (80 sloc) 15.3 kB
<!DOCTYPE html> <html> <head> <title>app.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> app.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">storage</span><span class="p">,</span> <span class="nx">helper</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#connect&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">userAddress</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#userAddress&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">showSpinner</span><span class="p">(</span><span class="s1">&#39;connectionSpinner&#39;</span><span class="p">);</span>
<span class="nx">storage</span><span class="p">.</span><span class="nx">connect</span><span class="p">(</span><span class="nx">userAddress</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">,</span> <span class="nx">storageInfo</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">setConnectionState</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="s1">&#39;userStorageInfo&#39;</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">storageInfo</span><span class="p">));</span>
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="s1">&#39;userAddress&#39;</span><span class="p">,</span> <span class="nx">userAddress</span><span class="p">);</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">setConnectionState</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">hideSpinner</span><span class="p">(</span><span class="s1">&#39;connectionSpinner&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#fetchPublicKey&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publicKey&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">showSpinner</span><span class="p">(</span><span class="s1">&#39;fetchPublicSpinner&#39;</span><span class="p">);</span>
<span class="nx">storage</span><span class="p">.</span><span class="nx">getData</span><span class="p">(</span><span class="s1">&#39;public&#39;</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">error</span> <span class="o">&amp;&amp;</span> <span class="nx">data</span> <span class="o">!=</span> <span class="s2">&quot;null&quot;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publicValue&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">hideSpinner</span><span class="p">(</span><span class="s1">&#39;fetchPublicSpinner&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publishPublic&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publicKey&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publicValue&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">showSpinner</span><span class="p">(</span><span class="s1">&#39;publishPublicSpinner&#39;</span><span class="p">);</span>
<span class="nx">storage</span><span class="p">.</span><span class="nx">putData</span><span class="p">(</span><span class="s1">&#39;public&#39;</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publicValue&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">hideSpinner</span><span class="p">(</span><span class="s1">&#39;publishPublicSpinner&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#authorize&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">storage</span><span class="p">.</span><span class="nx">authorize</span><span class="p">([</span><span class="s1">&#39;public&#39;</span><span class="p">,</span> <span class="s1">&#39;tutorial&#39;</span><span class="p">]);</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#publishTutorial&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#tutorialKey&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="kd">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#tutorialValue&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">showSpinner</span><span class="p">(</span><span class="s1">&#39;publishTutorialSpinner&#39;</span><span class="p">);</span>
<span class="nx">storage</span><span class="p">.</span><span class="nx">putData</span><span class="p">(</span><span class="s1">&#39;tutorial&#39;</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">error</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#tutorialValue&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">hideSpinner</span><span class="p">(</span><span class="s1">&#39;publishTutorialSpinner&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#fetchTutorialKey&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#tutorialKey&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">();</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">showSpinner</span><span class="p">(</span><span class="s1">&#39;fetchTutorialSpinner&#39;</span><span class="p">);</span>
<span class="nx">storage</span><span class="p">.</span><span class="nx">getData</span><span class="p">(</span><span class="s1">&#39;tutorial&#39;</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">error</span><span class="p">,</span> <span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">error</span> <span class="o">&amp;&amp;</span> <span class="nx">data</span> <span class="o">!==</span> <span class="s2">&quot;null&quot;</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#tutorialValue&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">hideSpinner</span><span class="p">(</span><span class="s1">&#39;fetchTutorialSpinner&#39;</span><span class="p">);</span>
<span class="p">});</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#disconnect&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">disconnect</span><span class="p">();</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#deauthorize&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s1">&#39;click&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">deauthorize</span><span class="p">();</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">});</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">setConnectionState</span><span class="p">(</span><span class="nx">helper</span><span class="p">.</span><span class="nx">isConnected</span><span class="p">());</span>
<span class="nx">helper</span><span class="p">.</span><span class="nx">setAuthorizedState</span><span class="p">(</span><span class="nx">helper</span><span class="p">.</span><span class="nx">isAuthorized</span><span class="p">());</span>
<span class="p">});</span>
<span class="p">})(</span><span class="nx">tutorial</span><span class="p">,</span> <span class="nx">helper</span><span class="p">);</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
Jump to Line
Something went wrong with that request. Please try again.