/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Spritz JavaScript SDK version 1.2.2 // Tue Aug 05 2014 15:57:10 GMT-0600 (MDT) // // Copyright (c) 2014 All Right Reserved, http://www.spritzinc.com/ // // This source is subject to the Spritz Developer License. // Please see http://www.spritzinc.com/spritz-developers-agreement for more information. // All other rights reserved. // // Spritz JavaScript SDK uses the following open source software: // jQuery: Home Page: https://jquery.org License: jquery.org/license // Bootstrap: Home Page: getbootstrap.com License: github.com/twbs/bootstrap/blob/master/LICENSE // Closure Tools: Home Page: developers.google.com/closure/library License: www.apache.org/licenses/LICENSE-2.0 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// !function(a,b,c,d){function e(){var a=!1;if(d&&d.fn){var b=d.fn.jquery.split(".");1===parseInt(b[0])?parseInt(b[1])>=7&&(a=!0):a=!0}if(!a)throw new Error("Spritz's JavaScript requires jQuery 1.7+")}function f(){var a=d("#spritzjs");if(0===a.length)b.spritz_sdk_root="//sdk.spritzinc.com/js/1.2";else{var c=a.attr("src"),e=c.split("/"),f="";if(e.length<3)f=".";else for(var g=0;g=e||f<=a.width-O?B=setTimeout(function(){B=null,pb()},c.redicle.countdownSlice):(kb(),gb(),tb(),nb(this))},qb=function(){return z},rb=function(a){return Math.floor(j/(a*i))},sb=function(a){return(1+a/100)*rb(qb())},tb=function(){var a=y.getCurrentWord();ub(a.word,a.orp,a.position,a.isBold())},ub=function(a,b,d,e){if(null!=a&&0!=a.length){var f,g,h=Q;e?(f=ab,g=cb):(f=_,g=bb);var i,j,k,l,m,n,o=a.length;0==b?(i=null,l=0):(i=a.substring(0,b),l=Math.round(hb(i,f))),j=a.substring(b,b+1),m=Math.round(hb(j,g)),n=Math.round(m/2),k=b==o-1?null:a.substring(b+1),l>0&&ib(i,f,c.redicle.textNormalPaintColor,O-l-n,h),ib(j,g,F,O-n,h),null!=k&&ib(k,f,c.redicle.textNormalPaintColor,O+n,h)}},vb=function(){h.fillStyle=c.redicle.backgroundColor,h.fillRect(R,Z,S-R,$)},wb=function(){var b=d(a),c=b.width(),e=b.height();c==width&&e==I?k.utils.debug(3,f+"dimensions unchanged: "+width+"x"+I):(k.utils.debug(3,f+"dimensions changed: "+width+"x"+I+" -> "+c+"x"+e),a.width=c,a.height=e,eb())},xb=function(b){var c=M,d=a.width-(u+v)-2*Math.round(a.width*t);if(h.measureText(b).width>d)do c--,h.font=c+"px "+l+","+o;while(h.measureText(b).width>d);return c},yb=function(b,d){if(b){db();var e=Math.round(a.width*t)+u,f=xb(b),g=f+"px "+l,h=Math.round((a.height-w-x)/2),i=h-f/2,j=d||c.redicle.textNormalPaintColor;ib(b,g,j,e,i)}};!function(){m([l],function(){eb(),h.fillStyle=c.redicle.backgroundColor,h.fillRect(0,0,a.width,a.height),gb(),y?tb():yb(c.placeholderText.startText,c.placeholderText.startTextColor)})}(),this.getCurrentText=function(){return mb()},this.setCurrentText=function(a){y=a,vb(),E===g.running&&(this.pauseText(),tb()),E===g.paused&&tb(),E===g.ready&&yb(c.placeholderText.startText,c.placeholderText.startTextColor),E===g.completed&&(vb(),yb(c.placeholderText.endText,c.placeholderText.endTextColor))},this.getCurrentTextSpeed=function(){return qb()},this.setCurrentTextSpeed=function(a){z=a},this.getCurrentPosition=function(){return null!=y?y.getCurrentIndex():-1},this.setCurrentPosition=function(a){null!=y&&y.setCurrentIndex(a)},this.getCurrentState=function(){return E},this.setCurrentState=function(a){E=a},this.getHighlightBestLetter=function(){return D},this.setHighlightBestLetter=function(a){D=a,lb()},this.getOnCompleteCallback=function(){return A},this.setOnCompleteCallback=function(a){A=a},this.isPaused=function(){return E==g.paused},this.isReady=function(){return E==g.ready},this.isRunning=function(){return E==g.running},this.isCompleted=function(){return E==g.completed},this.displayWord=function(a,b,c){ub(a,b,0,c)},this.eraseWord=function(){vb()},this.displayText=function(a,b){if(k.utils.debug(3,f+"Displaying text with "+a.size()+" words in "+z+" words/min"),y=a,A=b,y.hasNextWord())E=g.running,H&&wb(),lb(),ob();else if(null!=A){var b=A;delete A,b()}},this.displayPlaceholderText=function(a,b){kb.call(this),gb.call(this),yb(a,b)},this.pauseText=function(){E==g.running&&(null!=B&&(clearTimeout(B),B=null),y.getCurrentIndex()>0&&y.setCurrentIndex(y.getCurrentIndex()),E=g.paused),E=g.paused},this.resumeText=function(a){y?y.hasNextWord()?(k.utils.debug(3,f+"Resuming text with "+y.size()+" words at word # "+(y.getCurrentIndex()+1)),E=g.running,H&&wb(),lb(),"undefined"==typeof a||a?ob():nb(this)):k.utils.debug(2,f+"Cannot resume Text because there are no more words"):k.utils.debug(2,f+"Cannot resume Text because it is null")},this.resetText=function(){this.pauseText(),y=null,kb.call(this),gb.call(this)},this.reset=function(){kb.call(this),gb.call(this),y&&y.hasNextWord()?tb():y.hasNextWord()||(E=g.completed,yb(c.placeholderText.endText,c.placeholderText.endTextColor))}}var k=a;!function(){e(),f(),g()}(),jQuery(c).ready(function(){"SpritzSettings"in b&&"object"==typeof b.SpritzSettings&&"object"==typeof b.SpritzClient&&b.SpritzSettings.hasOwnProperty("clientId")&&"object"==typeof k&&"object"==typeof k.spritzinc&&k.spritzinc.initSpritzers(b.SpritzClient)}),jQuery(c).on("spritz_loaded_internal",function(){if("SpritzSettings"in b&&"object"==typeof b.SpritzSettings)if(b.SpritzSettings.hasOwnProperty("clientId")){var a="https://api.spritzinc.com/api-server/v1/",c=location.href;b.SpritzSettings.hasOwnProperty("apiRoot")&&(a=b.SpritzSettings.apiRoot),b.SpritzSettings.hasOwnProperty("redirectUri")&&(c=b.SpritzSettings.redirectUri),"object"==typeof k&&"object"==typeof k.client&&(b.SpritzClient=new k.client.SpritzClient(b.SpritzSettings.clientId,a,c),b.SpritzSettings.hasOwnProperty("anonymousEnabled")&&"boolean"==typeof b.SpritzSettings.anonymousEnabled&&b.SpritzClient.setAnonymousEnabled(b.SpritzSettings.anonymousEnabled),jQuery.isReady&&"object"==typeof k.spritzinc&&k.spritzinc.initSpritzers(b.SpritzClient))}else console&&console.log("SpritzSettings is missing clientId property, skipping initialization")}),k.utils={},k.utils.debugLevel=0,k.utils.setDebugLevel=function(a){k.utils.debugLevel=a},k.namespace=function(a){var b,c=a.split("."),d=k;for("SPRITZ"===c[0]&&(c=c.slice(1)),b=0;bd)c=d+"s ago";else{var e=Math.round((b.getTime()-a)/6e4);if(60>e)c=e+"m ago";else{var f,g,h=new Date(a);h.getHours()>12?(f=h.getHours()-12,g="PM"):(f=h.getHours(),g="AM");var i=f+":";h.getMinutes()<10&&(i+="0"),i=i+h.getMinutes()+" "+g,c=h.getDate()===b.getDate()&&h.getMonth()===b.getMonth()&&h.getFullYear()===b.getFullYear()?i:h.getMonth()+1+"/"+h.getDate()+"/"+h.getFullYear().toString().substring(2,4)+" "+i}}return c},k.utils.timeToString=function(a){var b,c=Math.round(a/1e3),d=c/60;if(d>=60){var e=Math.floor(d/60);d=Math.round(d%60),b=e+"hr"+(e>1?"s ":" ")+d+"m"}else d=Math.floor(d),c=Math.round(c%60),b=(d>0?d+"m ":"")+c+"s";return b},k.utils.debug=function(a){var c=[].slice.call(arguments).splice(1,arguments.length-1);if(b.console&&console.log){var d;switch(a){case 1:d="error";break;case 2:d="error";break;case 3:default:d="log"}if(a<=k.utils.debugLevel){for(var e="",f=0;f').insertAfter(d(this)).on("click",a);var j={relatedTarget:this};if(h.trigger(f=d.Event("show.bs.dropdown",j)),f.isDefaultPrevented())return;h.toggleClass(e.OPEN).trigger("shown.bs.dropdown",j),g.focus()}return!1}},h.prototype.keydown=function(a){if(/(38|40|27)/.test(a.keyCode)){var c=d(this);if(a.preventDefault(),a.stopPropagation(),!c.is(e.DISABLED)){var f=b(c),h=f.hasClass(e.OPEN);if(!h||h&&27==a.keyCode)return 27==a.which&&f.find(g).focus(),c.click();var i=" li:not(.divider):visible a",j=f.find("[role=menu]"+i+", [role=listbox]"+i);if(j.length){var k=j.index(j.filter(":focus"));38==a.keyCode&&k>0&&k--,40==a.keyCode&&k"+b.html()+""),d("."+e.DROPDOWN+" li",this.container).removeClass(e.SELECTED),a.addClass(e.SELECTED)};return a.prototype.setValue=function(a,b){var c=d("li[data-value='"+a+"']",this.container);return 1==c.length&&(h.call(this,c),g.call(this,c.data("value"),b)),1==c.length},d(c).ready(function(){d("."+e.SPEED_CONTAINER+"[data-role='select']").each(function(){var b=d(this);b.data("controller")instanceof a||new k.component.BootstrapSelectController(b)})}),{BootstrapSelectController:a}}),k.namespace("SPRITZ.model"),k.model.TimedWord=h,h.prototype={isBold:function(){return 0!=(this.flags&this.model.TimedWord.FLAG_BOLD)},isSentenceStart:function(){return 0!=(this.flags&this.model.TimedWord.FLAG_SENTENCE_START)},isParagraphStart:function(){return 0!=(this.flags&this.model.TimedWord.FLAG_PARAGRAPH_START)},toString:function(){return'{"'+this.word+'", '+this.orp+", "+this.multiplier+", "+this.position+(this.isParagraphStart()?", paragraphStart":"")+(this.isSentenceStart()?", sentenceStart":"")+(this.isBold()?", bold":"")+"}"}},k.model.TelemetryItem=function(a,b,c,d,e,f,g,h,i,j,k,l){if(this.id=a,this.time=g,this.user=b,this.userType=c,this.sessionId=d,this.category="ContentView",this.name=h,this.data={viewingSessionId:e,contentVersionId:f,"char":i,speed:j},"undefined"!=typeof k&&(this.data.interrupted=k),"undefined"!=typeof l)for(var m in l)l.hasOwnProperty(m)&&(this.data[m]=l[m])},k.model.TelemetryBatch=function(a,b){this.clientOS=a,this.clientEvents=b},k.model.IllegalArgumentException=function(a){this.name="IllegalArgumentException",this.message=a},k.model.IllegalArgumentException.prototype=new Error,k.model.IllegalArgumentException.prototype.constructor=k.model.IllegalArgumentException,k.model.ArrayIndexOutOfBoundsException=function(a){this.name="ArrayIndexOutOfBoundsException",this.message=a},k.model.ArrayIndexOutOfBoundsException.prototype=new Error,k.model.ArrayIndexOutOfBoundsException.prototype.constructor=k.model.ArrayIndexOutOfBoundsException,k.namespace("SPRITZ.model"),k.model.SpritzText=i,i.prototype={getContentVersionId:function(){return this.contentVersionId},setContentVersionId:function(a){this.contentVersionId=a},getDuration:function(){return this.duration},getWords:function(){return this.words},getLocale:function(){return this.locale},getVersion:function(){return this.version},getWord:function(a){return this.words[a]},getCurrentWord:function(){return this.words[this.index]},getNextWord:function(){if(this.words[this.index+1]){if(this.setCurrentIndex(++this.index),this.words[this.index]){var a=this.words[this.index];return a}return null}return null},hasNextWord:function(){return this.index0||this.words.length==this.wordCount},reset:function(){this.setCurrentIndex(0)},getPreviousSentenceStart:function(a,b){var c=k.model;if(0>a||a>=this.words.length)throw new c.ArrayIndexOutOfBoundsException(a);var d=a;if(b>0)for(;d>0&&b>0&&(!this.words[d].isSentenceStart()||0!=--b);d--);return d},getNextSentenceStart:function(a,b){var c=k.model;if(0>a||a>this.words.length)throw new c.ArrayIndexOutOfBoundsException(a);var d=a;if(b>0)for(;d=0&&ae;++e)!function(e){function f(){return g&&g.offsetWidth!=h&&(++b,g.parentNode.removeChild(g),g=null),b>=a.length&&(i&&clearInterval(i),b==a.length)?(d(),!0):void 0}var g=c.createElement("span");g.innerHTML="giItT1WQy@!-/#",g.style.position="absolute",g.style.left="-10000px",g.style.top="-10000px",g.style.fontSize="300px",g.style.fontFamily="sans-serif",g.style.fontVariant="normal",g.style.fontStyle="normal",g.style.fontWeight="normal",g.style.letterSpacing="0",c.body.appendChild(g);var h=g.offsetWidth;g.style.fontFamily=e;var i=0;f()||(i=setInterval(f,50))}(a[e])}var b=0;return function(c,d){0===b?a(c,d):d()}}();k.namespace("SPRITZ.client"),k.addToNamespace(k.client,function(){var a={name:"Spritz_JSSDK",version:"1.2.2",buildDate:"Tue Aug 05 2014 15:43:56 GMT-0600 (MDT)"};return{VersionInfo:a}}),k.addToNamespace(k.namespace("SPRITZ.client"),function(){function a(){return"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&null!==new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)}function c(a,b){this.code=a,this.message=b}function d(a,b,c){this.url=b+"/oauth/authorize?c="+encodeURIComponent(k.client.VersionInfo.name+"_"+k.client.VersionInfo.version)+"&response_type=token&client_id="+a+"&redirect_uri="+encodeURIComponent(c),this.onSuccess=null,this.onError=null,this.storageHandler=new k.datastore.StorageHandler}var e=function(a){"function"==typeof b.removeEventListener?(b.removeEventListener("message",this.onMessageHandler,!1),k.utils.debug(3,"Registered listener via addEventListener")):b.detachEvent("onmessage",this.onMessageHandler),this.storageHandler.remove("authResponse"),this.onSuccess&&this.onSuccess(a.data),this.showing=!1,a.source.close()};return d.prototype.show=function(c,d){this.onSuccess=c,this.onError=d,k.utils.debug(3,"opening auth popup with URL: ",this.url),this.storageHandler.remove("authResponse");var f=b.open(this.url,"SpritzLogin","width=400,height=400,location=0,menubar=0,toolbar=0");if(f){f.focus(),this.showing=!0,this.onMessageHandler=l.createDelegate(this,e),"function"==typeof b.addEventListener?(b.addEventListener("message",this.onMessageHandler,!1),k.utils.debug(3,"Registered listener via addEventListener")):b.attachEvent("onmessage",this.onMessageHandler);var g=a(),h=this,i=null;i=setInterval(function(){var a=h.storageHandler.getString("authResponse");if(null!==a&&h.onMessageHandler({data:a,source:f}),g)try{f.name&&-1!==f.name.indexOf("#access_token")&&h.onMessageHandler({data:f.name,source:f})}catch(b){k.utils.debug(2,b)}h.showing&&f?f.closed&&(clearInterval(i),h.showing=!1,h.onError&&h.onError(new Error("Login aborted"))):clearInterval(i)},250)}else k.utils.debug(1,"SpritzClient: Unable to open auth popup."),this.onError&&this.onError(new Error("Popup unable to open."))},{APIError:c,AuthPopup:d}}),k.addToNamespace(k.namespace("SPRITZ.client"),function(){function a(a){return"string"==typeof a&&'"'===a.charAt(0)&&'"'===a.charAt(a.length-1)&&(a=a.substr(1,a.length-2)),a}var b=Object.freeze({USER_ID:"userId",USER_NAME:"userName",GUEST_ID:"guestId"}),c=function(a){var b={};if(null===a||0===a.length)return b;var c=a.indexOf("#");c>=0&&(a=a.substring(c+1));for(var d=a.split("&"),e=0;e0},z.prototype.setAuthResponse=function(a,b,c){q.call(this,a,b,c)},z.prototype.spritzify=function(a,b,c,d){i.call(this,{type:"POST",url:this.apiRoot+"/misc/spritzify",dataType:"json",async:!0,data:{plainText:a,locale:b}},!0,!0,function(a){try{var b=k.model.SpritzText.create(a.plainTextHash,a.sd0,a.sd1,a.sd2,a.duration);"function"==typeof c&&c(b)}catch(e){"function"==typeof d&&d(new Error("Invalid data received: "+e.message))}},function(a){if("function"==typeof d){var b;b="undefined"!=typeof a.message?a.message:a.status+" ["+a.statusText+"]",d(new Error("Unable to retrive spritzableText: "+b))}})},z.prototype.sendTelemetry=function(a,b,c){var d=a.clientEvents[0].user,e="g"===a.clientEvents[0].userType?"guest":"user",f="g"===a.clientEvents[0].userType;i.call(this,{type:"POST",contentType:"application/json",url:this.apiRoot+"/"+e+"/"+d+"/event",dataType:"json",async:!0,data:JSON.stringify(a)},!0,f,function(c){"function"==typeof b&&b(a,c)},function(b){if("function"==typeof c){var d;d="undefined"!=typeof b.message?b.message:b.status+" ["+b.statusText+"]",c(a,new Error("Unable to send Telemetry: "+d))}})},z.prototype.setAnonymousEnabled=function(a){this.anonymousEnabled=a===!0},z.prototype.getGuestId=function(){var c=this.storageHandler.getString(b.GUEST_ID);if(c){var d=a(c);c!==d&&(this.setGuestId(d),c=d)}return c},z.prototype.setGuestId=function(a){this.storageHandler.putString(b.GUEST_ID,a)},z.prototype.getUserId=function(){var c=this.storageHandler.getString(b.USER_ID);if(c){var d=a(c);c!==d&&(this.setUserId(d),c=d)}return c},z.prototype.setUserId=function(a){this.storageHandler.putString(b.USER_ID,a)},z.prototype.getUserName=function(){return this.storageHandler.getString(b.USER_NAME)},z.prototype.setUserName=function(a){this.storageHandler.putString(b.USER_NAME,a)},z.prototype.registerLoginCallback=function(a){"function"==typeof a&&(this.loginCallback=a)},z.prototype.registerLogoutCallback=function(a){"function"==typeof a&&(this.logoutCallback=a)},{SpritzClient:z}}),k.namespace("SPRITZ.datastore"),k.addToNamespace(k.datastore,function(){function a(){}a.prototype.get=function(a){var c=localStorage.getItem(b(a));return null==c?(k.utils.debug(2,"StorageHandler: Item ["+a+"] does not exist"),null):d(c)},a.prototype.getString=function(a){return localStorage.getItem(b(a))},a.prototype.select=function(a){for(var c=[],e=b(a),f=0,g=localStorage.length;g>f;f+=1){var h=localStorage.key(f);0==h.indexOf(e)&&c.push(d(localStorage.getItem(h)))}return k.utils.debug(3,"StorageHandler: Select returning "+c.length+" items"),c},a.prototype.put=function(a,d){localStorage.setItem(b(a),c(d))},a.prototype.putString=function(a,c){localStorage.setItem(b(a),c)},a.prototype.remove=function(a){for(var c=0,d=b(a),e=0,f=localStorage.length;f>e;e+=1){var g=localStorage.key(e);null!=g&&0==g.indexOf(d)&&(localStorage.removeItem(g),c+=1)}return c};var b=function(a){return"spritz."+a},c=function(a){return JSON.stringify(a)},d=function(a){try{return JSON.parse(a)}catch(b){return k.utils.debug(2,"StorageHandler: Failed to parse item, exception ["+b.name+"] msg["+b.message+"]"),k.utils.debug(2,"StorageHandler: Item is not JSON - returning the raw value: ["+a+"]"),a}};return{StorageHandler:a,composeKey:b}}),k.namespace("SPRITZ.display"),k.addToNamespace(k.display,function(){function a(a,b,c){this.name="dp"+Math.random(),d[this.name]=new j(a,b,c),this.telemetryHandler=new k.spritzinc.TelemetryHandler,this.onCompleteCallback=function(a){this.telemetryHandler.stop(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),"function"==typeof a&&a()}}function b(a){var b=a.getCurrentIndex();if(b>=0){var c;a.hasNextWord()?c=2:(b--,c=1),b=a.getPreviousSentenceStart(b,c),""==a.getWord(b).word&&be.MAX_SPEED||ae.MAX_SPEED?"faster than maxUnregistered ["+e.MAX_SPEED+"]":"slower than minUnregistered ["+e.MIN_SPEED+"]";return k.utils.debug(0,"Attempt to set speed ["+a+"] "+c+" failed"),!1}return null!=d[this.name].getCurrentText()&&(this.telemetryHandler.changeSpeed(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed(),a),d[this.name].isRunning()&&this.telemetryHandler.start(d[this.name].getCurrentText(),a)),d[this.name].setCurrentTextSpeed(a),a},a.prototype.getCurrentPosition=function(){return null!=this.getCurrentText()?this.getCurrentText().getCurrentIndex():-1},a.prototype.setCurrentPosition=function(a){null!=this.getCurrentText()&&(d[this.name].isRunning()&&this.telemetryHandler.pause(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),d[this.name].setCurrentPosition(a))},a.prototype.getHighlightBestLetter=function(){return d[this.name].getHighlightBestLetter()},a.prototype.setHighlightBestLetter=function(a){d[this.name].setHighlightBestLetter(a)},a.prototype.getOnCompleteCallback=function(){return d[this.name].getOnCompleteCallback()},a.prototype.setOnCompleteCallback=function(a){d[this.name].setOnCompleteCallback(this.onCompleteCallback.bind(this,a))},a.prototype.isPaused=function(){return d[this.name].isPaused()},a.prototype.isReady=function(){return d[this.name].isReady()},a.prototype.isRunning=function(){return d[this.name].isRunning()},a.prototype.isCompleted=function(){return d[this.name].isCompleted()},a.prototype.displayText=function(a,b){d[this.name].getCurrentText()&&this.telemetryHandler.stop(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),d[this.name].displayText(a,this.onCompleteCallback.bind(this,b)),this.telemetryHandler.viewStart(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),this.telemetryHandler.start(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed())},a.prototype.pauseText=function(){d[this.name].isRunning()&&this.telemetryHandler.pause(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),d[this.name].pauseText()},a.prototype.resumeText=function(a){(d[this.name].isReady()||d[this.name].isPaused())&&this.telemetryHandler.start(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),d[this.name].resumeText(a)},a.prototype.resetUser=function(){this.pauseText(),this.telemetryHandler.resetUser()},a.prototype.resetText=function(){null!=d[this.name].getCurrentText()&&(d[this.name].pauseText(),this.telemetryHandler.stop(d[this.name].getCurrentText(),d[this.name].getCurrentTextSpeed()),d[this.name].resetText())},a.prototype.goToFirstWord=function(){this.getCurrentText()&&(d[this.name].pauseText(),this.telemetryHandler.rewind(this.getCurrentText(),d[this.name].getCurrentTextSpeed()),this.getCurrentText().reset(),d[this.name].reset())},a.prototype.goToPreviousSentence=function(){this.getCurrentText()&&(d[this.name].pauseText(),this.telemetryHandler.backup(this.getCurrentText(),d[this.name].getCurrentTextSpeed()),this.getCurrentText().setCurrentIndex(b(this.getCurrentText())),d[this.name].reset())},a.prototype.goToNextSentence=function(){var a=this.getCurrentText();if(a){d[this.name].pauseText(),this.telemetryHandler.forward(a,d[this.name].getCurrentTextSpeed());var b=a.setCurrentIndex(c(a));if(b||a.setCurrentIndex(a.size()-1),d[this.name].reset(),!a.hasNextWord()){var e=d[this.name].getOnCompleteCallback();e&&this.onCompleteCallback(e)}}},a.prototype.seek=function(a,b){var c,e=this.getCurrentText();return e?e.seek(a,b)?(d[this.name].pauseText(),this.telemetryHandler.seek(this.getCurrentText(),d[this.name].getCurrentTextSpeed()),d[this.name].reset(),c=!0):(k.utils.debug(2,name+"SpritzText.seek() failed"),c=!1):(k.utils.debug(2,name+"Cannot seek because text is null"),c=!1),c},a.prototype.getCurrentState=function(){return d[this.name].getCurrentState()},a.prototype.setCurrentState=function(a){return d[this.name].setCurrentState(a)},a.prototype.goToEnd=function(){var a=this.getCurrentText();if(a){d[this.name].pauseText(),this.telemetryHandler.end(this.getCurrentText(),d[this.name].getCurrentTextSpeed()),a.setCurrentIndex(a.size()-1),d[this.name].reset();var b=d[this.name].getOnCompleteCallback();b&&this.onCompleteCallback(b)}else k.utils.debug(2,"SpritzDisplayProxy: no text loaded")},a.prototype.eraseWord=function(){return d[this.name].eraseWord()},a.prototype.displayPlaceholderText=function(a,b){return d[this.name].displayPlaceholderText(a,b)},{SpritzDisplayProxy:a}}),k.namespace("SPRITZ.spritzinc"),k.addToNamespace(k.spritzinc,function(){function a(){this.userAgent=navigator.userAgent,this.sessionId=o(),this.viewingSessionId=o(),this.contentVersionId=null,this.items=[],this.eventId=0,this.storageHandler=new k.datastore.StorageHandler,this.startTime=(new Date).getTime(),this.updateTime=this.startTime,this.inactivityTimeout=null,this.userId=null,this.userType=null,this.started=!1,this.batchDelay=v.BATCH_DELAY,b.call(this),p.call(this,this.startTime)}function b(){this.userType=null,this.userId=SpritzClient.getUserId(),null!==this.userId?this.userType="u":(this.userId=SpritzClient.getGuestId(),null!==this.userId&&(this.userType="g"))}function c(){this.inactivityTimeout=setTimeout(l.createDelegate(this,e),v.BATCH_TIMEOUT)}function d(){null!==this.inactivityTimeout&&(clearTimeout(this.inactivityTimeout),this.inactivityTimeout=null)}function e(){k.utils.debug(3,"Processing inactivity timeout with ["+this.items.length+"] item(s)"),this.items.length>0&&f.call(this)}function f(){d.call(this),g.call(this,this.items),this.items=[],this.startTime=(new Date).getTime()}function g(a){var b=new k.model.TelemetryBatch(this.userAgent,a);SpritzClient.sendTelemetry(b,l.createDelegate(this,h),l.createDelegate(this,i))}function h(a,b){var c=a.clientEvents[0].sessionId,d=a.clientEvents[0].data.contentVersionId;b.lengthe;e+=1)0==this.storageHandler.remove(j(c,d,b[e]))&&k.utils.debug(2,"Failed to remove item ["+b[e]+"]")}function i(a,b){k.utils.debug(2,"Failed to send batch ["+b.message+"]"),s.call(this,a.clientEvents)}function j(a,b,c){return v.TELEMETRY_KEY+"."+a+"."+b+"."+c}function m(a){return"undefined"==typeof a?new Date:a}function n(a){return(new Date).getTime()-a}function o(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)})}function p(a){for(var b="",c="",d="",e=r.call(this,a),f=[],g=[],h=0,i=e.length;i>h;h+=1){var j=e[h];(j.user!==b||j.sessionId!==c||j.data.contentVersionId!==d||g.length>=v.BATCH_SIZE)&&(g.length>0&&(f.push(g),g=[]),b=j.user,c=j.sessionId,d=j.data.contentVersionId),g.push(j)}g.length>0&&f.push(g),f.length>0&&q.call(this,f)}function q(a){var b=a[0];b[0].user===this.getUserId()?g.call(this,b):s.call(this,b),a.length>1&&(a.splice(0,1),this.batchDelay>0?setTimeout(l.createDelegate(this,function(){q.call(this,a)}),this.batchDelay):q.call(this,a))}function r(a){for(var b=this.storageHandler.select(v.TELEMETRY_KEY).sort(t),c=b.length-1;c>=0;c--){var d=b[c],e="Date"==typeof d.time?d.time:new Date(d.time);e.getTime()>=a&&b.splice(c,1)}return b}function s(a){for(var b=0,c=a.length;c>b;b+=1){var d=a[b];n(new Date(d.time).getTime())>v.HOLDING_PERIOD&&0===this.storageHandler.remove(j(d.sessionId,d.data.contentVersionId,d.id))&&k.utils.debug(2,"Failed to remove item ["+d+"]")}}function t(a,b){var c;return c=a.user>b.user?1:a.userb.sessionId?1:a.sessionIdb.data.contentVersionId?1:a.data.contentVersionIdb.id?1:a.idb.time?1:a.time0&&f.call(this),this.userId=null,this.userType=null},a.prototype.viewStart=function(a,b){this.checkPreviousContent(a),this.contentVersionId=a.getContentVersionId(),this.items=[];var c=new Date;this.startTime=c.getTime(),this.storeEvent(u.VIEW_START,a,b,c),this.started=!0},a.prototype.start=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.START,a,b),this.started=!0},a.prototype.stop=function(a,b){this.started&&(this.storeEvent(u.STOP,a,b,void 0,a.hasNextWord()),this.started=!1),this.items.length>0&&f.call(this)},a.prototype.pause=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.PAUSE,a,b),this.started=!0},a.prototype.backup=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.BACKUP,a,b),this.started=!0},a.prototype.forward=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.FORWARD,a,b),this.started=!0},a.prototype.rewind=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.REWIND,a,b),this.started=!0},a.prototype.end=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.GOTOEND,a,b),this.started=!0},a.prototype.seek=function(a,b){this.checkPreviousContent(a),this.storeEvent(u.SEEK,a,b),this.started=!0},a.prototype.changeSpeed=function(a,b,c){this.checkPreviousContent(a),this.storeEvent(u.SPEED,a,b,void 0,void 0,{newSpeed:c}),this.started=!0},a.prototype.checkPreviousContent=function(a){this.items.length>0&&(null!==this.contentVersionId&&this.contentVersionId!==a.getContentVersionId()||n(this.startTime)>=v.BATCH_TIMEOUT)&&f.call(this)},a.prototype.storeEvent=function(a,b,e,g,h,i){if(null!==this.getUserId()){d.call(this),this.eventId+=1;var l=b.hasNextWord()?b.getCurrentWord().position:-1,n=j(this.sessionId,this.contentVersionId,this.eventId),o=new k.model.TelemetryItem(this.eventId,this.getUserId(),this.userType,this.sessionId,this.viewingSessionId,this.contentVersionId,m(g),a,l,e,h,i);k.utils.debug(3,"Added item: "+JSON.stringify(o)),this.storageHandler.put(n,o),this.items.push(o),this.updateTime=(new Date).getTime(),this.items.length>=v.BATCH_SIZE&&f.call(this),c.call(this)}},a.prototype.getUserId=function(){return null===this.userId&&b.call(this),this.userId},{TelemetryHandler:a,batchTimeout:v.BATCH_TIMEOUT,batchSize:v.BATCH_SIZE,holdingPeriod:v.HOLDING_PERIOD,EventTypeEnum:u,submitPendingItems:p,sendBatchSuccess:h,sendBatchFailure:i}}),k.namespace("SPRITZ.template"),k.addToNamespace(k.template,function(){function a(a){var b=a;return b.match(/{{\s*[\w\.]+\s*}}/g).map(function(a){var c=a.match(/[\w\.]+/)[0];g[c]||k.utils.debug(1,"Can't find constant: ",g[c]),b=b.replace(new RegExp(a,"g"),g[c])}),b}function b(b){f=b;var g="";return g+='
',g+=c(),g+=a('
'),g+='
',g+='
',g+=a(''),g+="
",g+='
',f.speedItems.length>0&&(g+=e()),g+=d(),g+='
.
',g+="
",g+="
"}function c(){var b='
';return b+='',f.header.login&&(b+=a('Login'),b+=a(' ",b+=a('"),f.header.close&&(b+='×'),b+="
"}function d(){var a="";a+='
a
',a+='
';for(var b=0,c=f.controlButtons.length;c>b;b+=1){var d=f.controlButtons[b],e=f.controlTitles[d];a+='
'}return a+="
"}function e(){var b="",c=SpritzClient.isUserLoggedIn()||SpritzClient.anonymousEnabled;loggedIn=SpritzClient.isUserLoggedIn(),b+=a('
')+a('"+a('",b+="
"}var f,g=k.constants.CSSClasses,h=k.constants.Constants;return{buildHtml:b,interpolate:a}}),k.namespace("SPRITZ.spritzinc"),k.addToNamespace(k.spritzinc,function(){function a(d){return this instanceof a?(this.spritzClient=b.SpritzClient||null,this.loading=!1,this.container=null,this.parentContainer=null,this.spritzPanel=null,this.pausePlayBtn=null,this.rewindBtn=null,this.backBtn=null,this.forwardBtn=null,this.pauseTitle=null,this.playTitle=null,this.speedDropdownController=null,this.progressReporter=null,this.seekPosition=null,this.seekMode=null,this.playOnFetchSuccess=!1,this.defaults=O,this.options,e.call(this,d),void c.call(this)):new a(d)}function c(){var a=this,b=this.options;this.container=d(k.template.buildHtml(b));var c=d("."+M.CANVAS,this.container);null===this.spritzPanel?this.spritzPanel=new k.display.SpritzDisplayProxy(c[0],b):this.spritzPanel.reloadRedicle(c[0],b),this.pausePlayBtn=d("."+M.BTN_PAUSEPLAY,this.container),this.rewindBtn=d("."+M.BTN_REWIND,this.container),this.backBtn=d("."+M.BTN_BACK,this.container),this.forwardBtn=d("."+M.BTN_FORWARD,this.container),this.endBtn=d("."+M.BTN_END,this.container),b.header.close&&(this.closeBtn=d("."+M.BTN_CLOSE,this.container),b.header.closeHandler&&(b.header.closeHandler=l.createDelegate(this,b.header.closeHandler)),this.closeBtn.on("click",b.header.closeHandler||this.hideSpritzer.bind(a)));for(var e={pauseplay:h,rewind:i,back:j,forward:m,end:n,redicle:o,complete:p,speedchange:q},f=b.controlButtons,g=0,r=f.length;r>g;g+=1)d("."+M.BTN_BASE+f[g],this.container).on("click",l.createDelegate(this,e[f[g]]));if(c.on("click",l.createDelegate(this,o)),b.speedItems.length>0){var s=d("."+M.SPEED_CONTAINER,this.container);this.speedDropdownController=new k.component.BootstrapSelectController(s),s.on("change",l.createDelegate(this,q))}var t=E.call(this)||b.defaultSpeed;this.setSpeed(t),this.progressReporter=l.createDelegate(this,L),B.call(this),C.call(this,!1),this.pauseTitle=b.controlTitles.pause,this.playTitle=b.controlTitles.play,d("."+M.BTN_LOGIN,this.container).on("click",l.createDelegate(this,F)),d("."+M.BTN_LOGOUT,this.container).on("click",l.createDelegate(this,G)),H.call(this,SpritzClient.isUserLoggedIn())}function e(a,b){var c=d.extend(!0,{},this.defaults);if(b===!0&&(c=this.getOptions()||this.defaults),a&&"object"==typeof a){if(this.options=d.extend({},c,a),k.utils.setDebugLevel(this.options.debugLevel),a&&a.redicle){var e=d.extend(!0,c.redicle,a.redicle);this.options.redicle=e}if(a&&a.placeholderText){var f=d.extend(!0,c.placeholderText,a.placeholderText);this.options.placeholderText=f}}else this.options=c;return this.options}function f(a){d("#"+M.LOADING,this.container).hide(),this.loading=!1,this.pausePlayBtn.removeClass(M.BTN_DISABLED),null!==this.seekPosition&&a.seek(this.seekPosition,this.seekMode),this.playOnFetchSuccess?(this.startSpritzing(a),B.call(this,!0),C.call(this,!0)):this.setSpritzText(a),this.playOnFetchSuccess=!1}function g(a){d("#"+M.LOADING,this.container).hide(),this.loading=!1,this.pausePlayBtn.removeClass(M.BTN_DISABLED),this.playOnFetchSuccess=!1,k.utils.debug(1,"Unable to spritz: "+a.message)}function h(){var a=D(this.pausePlayBtn);null==this.spritzPanel.getCurrentText()?a&&this._useCurrentUrl()&&this.loadText(!0):a&&(this.spritzPanel.isPaused()||this.spritzPanel.isReady()?(this.resumeSpritzing(),B.call(this,!0),s.call(this,this.playTitle)):(this.spritzPanel.pauseText(),B.call(this),C.call(this,!1),s.call(this,this.pauseTitle)))}function i(){if(D(this.rewindBtn)){var a=this.spritzPanel.getCurrentPosition();this.spritzPanel.goToFirstWord(),B.call(this),C.call(this,!1),t.call(this,a)}}function j(){if(D(this.backBtn)){var a=this.spritzPanel.getCurrentPosition();this.spritzPanel.goToPreviousSentence(),B.call(this),C.call(this,!1),u.call(this,a)}}function m(){if(D(this.forwardBtn)){var a=this.spritzPanel.getCurrentPosition();this.spritzPanel.goToNextSentence(),B.call(this),C.call(this,!1),v.call(this,a)}}function n(){if(D(this.endBtn)){var a=this.spritzPanel.getCurrentPosition();this.spritzPanel.goToEnd(),B.call(this),C.call(this,!1),w.call(this,a)}}function o(){null==this.spritzPanel.getCurrentText()?D(this.pausePlayBtn)&&this._useCurrentUrl()&&this.loadText(!0):D(this.pausePlayBtn)&&this.spritzPanel.getCurrentText().hasNextWord()?this.spritzPanel.isPaused()||this.spritzPanel.isReady()?(this.resumeSpritzing(),B.call(this,!0),x.call(this,this.playTitle)):(this.spritzPanel.pauseText(),B.call(this),C.call(this,!1),x.call(this,this.pauseTitle)):(this.spritzPanel.goToFirstWord(),this.resumeSpritzing(),B.call(this,!0),x.call(this,this.playTitle))}function p(){B.call(this),C.call(this,!1),y.call(this)}function q(a,b){if(a.preventDefault(),b&&"object"==typeof b)var c=b.newValue;if(c){var d=parseInt(c,10);this.spritzPanel.setCurrentTextSpeed(d),z.call(this)}}function r(a,b){var c=[];c.push(this.spritzPanel.getCurrentPosition()),"undefined"!=typeof b&&c.push(b),null!==this.parentContainer&&this.parentContainer.trigger("onSpritz"+a,c)}function s(a){r.call(this,a)}function t(a){r.call(this,"Rewind",a)}function u(a){r.call(this,"Back",a)}function v(a){r.call(this,"Forward",a)}function w(a){r.call(this,"GoToEnd",a)}function x(a){r.call(this,a)}function y(){null!==this.parentContainer&&this.parentContainer.trigger("onSpritzComplete")}function z(){null!==this.parentContainer&&this.parentContainer.trigger("onSpritzSpeedChange",[this.spritzPanel.getCurrentTextSpeed()])}function A(a){null!==this.parentContainer&&this.parentContainer.trigger("onProgressChange",[a])}function B(a){null==this.spritzPanel.getCurrentText()||0==this.spritzPanel.getCurrentText().getWords().length?(this.pausePlayBtn.addClass(M.BTN_DISABLED),this.rewindBtn.addClass(M.BTN_DISABLED),this.backBtn.addClass(M.BTN_DISABLED),this.forwardBtn.addClass(M.BTN_DISABLED),this.endBtn.addClass(M.BTN_DISABLED)):a||this.spritzPanel.getCurrentPosition()>0&&this.spritzPanel.getCurrentText().hasNextWord()?(this.pausePlayBtn.removeClass(M.BTN_DISABLED),this.rewindBtn.removeClass(M.BTN_DISABLED),this.backBtn.removeClass(M.BTN_DISABLED),this.forwardBtn.removeClass(M.BTN_DISABLED),this.endBtn.removeClass(M.BTN_DISABLED)):0==this.spritzPanel.getCurrentPosition()?(this.pausePlayBtn.removeClass(M.BTN_DISABLED),this.rewindBtn.addClass(M.BTN_DISABLED),this.backBtn.addClass(M.BTN_DISABLED),this.forwardBtn.removeClass(M.BTN_DISABLED),this.endBtn.removeClass(M.BTN_DISABLED)):this.spritzPanel.getCurrentText().hasNextWord()||(this.pausePlayBtn.addClass(M.BTN_DISABLED),this.rewindBtn.removeClass(M.BTN_DISABLED),this.backBtn.removeClass(M.BTN_DISABLED),this.forwardBtn.addClass(M.BTN_DISABLED),this.endBtn.addClass(M.BTN_DISABLED))}function C(a){a?(this.pausePlayBtn.removeClass(M.BTN_PLAY),this.pausePlayBtn.addClass(M.BTN_PAUSE),this.pausePlayBtn.prop("title","Pause")):(this.pausePlayBtn.removeClass(M.BTN_PAUSE),this.pausePlayBtn.addClass(M.BTN_PLAY),this.pausePlayBtn.prop("title","Play"))}function D(a){return!a.hasClass(M.BTN_DISABLED)}function E(){var a=d("."+M.BTN_WPM,this.container).text();return parseInt(a,10)}function F(){this.spritzPanel.resetUser(),this.spritzClient.userLogin(l.createDelegate(this,function(){H.call(this,!0),B.call(this),C.call(this,!1)}),function(a){k.utils.debug(1,"Login failure ["+a+"]")})}function G(){this.spritzPanel.resetUser(),this.spritzClient.userLogout(),H.call(this,!1),B.call(this),C.call(this,!1)}function H(a){var b=d("."+M.BTN_LOGIN),c=d("."+M.BTN_USER);b.removeClass(a?M.LOGGEDOUT:M.LOGGEDIN),b.addClass(a?M.LOGGEDIN:M.LOGGEDOUT),c.removeClass(a?M.LOGGEDIN:M.LOGGEDOUT),c.addClass(a?M.LOGGEDOUT:M.LOGGEDIN),d("."+M.USER).text(a?SpritzClient.getUserName():""),I.call(this)}function I(){var a=d("."+M.DISABLED);if(J()&&a.length>0&&d("."+M.DISABLED).removeClass(M.DISABLED),!J()){var b=this.getSpeed();if(b>N.MAX_SPEED||bN.MAX_SPEED||cN.MAX_SPEED||a=b?A.call(this,d):100>c%b&&A.call(this,d)}var M=k.constants.CSSClasses,N=k.constants.Constants,O={debugLevel:1,redicleWidth:300,redicleHeight:50,defaultSpeed:250,speedItems:[250,300,350,400,450,500,550,600],header:{login:!0,close:!1,closeHandler:null},controlButtons:["rewind","back","pauseplay","forward"],controlTitles:{pause:"Pause",play:"Play",rewind:"Back to Beginning",back:"Previous Sentence",forward:"Next Sentence",end:"Go to End"},placeholderText:{startText:"Click to spritz",startTextColor:"#bababa",endText:"",endTextColor:"#bababa"},redicle:{backgroundColor:"#ffffff",textNormalPaintColor:"#333",textHighlightPaintColor:"#cc0001",redicleLineColor:"#000",redicleLineWidth:1,countdownTime:750,countdownSlice:5,countdownColor:"rgba(0,0,0,0.1)"}};return a.prototype.attach=function(a){return this.parentContainer=a,a.hasClass(M.ROOT)||a.addClass(M.ROOT),this.container.appendTo(a),a.data("controller",this),this.spritzClient&&this.hasSource()&&this._useCurrentUrl()&&(C.call(this,!1),this.pausePlayBtn.removeClass(M.BTN_DISABLED)),H.call(this,SpritzClient.isUserLoggedIn()),this},a.prototype.detach=function(){var a=this.parentContainer;return this.container.remove(),this.parentContainer=null,a},a.prototype.hasSource=function(){var a;if(null===this.spritzPanel.getCurrentText()){var b=this.parentContainer.data("url");a=null===b||"undefined"==typeof b||b.length>0}else a=!0;return a},a.prototype.loadText=function(a,b){var c;if(!this.spritzClient||this.loading)c=!1;else{this.spritzPanel.isRunning()&&this.pauseSpritzing(),b||(b={});var e=this.parentContainer.data("url")||b.url,h=this.parentContainer.data("selector")||b.selector,i=this.parentContainer.data("selectortype")||b.selectorType;e||(e=location.href),0==e.length?c=!1:(this.loading=!0,this.pausePlayBtn.addClass(M.BTN_DISABLED),this.playOnFetchSuccess=a,d("#"+M.LOADING,this.container).show(),this.spritzClient.fetchContents(e,l.createDelegate(this,f),l.createDelegate(this,g),h,i),c=!0)}return c},a.prototype.getSpritzText=function(){return this.spritzPanel.getCurrentText()},a.prototype.setSpritzText=function(a){null===a?(B.call(this,!1),null!=this.spritzClient&&this.hasSource()&&(C.call(this,!0),this.pausePlayBtn.removeClass(M.BTN_DISABLED))):(null==a.getProgressTracker()&&a.setProgressTracker(this.progressReporter),this.spritzPanel.setCurrentText(a),this.spritzPanel.setOnCompleteCallback(l.createDelegate(this,p)),B.call(this,!1))},a.prototype.getUrl=function(){return this.parentContainer.data("url")},a.prototype.setUrl=function(a,b,c){if(this.parentContainer){var d=this.parentContainer.data();d.url&&d.url===a||(this.spritzPanel.resetText(),this.parentContainer.data("url",a),"number"==typeof b?(this.seekPosition=b,this.seekMode="undefined"==typeof c?k.model.SpritzText.SeekType.SENTENCE_START:c===k.model.SpritzText.SeekType.SENTENCE_START||c===k.model.SpritzText.SeekType.ABSOLUTE?c:null):this.seekPosition=null,B.call(this,!1),this.spritzClient&&this.hasSource()&&(C.call(this,!1),this.pausePlayBtn.removeClass(M.BTN_DISABLED)))}else k.utils.debug(1,"setUrl() failed. No parent container set for the controller. Make sure you have attached the controller to an element in the DOM first.")},a.prototype._useCurrentUrl=function(){if(this.parentContainer){var a=this.parentContainer.data(),b=!1;return a&&"spritzer"===a.role&&(b=!0),b}},a.prototype.startSpritzing=function(a){this.spritzPanel.pauseText(),!a&&this.spritzPanel.getCurrentText()?this.spritzPanel.resumeText(!0):a&&(null==a.getProgressTracker()&&a.setProgressTracker(this.progressReporter),this.spritzPanel.displayText(a,l.createDelegate(this,p))),B.call(this,!0),C.call(this,!0)},a.prototype.stopSpritzing=function(){this.spritzPanel.resetText(),B.call(this),C.call(this,!1)},a.prototype.pauseSpritzing=function(){this.spritzPanel.pauseText(),C.call(this,!1)},a.prototype.resumeSpritzing=function(){this.spritzPanel.resumeText(),C.call(this,!0)},a.prototype.getSpeed=function(){return this.spritzPanel.getCurrentTextSpeed()},a.prototype.setSpeed=function(a){var b=this.spritzPanel.setCurrentTextSpeed(a);return b&&this.speedDropdownController&&this.speedDropdownController.setValue(a,!0),b},a.prototype.getHighlightBestLetter=function(){return this.spritzPanel.getHighlightBestLetter()},a.prototype.setHighlightBestLetter=function(a){this.spritzPanel.setHighlightBestLetter(a)},a.prototype.getProgressReporter=function(){return this.progressReporter},a.prototype.setProgressReporter=function(a){this.progressReporter=a},a.prototype.seek=function(a,b){var c;return this.spritzPanel.seek(a,b)?(B.call(this),C.call(this,!1),c=!0):c=!1,c},a.prototype.setButtonState=function(a,b){b?a.removeClass(M.BTN_DISABLED):a.addClass(M.BTN_DISABLED)},a.prototype.adjustButtonStates=function(a){B.call(this,"undefined"==typeof a?this.spritzPanel.isRunning():a)},a.prototype.adjustPausePlayButton=function(a){C.call(this,"undefined"==typeof a?this.spritzPanel.isRunning():a)},a.prototype.showSpritzer=function(){this.container.show()},a.prototype.hideSpritzer=function(){this.pauseSpritzing(),this.container.hide()},a.prototype.applyOptions=function(a,b){var d=this.container,f=this.spritzPanel.getCurrentText(),g=this.spritzPanel.getOnCompleteCallback(),h=this.spritzPanel.getCurrentTextSpeed(),i=this.spritzPanel.getHighlightBestLetter(),j=this.spritzPanel.getCurrentState(),k=this.spritzPanel.isRunning();k&&this.spritzPanel.pauseText();var l=this.parentContainer,m=this.getProgressReporter();e.call(this,a,b),c.call(this),this.setProgressReporter(m),this.spritzPanel.setOnCompleteCallback(g),this.spritzPanel.setCurrentTextSpeed(h),this.spritzPanel.setHighlightBestLetter(i),this.speedDropdownController&&this.speedDropdownController.setValue(h,!0),d.remove(),this.attach(l),k||this.spritzPanel.setCurrentState(j),f&&this.spritzPanel.setCurrentText(f),k&&this.spritzPanel.resumeText(!1),B.call(this,k),C.call(this,k) },a.prototype.getProp=function(a){var b=a.split("."),c=this.options[b[0]];return this.options[b[0]]?(b.length>1&&(c=this.options[b[0]][b[1]]),c):void k.utils.debug(2,"SpritzOptions: the "+a+" property does not exist.")},a.prototype.getOptions=function(){return this.options||k.utils.debug(2,"SpritzOptions: no options initialized yet."),this.options},{SpritzerController:a,initSpritzers:K,adjustPausePlayButton:C,setButtonStates:B,init:c}}),k.namespace("SPRITZ.bookmark"),k.addToNamespace(k.bookmark,function(){function a(a,c){this.spritzerController=a,this.bookStores=null,this.currentBookStore=null,this.currentChapterName=null,this.options=null,b.call(this,c)}function b(a){this.options=F(a),this.bookStores=c.call(this,this.spritzerController)}function c(a){for(var b={},c=d(this.options.book),f=0,i=c.length;i>f;f+=1){var j=c[f],m=d(this.options.bookTitle,j),s=h(d(this.options.bookName,m)),u=d(this.options.totalTime,m),v=d(this.options.remainingTime,m),w=new k.bookmark.BookStore(s,g(u,v));b[s]=w,e.call(this,j,w);var x=a.parentContainer;x.on("onSpritzPause",l.createDelegate(this,n)),x.on("onSpritzRewind",l.createDelegate(this,q)),x.on("onSpritzBack",l.createDelegate(this,o)),x.on("onSpritzForward",l.createDelegate(this,p)),x.on("onSpritzComplete",l.createDelegate(this,r)),x.on("onSpritzSpeedChange",l.createDelegate(this,t))}return b}function e(a,b){for(var c=d(this.options.bookChapter,a),e=0,j=c.length;j>e;e+=1){var k=c[e],m=d(k).data("url"),n=d(k).data("selector"),o=d(this.options.statusImage,k),p=d(this.options.chapterName,k),q=h(p),r=d(this.options.totalTime,k),s=d(this.options.remainingTime,k),t=f(m,n),w=g(r,s,o,p);b.addChapter(q,t,w),i.call(this,b,q,t,w),d(o).on("click",{handler:b,name:q},l.createDelegate(this,u)),d(p).on("click",{handler:b,name:q},l.createDelegate(this,v))}}function f(a,b){return{url:a,selector:b}}function g(a,b,c,d){return{totalTime:a,remainingTime:b,bookmarkElement:c,chapterElement:d}}function h(a){var b=d(a).data("name");return("undefined"==typeof b||null===b||""===b)&&(b=a.text()),b}function i(a,b,c){var d=this,e=function(e){k.utils.debug(3,"BookController.onFetchInfoSuccess: "+e.getWordCount()+", "+e.getDuration()),c.text=e,y.call(d,a,b)},f=function(a){k.utils.debug(1,"BookController.onFetchInfoError: "+a.message)};SpritzClient.fetchContents2(c.url,e,f,{selector:c.selector,selectorType:"CSS",includePlainText:!1,includeSpritzableText:!1})}function j(a,b,c){var d=function(d){k.utils.debug(3,"BookController.fetchTextAndStartSpritzing"),c.text=d,m.call(this,a,b,c)},e=function(a){k.utils.debug(1,"BookController.fetchTextAndStartSpritzing: "+a.message)};SpritzClient.fetchContentsByContentId(c.text.contentId,l.createDelegate(this,d),e)}function m(a,b,c){null!=this.currentBookStore&&null!=this.currentChapterName&&d(this.currentBookStore.getControls(this.currentChapterName).chapterElement).removeClass(this.options.textHighlighter),d(a.getControls(b).chapterElement).addClass(this.options.textHighlighter),this.currentBookStore=a,this.currentChapterName=b;var e=c.text.clone(),f=a.getPosition(b);null!==f&&e.setCurrentIndex(f),e.hasNextWord()?this.spritzerController.startSpritzing(e):this.spritzerController.setSpritzText(e)}function n(a,b){s.call(this,b)}function o(a,b){s.call(this,b)}function p(a,b){s.call(this,b)}function q(a,b){s.call(this,b)}function r(){this.currentBookStore.setCompleted(this.currentChapterName),y.call(this,this.currentBookStore,this.currentChapterName)}function s(a){var b=this.spritzerController.getSpritzText().getPreviousSentenceStart(a,1);this.currentBookStore.setPosition(this.currentChapterName,b),y.call(this,this.currentBookStore,this.currentChapterName)}function t(a,b){k.utils.debug(3,"BookController.onSpeedChange");for(var c in this.bookStores)if(this.bookStores.hasOwnProperty(c)){var d=this.bookStores[c];z(this.bookStores[c],b);for(var e in d.getChapters())A(d,e,b)}}function u(a){k.utils.debug(3,"BookController.onBookmarkClick"),w.call(this,a.data.handler,a.data.name,a.data.handler.getContent(a.data.name))}function v(a){k.utils.debug(3,"BookController.onChapterClick"),w.call(this,a.data.handler,a.data.name,a.data.handler.getContent(a.data.name))}function w(a,b,c){var d=this;if(k.utils.debug(3,"BookController.handleContentClick"),"undefined"==typeof c.text){var e=function(e){k.utils.debug(4,"BookController.handleContentClick"),c.text=e,y.call(d,a,b)},f=function(a){k.utils.debug(3,"BookController.handleContentClick: "+a.message)};SpritzClient.fetchContents(c.url,e,f,c.selector)}else c.text.isLoaded()?m.call(this,a,b,c):j.call(this,a,b,c)}function x(){var a=this.spritzerController.getSpeed();return 0>=a&&(a=250),a}function y(a,b){var c=x.call(this);z(a,c),A(a,b,c),D.call(this,a,b),E.call(this,a,b)}function z(a,b){B(a.controls.totalTime,k.utils.timeToString(a.getTotalTotalTime(b))),B(a.controls.remainingTime,k.utils.timeToString(a.getTotalRemainingTime(b)))}function A(a,b,c){var d=a.getControls(b),e=k.utils.timeToString(a.getTotalTime(b,c));B(d.totalTime,e),C(d.chapterElement,"Total Time: "+e);var f=k.utils.timeToString(a.getRemainingTime(b,c));B(d.remainingTime,f),C(d.bookmarkElement,"Remaining Time: "+f)}function B(a,b){null!==a&&d(a).text(b)}function C(a,b){null!==a&&d(a).prop("title",b)}function D(a,b){a.hasBookmark(b)?d(a.getControls(b).bookmarkElement).addClass(this.options.bookmarkImage):d(a.getControls(b).bookmarkElement).removeClass(this.options.bookmarkImage)}function E(a,b){var c=a.getControls(b);a.isCompleted(b)?(d(c.bookmarkElement).addClass(this.options.checkmarkImage),d(c.chapterElement).addClass(this.options.chapterCompleted),d(c.totalTime).addClass(this.options.chapterCompleted),d(c.remainingTime).addClass(this.options.chapterCompleted)):(d(c.bookmarkElement).removeClass(this.options.checkmarkImage),d(c.chapterElement).removeClass(this.options.chapterCompleted),d(c.totalTime).removeClass(this.options.chapterCompleted),d(c.remainingTime).removeClass(this.options.chapterCompleted))}function F(a){var b={},c={book:".spritz-book",bookTitle:".book-title",bookChapter:".book-chapter",bookName:".book-name",totalTime:".total-time",remainingTime:".remaining-time",statusImage:".status-image",chapterName:".chapter-name",bookmarkImage:"bookmark-image",checkmarkImage:"checkmark-image",chapterCompleted:"chapter-completed",textHighlighter:"text-highlighter"};return b="object"==typeof a?d.extend({},c,a):c}return{BookController:a}}),k.addToNamespace(k.bookmark,function(){function a(){var a=localStorage.getItem(this.storageKey);this.bookmarkData=null!==a&&"undefined"!=typeof a?JSON.parse(a):null}function b(){localStorage.setItem(this.storageKey,JSON.stringify(this.bookmarkData))}function c(){var a={};return a.createTime=(new Date).getTime(),a.updateTime=null,a.chapterPositions={},a}var d=function(b,c){this.bookmarkData=null,this.controls=c,this.storageKey="spritz.bookmark."+b,this.chapters={},a.call(this)};return d.prototype.addChapter=function(a,b,c){this.chapters[a]={content:b,controls:c}},d.prototype.getChapters=function(){return this.chapters},d.prototype.getContent=function(a){return this.chapters[a].content},d.prototype.getControls=function(a){return this.chapters[a].controls},d.prototype.getPosition=function(a){var b=null;return null!=this.bookmarkData&&(b=this.bookmarkData.chapterPositions[a],"undefined"==typeof b&&(b=0)),b},d.prototype.setPosition=function(a,d){null==this.bookmarkData&&(this.bookmarkData=c()),this.bookmarkData.updateTime=(new Date).getTime(),this.bookmarkData.chapterPositions[a]=d,b.call(this)},d.prototype.isCompleted=function(a){var b=this.getContent(a).text;return null!==b&&b.getWordCount()>0&&this.getPosition(a)>=b.getWordCount()},d.prototype.setCompleted=function(a){this.setPosition(a,this.getContent(a).text.getWordCount())},d.prototype.hasBookmark=function(a){var b=this.getPosition(a),c=this.getContent(a);return b>0&&b=-128&&128>a){var b=n.math.Long.IntCache_[a];if(b)return b}var c=new n.math.Long(0|a,0>a?-1:0);return a>=-128&&128>a&&(n.math.Long.IntCache_[a]=c),c},n.math.Long.fromNumber=function(a){return isNaN(a)||!isFinite(a)?n.math.Long.ZERO:a<=-n.math.Long.TWO_PWR_63_DBL_?n.math.Long.MIN_VALUE:a+1>=n.math.Long.TWO_PWR_63_DBL_?n.math.Long.MAX_VALUE:0>a?n.math.Long.fromNumber(-a).negate():new n.math.Long(a%n.math.Long.TWO_PWR_32_DBL_|0,a/n.math.Long.TWO_PWR_32_DBL_|0)},n.math.Long.fromBits=function(a,b){return new n.math.Long(a,b)},n.math.Long.fromString=function(a,b){if(0==a.length)throw Error("number format error: empty string");var c=b||10;if(2>c||c>36)throw Error("radix out of range: "+c);if("-"==a.charAt(0))return n.math.Long.fromString(a.substring(1),c).negate();if(a.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+a);for(var d=n.math.Long.fromNumber(Math.pow(c,8)),e=n.math.Long.ZERO,f=0;fg){var i=n.math.Long.fromNumber(Math.pow(c,g));e=e.multiply(i).add(n.math.Long.fromNumber(h))}else e=e.multiply(d),e=e.add(n.math.Long.fromNumber(h))}return e},n.math.Long.TWO_PWR_16_DBL_=65536,n.math.Long.TWO_PWR_24_DBL_=1<<24,n.math.Long.TWO_PWR_32_DBL_=n.math.Long.TWO_PWR_16_DBL_*n.math.Long.TWO_PWR_16_DBL_,n.math.Long.TWO_PWR_31_DBL_=n.math.Long.TWO_PWR_32_DBL_/2,n.math.Long.TWO_PWR_48_DBL_=n.math.Long.TWO_PWR_32_DBL_*n.math.Long.TWO_PWR_16_DBL_,n.math.Long.TWO_PWR_64_DBL_=n.math.Long.TWO_PWR_32_DBL_*n.math.Long.TWO_PWR_32_DBL_,n.math.Long.TWO_PWR_63_DBL_=n.math.Long.TWO_PWR_64_DBL_/2,n.math.Long.ZERO=n.math.Long.fromInt(0),n.math.Long.ONE=n.math.Long.fromInt(1),n.math.Long.NEG_ONE=n.math.Long.fromInt(-1),n.math.Long.MAX_VALUE=n.math.Long.fromBits(-1,2147483647),n.math.Long.MIN_VALUE=n.math.Long.fromBits(0,-2147483648),n.math.Long.TWO_PWR_24_=n.math.Long.fromInt(1<<24),n.math.Long.prototype.toInt=function(){return this.low_},n.math.Long.prototype.toNumber=function(){return this.high_*n.math.Long.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.math.Long.prototype.toString=function(a){var b=a||10;if(2>b||b>36)throw Error("radix out of range: "+b);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(n.math.Long.MIN_VALUE)){var c=n.math.Long.fromNumber(b),d=this.div(c),e=d.multiply(c).subtract(this);return d.toString(b)+e.toInt().toString(b)}return"-"+this.negate().toString(b)}for(var f=n.math.Long.fromNumber(Math.pow(b,6)),e=this,g="";;){var h=e.div(f),i=e.subtract(h.multiply(f)).toInt(),j=i.toString(b);if(e=h,e.isZero())return j+g;for(;j.length<6;)j="0"+j;g=""+j+g}},n.math.Long.prototype.getHighBits=function(){return this.high_},n.math.Long.prototype.getLowBits=function(){return this.low_},n.math.Long.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:n.math.Long.TWO_PWR_32_DBL_+this.low_},n.math.Long.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.math.Long.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var a=0!=this.high_?this.high_:this.low_,b=31;b>0&&0==(a&1<0},n.math.Long.prototype.greaterThanOrEqual=function(a){return this.compare(a)>=0},n.math.Long.prototype.compare=function(a){if(this.equals(a))return 0;var b=this.isNegative(),c=a.isNegative();return b&&!c?-1:!b&&c?1:this.subtract(a).isNegative()?-1:1},n.math.Long.prototype.negate=function(){return this.equals(n.math.Long.MIN_VALUE)?n.math.Long.MIN_VALUE:this.not().add(n.math.Long.ONE)},n.math.Long.prototype.add=function(a){var b=this.high_>>>16,c=65535&this.high_,d=this.low_>>>16,e=65535&this.low_,f=a.high_>>>16,g=65535&a.high_,h=a.low_>>>16,i=65535&a.low_,j=0,k=0,l=0,m=0;return m+=e+i,l+=m>>>16,m&=65535,l+=d+h,k+=l>>>16,l&=65535,k+=c+g,j+=k>>>16,k&=65535,j+=b+f,j&=65535,n.math.Long.fromBits(l<<16|m,j<<16|k)},n.math.Long.prototype.subtract=function(a){return this.add(a.negate())},n.math.Long.prototype.multiply=function(a){if(this.isZero())return n.math.Long.ZERO;if(a.isZero())return n.math.Long.ZERO;if(this.equals(n.math.Long.MIN_VALUE))return a.isOdd()?n.math.Long.MIN_VALUE:n.math.Long.ZERO;if(a.equals(n.math.Long.MIN_VALUE))return this.isOdd()?n.math.Long.MIN_VALUE:n.math.Long.ZERO;if(this.isNegative())return a.isNegative()?this.negate().multiply(a.negate()):this.negate().multiply(a).negate();if(a.isNegative())return this.multiply(a.negate()).negate();if(this.lessThan(n.math.Long.TWO_PWR_24_)&&a.lessThan(n.math.Long.TWO_PWR_24_))return n.math.Long.fromNumber(this.toNumber()*a.toNumber());var b=this.high_>>>16,c=65535&this.high_,d=this.low_>>>16,e=65535&this.low_,f=a.high_>>>16,g=65535&a.high_,h=a.low_>>>16,i=65535&a.low_,j=0,k=0,l=0,m=0;return m+=e*i,l+=m>>>16,m&=65535,l+=d*i,k+=l>>>16,l&=65535,l+=e*h,k+=l>>>16,l&=65535,k+=c*i,j+=k>>>16,k&=65535,k+=d*h,j+=k>>>16,k&=65535,k+=e*g,j+=k>>>16,k&=65535,j+=b*i+c*h+d*g+e*f,j&=65535,n.math.Long.fromBits(l<<16|m,j<<16|k)},n.math.Long.prototype.div=function(a){if(a.isZero())throw Error("division by zero");if(this.isZero())return n.math.Long.ZERO;if(this.equals(n.math.Long.MIN_VALUE)){if(a.equals(n.math.Long.ONE)||a.equals(n.math.Long.NEG_ONE))return n.math.Long.MIN_VALUE;if(a.equals(n.math.Long.MIN_VALUE))return n.math.Long.ONE;var b=this.shiftRight(1),c=b.div(a).shiftLeft(1);if(c.equals(n.math.Long.ZERO))return a.isNegative()?n.math.Long.ONE:n.math.Long.NEG_ONE;var d=this.subtract(a.multiply(c)),e=c.add(d.div(a));return e}if(a.equals(n.math.Long.MIN_VALUE))return n.math.Long.ZERO;if(this.isNegative())return a.isNegative()?this.negate().div(a.negate()):this.negate().div(a).negate();if(a.isNegative())return this.div(a.negate()).negate();for(var f=n.math.Long.ZERO,d=this;d.greaterThanOrEqual(a);){for(var c=Math.max(1,Math.floor(d.toNumber()/a.toNumber())),g=Math.ceil(Math.log(c)/Math.LN2),h=48>=g?1:Math.pow(2,g-48),i=n.math.Long.fromNumber(c),j=i.multiply(a);j.isNegative()||j.greaterThan(d);)c-=h,i=n.math.Long.fromNumber(c),j=i.multiply(a);i.isZero()&&(i=n.math.Long.ONE),f=f.add(i),d=d.subtract(j)}return f},n.math.Long.prototype.modulo=function(a){return this.subtract(this.div(a).multiply(a))},n.math.Long.prototype.not=function(){return n.math.Long.fromBits(~this.low_,~this.high_)},n.math.Long.prototype.and=function(a){return n.math.Long.fromBits(this.low_&a.low_,this.high_&a.high_)},n.math.Long.prototype.or=function(a){return n.math.Long.fromBits(this.low_|a.low_,this.high_|a.high_)},n.math.Long.prototype.xor=function(a){return n.math.Long.fromBits(this.low_^a.low_,this.high_^a.high_)},n.math.Long.prototype.shiftLeft=function(a){if(a&=63,0==a)return this;var b=this.low_;if(32>a){var c=this.high_;return n.math.Long.fromBits(b<>>32-a)}return n.math.Long.fromBits(0,b<a){var c=this.low_;return n.math.Long.fromBits(c>>>a|b<<32-a,b>>a)}return n.math.Long.fromBits(b>>a-32,b>=0?0:-1)},n.math.Long.prototype.shiftRightUnsigned=function(a){if(a&=63,0==a)return this;var b=this.high_;if(32>a){var c=this.low_;return n.math.Long.fromBits(c>>>a|b<<32-a,b>>>a)}return 32==a?n.math.Long.fromBits(b,0):n.math.Long.fromBits(b>>>a-32,0)},d(c).trigger("spritz_loaded_internal"),d(c).trigger("spritz_loaded")}(window.SPRITZ=window.SPRITZ||{},window,document,window.jQuery);