aboutsummaryrefslogtreecommitdiffhomepage
path: root/js/reveal.js
diff options
context:
space:
mode:
authorHakim El Hattab2014-03-12 08:51:51 +0100
committerHakim El Hattab2014-03-12 08:51:51 +0100
commit1c2f4a2e9243d43abf1f6606cfba079daa7d72f7 (patch)
treef150cb9c91fcb5e0553d9c30b2b3739fa95a67e4 /js/reveal.js
parente8ab2641daf519ea177443ca4fc356c7ff38ecf8 (diff)
deserialize state values
Diffstat (limited to 'js/reveal.js')
-rw-r--r--js/reveal.js29
1 files changed, 20 insertions, 9 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 5cb72eb..aa9f7b1 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -755,6 +755,22 @@ var Reveal = (function(){
}
/**
+ * Utility for deserializing a value.
+ */
+ function deserialize( value ) {
+
+ if( typeof value === 'string' ) {
+ if( value === 'null' ) return null;
+ else if( value === 'true' ) return true;
+ else if( value === 'false' ) return false;
+ else if( value.match( /^\d+$/ ) ) return parseFloat( value );
+ }
+
+ return value;
+
+ }
+
+ /**
* Measures the distance in pixels between point a
* and point b.
*
@@ -2352,9 +2368,9 @@ var Reveal = (function(){
function setState( state ) {
if( typeof state === 'object' ) {
- slide( state.indexh, state.indexv, state.indexf );
- togglePause( state.paused );
- toggleOverview( state.overview );
+ slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) );
+ togglePause( deserialize( state.paused ) );
+ toggleOverview( deserialize( state.overview ) );
}
}
@@ -3430,12 +3446,7 @@ var Reveal = (function(){
for( var i in query ) {
var value = query[ i ];
- query[ i ] = unescape( value );
-
- if( value === 'null' ) query[ i ] = null;
- else if( value === 'true' ) query[ i ] = true;
- else if( value === 'false' ) query[ i ] = false;
- else if( value.match( /^\d+$/ ) ) query[ i ] = parseFloat( value );
+ query[ i ] = deserialize( unescape( value ) );
}
return query;