From 1d32cce1d5a21d5a649419bf323ab635534c3977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E4=B8=9E=E5=AE=8F?= Date: Sun, 7 Aug 2016 14:52:17 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8A=A0=E5=90=88=E6=88=90=E7=9A=84jsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GuanKiann/HuatIm/HapSing.jsx | 29 +++++++++++++++++++++++++++++ src/GuanKiann/HuatIm/HuatIm.jsx | 8 +++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/GuanKiann/HuatIm/HapSing.jsx diff --git a/src/GuanKiann/HuatIm/HapSing.jsx b/src/GuanKiann/HuatIm/HapSing.jsx new file mode 100644 index 00000000..32e34538 --- /dev/null +++ b/src/GuanKiann/HuatIm/HapSing.jsx @@ -0,0 +1,29 @@ +import React from 'react'; + +import Debug from 'debug'; + +var debug = Debug('itaigi:HapSing'); + +export default class HapSing extends React.Component { + + play(id) { + debug('play') + document.getElementById(id).play(); + } + + render() { + var id = this.props.音標; + return ( +
+ + +
+ ); + } +}; diff --git a/src/GuanKiann/HuatIm/HuatIm.jsx b/src/GuanKiann/HuatIm/HuatIm.jsx index 8f015892..1b866c3a 100644 --- a/src/GuanKiann/HuatIm/HuatIm.jsx +++ b/src/GuanKiann/HuatIm/HuatIm.jsx @@ -6,6 +6,7 @@ import Transmit from 'react-transmit'; import Promise from 'bluebird'; var superagent = require('superagent-promise')(require('superagent'), Promise); import SoundsMapping from './SoundsMapping'; +import HapSing from './HapSing' import Debug from 'debug'; var debug = Debug('itaigi:HuatIm'); @@ -17,13 +18,14 @@ export default class HuatIm extends React.Component { } render() { - if (!this.props.suData.屬性內容.音標) { + let {音標}=this.props.suData.屬性內容; + if (!音標) { return
; } - var id = SoundsMapping.map(this.props.suData.屬性內容.音標); + let id = SoundsMapping.map(音標); if (id === undefined) { - return
; + return ; } return ( From 0a02c56feef839d11ed036c168dfafe01f92dab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E4=B8=9E=E5=AE=8F?= Date: Sun, 7 Aug 2016 17:01:54 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=9C=89=E6=B3=95=E5=BA=A6=E7=99=BC?= =?UTF-8?q?=E9=9F=B3=E7=9F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GuanKiann/HuatIm/HapSing.jsx | 49 +++++++++++++++++++++++++++----- src/GuanKiann/HuatIm/HuatIm.jsx | 4 +-- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/GuanKiann/HuatIm/HapSing.jsx b/src/GuanKiann/HuatIm/HapSing.jsx index 32e34538..3b00cbed 100644 --- a/src/GuanKiann/HuatIm/HapSing.jsx +++ b/src/GuanKiann/HuatIm/HapSing.jsx @@ -1,25 +1,47 @@ import React from 'react'; +import Transmit from 'react-transmit'; +import Promise from 'bluebird'; +var superagent = require('superagent-promise')(require('superagent'), Promise); import Debug from 'debug'; var debug = Debug('itaigi:HapSing'); -export default class HapSing extends React.Component { +class HapSing extends React.Component { + + constructor(props) { + super(props); + this.state = { + id: Math.random().toString(36), + }; + } + + componentWillMount() { + this.props.setQueryParams(this.props); + } + + componentWillReceiveProps(nextProps) { + if (nextProps.params === this.props.params) return; + this.props.setQueryParams(nextProps); + } play(id) { - debug('play') + debug('play', id); + document.getElementById(id).load(); document.getElementById(id).play(); } render() { - var id = this.props.音標; + debug('標漢字音標', this.props.標漢字音標); return (
-