From ce5a417857304055d74c740e7a3af389758c0c37 Mon Sep 17 00:00:00 2001 From: Vadim Makeev Date: Mon, 18 Jul 2011 16:40:01 +0400 Subject: [PATCH] currentSlide function added --- scripts/script.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/script.js b/scripts/script.js index 7d3469f..e8424b0 100755 --- a/scripts/script.js +++ b/scripts/script.js @@ -27,7 +27,7 @@ } function turnSlide(e) { - var current = slideList.indexOf(url.hash.substr(1)), target; + var current = currentSlide(), target; if(e) { if(e.type == 'keydown') { var prevent = true; @@ -104,21 +104,24 @@ function isFull() { return url.search.substr(1) == 'full'; } + + function currentSlide() { + return slideList.indexOf(url.hash.substr(1)); + } function updateProgress() { if(!progress) return; - progress.style.width = (100/(slideList.length-1) * slideList.indexOf(url.hash.substr(1))).toFixed(2) + '%'; + progress.style.width = (100/(slideList.length-1) * currentSlide()).toFixed(2) + '%'; } window.addEventListener('DOMContentLoaded', function() { if(isFull()) enterFull(); }, false); - window.addEventListener("popstate", function() { - var current_slide_number = slideList.indexOf(url.hash.substr(1)); - if (-1 === current_slide_number) { exitFull(); } + window.addEventListener('popstate', function() { + if(-1 === currentSlide()) exitFull(); }, false); document.addEventListener('keydown', turnSlide, false); document.addEventListener('keydown', enterFullKey, false); -})(); +})(); \ No newline at end of file