From 633f117e0cef68fa0ff366c3a51f9c947e35f790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EA=B2=BD=EB=AF=BC?= Date: Thu, 8 Aug 2013 17:45:25 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebFM/js/fm.js | 116 ++++++++++++++++++++++++------------------ WebFM/manifest.webapp | 4 +- 2 files changed, 68 insertions(+), 52 deletions(-) diff --git a/WebFM/js/fm.js b/WebFM/js/fm.js index 64a85d4..3cf6ea4 100644 --- a/WebFM/js/fm.js +++ b/WebFM/js/fm.js @@ -10,39 +10,6 @@ function $$(expr) { // XXX fake mozFMRadio object for UI testing on PC var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { - curLocation: null, - latitude: null, - longitude: null, - stationFreqByLocation: { - "서울특별시" : { - "91.9" : "S00001", - "95.9" : "S00002" - }, - "제주시" : { - "90.5" : "S00001", - "97.9" : "S00002" - } - }, - stationCode: { - "S00001" : "MBC FM4U", - "S00002" : "MBC 표준FM", - "S00003" : "SBS 파워FM", - "S00004" : "SBS 러브FM" - }, - timeTable: { - "S00001" : [ - "1600|오후의 발견, 스윗소로우 입니다", - "1800|배철수의 음악캠프", - "2200|로이킴, 정준영의 친한친구" - ], - "S00002" : [ - "1800|뉴스", - "1805|왕상한의 세계는 우리는(1,2부)", - "1900|뉴스포커스", - "1920|왕산한의 세계는 우리는(3,4부)", - "2000|뉴스데스크" - ] - }, speakerEnabled: false, frequency: null, @@ -115,7 +82,7 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { } this._seekRequest = {}; this._seekTimeout = window.setTimeout(function su_timeout() { - self.setFrequency(self.frequency + 0.5); + self.setFrequency(self.frequency + self.channelWidth); if (self._seekRequest.onsuccess) { self._seekRequest.onsuccess(); } @@ -131,7 +98,7 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { } this._seekRequest = {}; this._seekTimeout = window.setTimeout(function sd_timeout() { - self.setFrequency(self.frequency - 0.5); + self.setFrequency(self.frequency - self.channelWidth); if (self._seekRequest.onsuccess) { self._seekRequest.onsuccess(); } @@ -160,6 +127,43 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { this._seekRequest.onerror(); this._seekRequest = null; } + } +}; + +// add custom variables +var mozFMRadioCustomData = { + curLocation: null, + latitude: null, + longitude: null, + stationFreqByLocation: { + "서울특별시" : { + "91.9" : "S00001", + "95.9" : "S00002" + }, + "제주시" : { + "90.1" : "S00001", + "97.9" : "S00002" + } + }, + stationCode: { + "S00001" : "MBC FM4U", + "S00002" : "MBC 표준FM", + "S00003" : "SBS 파워FM", + "S00004" : "SBS 러브FM" + }, + timeTable: { + "S00001" : [ + "1600|오후의 발견, 스윗소로우 입니다", + "1800|배철수의 음악캠프", + "2000|로이킴, 정준영의 친한친구" + ], + "S00002" : [ + "1800|뉴스", + "1805|왕상한의 세계는 우리는(1,2부)", + "1900|뉴스포커스", + "1920|왕산한의 세계는 우리는(3,4부)", + "2000|뉴스데스크" + ] }, setCurrentLocation: function(strLocation) { @@ -171,10 +175,12 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { }, setCurrentLatitude: function(latitude) { + console.log( "setCurrentLatitude :", latitude ); this.latitude = latitude; }, setCurrentLongitude: function(longitude) { + console.log( "setCurrentLongitude :", longitude ); this.longitude = longitude; }, @@ -187,12 +193,16 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { }, getStationCode: function() { - var loc = this.curLocation.split('|'); - var freq = this.frequency; - var areaInfo = this.stationFreqByLocation[loc[1]] || this.stationFreqByLocation[loc[0]]; + var stationCode = null; - if( !!areaInfo && areaInfo[freq] ) { - stationCode = areaInfo[freq]; + if( !!this.curLocation ) { + var loc = this.curLocation.split('|'); + var freq = mozFMRadio.frequency; + var areaInfo = this.stationFreqByLocation[loc[1]] || this.stationFreqByLocation[loc[0]]; + + if( !!areaInfo && areaInfo[freq] ) { + stationCode = areaInfo[freq]; + } } return stationCode; }, @@ -204,6 +214,11 @@ var mozFMRadio = navigator.mozFM || navigator.mozFMRadio || { if( !!_timeTable ) { for( var i=0, len=_timeTable.length ; i