Author: ygrego Date: 2015-04-07 07:57:34 +0000 (Tue, 07 Apr 2015) New Revision: 1079 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1079 Log: Addition of following properties: "_timerManager", "_timeout". Modified: oipf/js/impl/model/SearchResults.js Modified: oipf/js/impl/model/SearchResults.js =================================================================== --- oipf/js/impl/model/SearchResults.js 2015-04-03 14:50:18 UTC (rev 1078) +++ oipf/js/impl/model/SearchResults.js 2015-04-07 07:57:34 UTC (rev 1079) @@ -48,6 +48,8 @@ _search: null, init: function(search) { + this._timerManager = new TimerManager(); + this._timeout = this._timerManager.createTimer.bind(this._timerManager, 0); this._search = search; this.lentgh = 0; this.totalSize = 0; @@ -71,51 +73,55 @@ var programmes = this._search._searchManager._metadata; - var startTime = this._currentQuery.startTime; + if (this._currentQuery && programmes) { + var startTime = this._currentQuery.startTime; - for (var i = 0; i< programmes.length; i++) { - var programme = programmes[i]; - var currentDate = new Date(); - /* - * The user searches information on the current program, broadcasted on the current channel. - * In this case don't need start time of program, the search must be proceeded on current time. - */ - if (startTime == null) { - if (programme.duration) { - var stopTime = startTime + programme.duration; - if (currentDate.getTime() >= startTime && currentDate.getTime() <= stopTime) { - console.log("[INFO] Program found."); - // Usefull to retrieve severals programs when user wants more than one programmes information. - var currentProgramIndex = i; - break; + for (var i = 0; i< programmes.length; i++) { + var programme = programmes[i]; + var currentDate = new Date(); + /* + * The user searches information on the current program, broadcasted on the current channel. + * In this case don't need start time of program, the search must be proceeded on current time. + */ + if (startTime == null) { + if (programme.duration) { + var stopTime = startTime + programme.duration; + if (currentDate.getTime() >= startTime && currentDate.getTime() <= stopTime) { + console.log("[INFO] Program found."); + // Usefull to retrieve severals programs when user wants more than one programmes information. + var currentProgramIndex = i; + break; + } } - } - } else { //The search use the start time like a filter to retrieve the required program information. + } else { //The search use the start time like a filter to retrieve the required program information. - if (currentDate.getTime() == startTime) { - currentProgramIndex = i; - break; + if (currentDate.getTime() == startTime) { + currentProgramIndex = i; + break; + } } + console.log("[INFO] Program not yet found."); } - console.log("[INFO] Program not yet found."); - } - - var self = this; - setTimeout(function() { - console.log("<<<<<<<<<<<<<<", new Date(), ">>>>>>>>>>>>>>>>", currentProgramIndex); - //When user want more than one result into his search. - if (currentProgramIndex != undefined) { - for (var i = 0; i < count; i++) { - self.push(programmes[currentProgramIndex]); - currentProgramIndex++; + + var self = this; + setTimeout(function() { + console.log("<<<<<<<<<<<<<<", new Date(), ">>>>>>>>>>>>>>>>", currentProgramIndex); + //When user want more than one result into his search. + if (currentProgramIndex != undefined) { + for (var i = 0; i < count; i++) { + self.push(programmes[currentProgramIndex]); + currentProgramIndex++; + } + self._search._searchManager.onMetadataSearch && self._search._searchManager.onMetadataSearch(self._search, 0); + } else { + self._search._searchManager.onMetadataSearch && self._search._searchManager.onMetadataSearch(self._search, 4); } - self._search._searchManager.onMetadataSearch && self._search._searchManager.onMetadataSearch(self._search, 0); - } else { - self._search._searchManager.onMetadataSearch && self._search._searchManager.onMetadataSearch(self._search, 4); - } + + }, 0); + } else { - }, 0); + } return false; },