UNPKG

unserver-unify

Version:

59 lines (53 loc) 1.49 kB
angular.module('bamboo.course').controller('BishunChapterCtrl', function( $stateParams, ApiService) { this.cid = $stateParams.cid; console.log("--- BishunChapterCtrl"); var self = this; var resUrl = ApiService.SHOST + '/lcourse/' + this.cid + '/resources/'; this.index=0; this.currentPPT; this.init = function(chapter) { self.chapter = chapter; resUrl = ApiService.SHOST + '/lcourse/' + self.chapter.cid + '/resources/'; console.log(self.chapter); self.show(0); } this.code; var myAudio this.playWord=function(word){ var file = self.chapter.libs[word]; if (!file) { return; } var filename = resUrl + file; try { // var myAudio = new Audio(filename); if(!myAudio){ myAudio = new Audio(filename); }else{ myAudio.pause(); myAudio.src=filename; } myAudio.play(); } catch (e) {} } this.nextPage=function(){ self.index++; if(self.index>=self.chapter.ppts.length){ self.index=0; } self.show(self.index); } this.lastPage=function(){ self.index--; if(self.index<0){ self.index=self.chapter.ppts.length-1; } self.show(self.index); } this.show=function(index){ self.index=index; self.currentPPT=self.chapter.ppts[index]; self.currentPPT.code=self.currentPPT.word.charCodeAt(0).toString(16); self.playWord(self.currentPPT.word); } });