JSDoc; JS code style

This commit is contained in:
miripiruni 2013-01-20 01:13:21 +04:00
parent ce37304006
commit f36d547070
1 changed files with 22 additions and 17 deletions

View File

@ -1,7 +1,8 @@
// Shower HTML presentation engine: github.com/shower/shower /**
// Copyright © 20102013 Vadim Makeev, pepelsbey.net * Shower HTML presentation engine: github.com/shower/shower
// Licensed under MIT license: github.com/shower/shower/wiki/MIT-License * @copyright 20102013 Vadim Makeev, pepelsbey.net
* @license MIT license: github.com/shower/shower/wiki/MIT-License
*/
window.shower = (function(window, document, undefined) { window.shower = (function(window, document, undefined) {
var shower = {}, var shower = {},
url = window.location, url = window.location,
@ -25,7 +26,7 @@ window.shower = (function(window, document, undefined) {
}; };
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
// Slide ID's are optional. In case of missing ID we set it to the // Slide IDs are optional. In case of missing ID we set it to the
// slide number // slide number
if ( ! slides[i].id) { if ( ! slides[i].id) {
slides[i].id = i + 1; slides[i].id = i + 1;
@ -151,6 +152,8 @@ window.shower = (function(window, document, undefined) {
slideNumber = 0; slideNumber = 0;
} }
// As fast as you can ;-)
// http://jsperf.com/for-vs-foreach/46
for (; i >= 0; --i) { for (; i >= 0; --i) {
if (slideId === slideList[i].id) { if (slideId === slideList[i].id) {
slideNumber = i; slideNumber = i;
@ -184,7 +187,7 @@ window.shower = (function(window, document, undefined) {
// slides starts from 0 // slides starts from 0
ret = currentSlideNumber + 2; ret = currentSlideNumber + 2;
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
} else { } else {
@ -209,7 +212,7 @@ window.shower = (function(window, document, undefined) {
ret = currentSlideNumber; ret = currentSlideNumber;
shower.go(currentSlideNumber - 1); shower.go(currentSlideNumber - 1);
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
} else { } else {
@ -225,7 +228,7 @@ window.shower = (function(window, document, undefined) {
* @returns {Number} * @returns {Number}
*/ */
shower.first = function(callback) { shower.first = function(callback) {
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
@ -238,7 +241,7 @@ window.shower = (function(window, document, undefined) {
* @returns {Number} * @returns {Number}
*/ */
shower.last = function(callback) { shower.last = function(callback) {
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
return shower.go(slideList.length - 1); return shower.go(slideList.length - 1);
@ -274,7 +277,7 @@ window.shower = (function(window, document, undefined) {
shower.updateCurrentAndPassedSlides(currentSlideNumber); shower.updateCurrentAndPassedSlides(currentSlideNumber);
shower.runSlideshowIfPresented(currentSlideNumber); shower.runSlideshowIfPresented(currentSlideNumber);
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
@ -298,7 +301,7 @@ window.shower = (function(window, document, undefined) {
shower.scrollToSlide(currentSlideNumber); shower.scrollToSlide(currentSlideNumber);
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
@ -316,7 +319,7 @@ window.shower = (function(window, document, undefined) {
shower.enterListMode(); shower.enterListMode();
} }
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
@ -455,15 +458,17 @@ window.shower = (function(window, document, undefined) {
if (window.console) { if (window.console) {
slideNumber = shower._normalizeSlideNumber(slideNumber); slideNumber = shower._normalizeSlideNumber(slideNumber);
var slideId = slideList[slideNumber].id; var slideId = slideList[slideNumber].id,
var nextSlideId = slideList[slideNumber + 1] ? slideList[slideNumber + 1].id : null; nextSlideId = slideList[slideNumber + 1] ? slideList[slideNumber + 1].id : null,
notes = document.getElementById(slideId).querySelector('footer');
var notes = document.getElementById(slideId).querySelector('footer');
if (notes) { if (notes) {
console.info(notes.innerHTML.replace(/\n\s+/g,'\n')); console.info(notes.innerHTML.replace(/\n\s+/g,'\n'));
} }
if (nextSlideId) { if (nextSlideId) {
var next = document.getElementById(nextSlideId).querySelector('h2'); var next = document.getElementById(nextSlideId).querySelector('h2');
if (next) { if (next) {
next = next.innerHTML.replace(/^\s+|<[^>]+>/g,''); next = next.innerHTML.replace(/^\s+|<[^>]+>/g,'');
console.info('NEXT: ' + next); console.info('NEXT: ' + next);
@ -505,7 +510,7 @@ window.shower = (function(window, document, undefined) {
shower.updateCurrentAndPassedSlides(slideNumber); shower.updateCurrentAndPassedSlides(slideNumber);
shower.showPresenterNotes(slideNumber); shower.showPresenterNotes(slideNumber);
if (typeof(callback) === "function") { if (typeof(callback) === 'function') {
callback(); callback();
} }
} }