Skip to content

Commit

Permalink
Make the Example section more concise (Issue #42).
Browse files Browse the repository at this point in the history
New update according to comments of PR #64.
  • Loading branch information
louaybassbouss committed Mar 18, 2015
1 parent d31df43 commit c7d7492
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 38 deletions.
25 changes: 7 additions & 18 deletions Overview.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,16 +566,13 @@ <h3>
var presUrl = "http://example.com/presentation.html";
// create random presId
var presId = Math.random().toFixed(6).substr(2);
navigator.presentation.startSession(presUrl, presId).then(function(newSession){
// a new session is started successfully
setSession(newSession);
},function(){
// Start new session. presId is optional.
// the new started session will be passed to setSession on success or null on error
navigator.presentation.startSession(presUrl, presId).then(setSession).catch(function(e){
// user cancels the selection dialog or an error is occurred
setSession(null);
});
&lt;/script&gt;


</pre>
</section>
<section>
Expand All @@ -587,17 +584,13 @@ <h3>
&lt;script&gt;
// read presId from localStorage if exists
var presId = localStorage &amp;&amp; localStorage["presId"] || null;
// presId is mandatory for joinSession
presId &amp;&amp; navigator.presentation.joinSession(presUrl, presId).then(function(existingSession){
// session with requested presUrl and presId is found and joined successfully
setSession(existingSession);
},function(){
// no session found for presUrl and presId or error is occurred
// presId is mandatory for joinSession.
// The joined session will be passed to setSession on success or null on error
presId &amp;&amp; navigator.presentation.joinSession(presUrl, presId).then(setSession).catch(function(e){
// no session found for presUrl and presId or an error is occurred
setSession(null);
});
&lt;/script&gt;


</pre>
</section>
<section>
Expand Down Expand Up @@ -632,8 +625,6 @@ <h3>
}
};
&lt;/script&gt;


</pre>
<pre class="example">
&lt;!-- presentation.html --&gt;
Expand All @@ -648,8 +639,6 @@ <h3>
session.postMessage("hello");
};
&lt;/script&gt;


</pre>
</section><!--
<p>
Expand Down
29 changes: 9 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
<h1>
Presentation API
</h1>
<h2 class="no-num no-toc" id="editor's-draft-16-march-2015">
Editor's Draft 16 March 2015
<h2 class="no-num no-toc" id="editor's-draft-18-march-2015">
Editor's Draft 18 March 2015
</h2>
<dl>
<dt>
Expand Down Expand Up @@ -640,16 +640,13 @@ <h3 id="starting-a-new-presentation-session-example"><span class="secno">5.2 </s
var presUrl = "http://example.com/presentation.html";
// create random presId
var presId = Math.random().toFixed(6).substr(2);
navigator.presentation.startSession(presUrl, presId).then(function(newSession){
// a new session is started successfully
setSession(newSession);
},function(){
// Start new session. presId is optional.
// the new started session will be passed to setSession on success or null on error
navigator.presentation.startSession(presUrl, presId).then(setSession).catch(function(e){
// user cancels the selection dialog or an error is occurred
setSession(null);
});
&lt;/script&gt;


</pre>
</section>
<section>
Expand All @@ -660,17 +657,13 @@ <h3 id="joining-a-presentation-session-example"><span class="secno">5.3 </span>
&lt;script&gt;
// read presId from localStorage if exists
var presId = localStorage &amp;&amp; localStorage["presId"] || null;
// presId is mandatory for joinSession
presId &amp;&amp; navigator.presentation.joinSession(presUrl, presId).then(function(existingSession){
// session with requested presUrl and presId is found and joined successfully
setSession(existingSession);
},function(){
// no session found for presUrl and presId or error is occurred
// presId is mandatory for joinSession.
// The joined session will be passed to setSession on success or null on error
presId &amp;&amp; navigator.presentation.joinSession(presUrl, presId).then(setSession).catch(function(e){
// no session found for presUrl and presId or an error is occurred
setSession(null);
});
&lt;/script&gt;


</pre>
</section>
<section>
Expand Down Expand Up @@ -704,8 +697,6 @@ <h3 id="monitor-session's-state-and-exchange-data-example"><span class="secno">5
}
};
&lt;/script&gt;


</pre>
<pre class="example">&lt;!-- presentation.html --&gt;
&lt;script&gt;
Expand All @@ -719,8 +710,6 @@ <h3 id="monitor-session's-state-and-exchange-data-example"><span class="secno">5
session.postMessage("hello");
};
&lt;/script&gt;


</pre>
</section><!--
<p>
Expand Down

0 comments on commit c7d7492

Please sign in to comment.