(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("prop-types"), require("react"), require("axios")); else if(typeof define === 'function' && define.amd) define(["prop-types", "react", "axios"], factory); else { var a = typeof exports === 'object' ? factory(require("prop-types"), require("react"), require("axios")) : factory(root["prop-types"], root["react"], root["axios"]); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_33__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/dest/"; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 358); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_0__; /***/ }), /***/ 1: /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_1__; /***/ }), /***/ 10: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = AnueLink; /** * Get the corresponding url. * @param {*} env prod | stage | beta | int */ function AnueLink(env) { var isProd = env === 'prod'; var isApiProd = env !== 'int' && env !== 'beta'; var cnyesBaseUrl = isProd ? 'cnyes.com' : env + '.cnyes.cool'; var cookieDomain = isProd ? '.cnyes.com' : '.cnyes.cool'; var apiBaseUrl = isApiProd ? 'cnyes.com' : env + '.cnyes.cool'; var wwwChannelLink = 'https://www.' + cnyesBaseUrl; var newsChannelLink = 'https://news.' + cnyesBaseUrl; var cryptoChannelLink = 'https://crypto.' + cnyesBaseUrl; var fundChannelLink = 'https://fund.' + cnyesBaseUrl; var stockTalk = 'https://stock.' + cnyesBaseUrl; var globalStockTalk = 'https://global-stock.' + cnyesBaseUrl; var invest = 'https://invest.' + cnyesBaseUrl; var desktopFundsSearch = fundChannelLink + '/search'; var mobileFundsSearch = invest + '/funds/search'; var forexChannelLink = wwwChannelLink + '/forex/reuters'; var forexCrossListLink = wwwChannelLink + '/forex/crosslist'; var cryptoChannelBTCLink = cryptoChannelLink + '/BTC/24h'; var wdStockNewsLink = newsChannelLink + '/news/cat/wd_stock'; var forexNewsLink = newsChannelLink + '/news/cat/forex'; var cryptoNewsLink = newsChannelLink + '/news/cat/bc_virtual'; var bcNewsLink = newsChannelLink + '/news/cat/bc'; var fundNewsLink = newsChannelLink + '/news/cat/fund'; var twStockNewsLink = newsChannelLink + '/news/cat/tw_stock'; var usStockNewsLink = newsChannelLink + '/news/cat/us_stock'; var cnStockNewsLink = newsChannelLink + '/news/cat/cn_stock'; var driverFundDetailLink = invest + '/funds/detail'; var driverPageLink = invest + '/drivers'; var forexDetailPageLink = invest + '/forex/detail'; var newsTagLink = newsChannelLink + '/tag'; var newsDetailLink = newsChannelLink + '/news/id'; var hotTagsApiUrl = 'https://api.' + apiBaseUrl + '/api/v1/news/recommend/tags'; var hotDriversApiUrl = 'https://driver.api.' + apiBaseUrl + '/driver/api/v1/drivers?order=1y&sort=desc&page=1&size=3'; var hotTradesApiUrl = 'https://ws.api.' + apiBaseUrl + '/ws/api/v1/ga/pageViewHot'; // limit the categories for first version var anueSearchAllApiUrl = 'https://ess.api.' + apiBaseUrl + '/ess/api/v1/siteSearch/main?category=TWS_STOCK,FUND,US,G_INDEX,CC&q='; // .net link only have prod env var wdStockChannelLink = 'https://www.cnyes.com/global/IndexImmediateQuotedPrice/'; var archiveUSStock = 'https://www.cnyes.com/archive/usastock/'; var archiveTWStock = 'https://www.cnyes.com/archive/twstock'; var toUrlParams = function toUrlParams(params) { return Object.keys(params).filter(function (key) { return !!params[key]; }).map(function (key) { return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]); }).join('&'); }; /** * https://cnyesrd.atlassian.net/wiki/spaces/PS/pages/637993057 * symbol = [market]:[xxx]:[mType] * objectType: 主要用來區分是否為基金商品 *exception: /ga/pageViewHot 回覆在 market 欄位而非 objectType * type: 無法從 symbol 區分出來的細分類, 如 ETF */ return { generateStockLinkBySymbol: function generateStockLinkBySymbol(symbol) { var symbolSplit = String(symbol).split(':'); if (!symbolSplit || symbolSplit.length < 2) { return ''; } if ((symbolSplit[0] === 'TWF' || symbolSplit[0] === 'GF') && symbolSplit[2] === 'FUTURES') { return invest + '/futures/' + symbolSplit[0] + '/' + symbolSplit[1]; } if ((symbolSplit[0] === 'TWS' || symbolSplit[0] === 'GI') && symbolSplit[2] === 'INDEX') { return invest + '/index/' + symbolSplit[0] + '/' + symbolSplit[1]; } if ((symbolSplit[0] === 'TWS' || symbolSplit[0] === 'TWG') && symbolSplit[2] === 'STOCK') { return invest + '/twstock/' + symbolSplit[0] + '/' + symbolSplit[1]; } if ((symbolSplit[0] === 'TWS' || symbolSplit[0] === 'TSE') && symbolSplit[2]) { // symbolSplit[2]==='STOCK' || symbolSplit[2]==='INDEX' return stockTalk + '/market/TWS:' + symbolSplit[1] + ':' + symbolSplit[2]; } if ((symbolSplit[0] === 'CNS' || symbolSplit[0] === 'HKS') && symbolSplit[2] === 'STOCK') { return globalStockTalk + '/market/' + symbol; } if (symbolSplit[0] === 'USS' && symbolSplit[2] === 'STOCK') { return invest + '/usstock/detail/' + symbolSplit[1]; } if (symbolSplit[0] === 'FX') { return forexDetailPageLink + '/' + symbolSplit[1] + '/overview'; } if (symbolSplit[0] === 'EOD') { return 'https://www.cnyes.com/futures/html5chart/' + symbolSplit[1] + '.html'; } if (symbolSplit[0] === 'CC' && symbolSplit[1]) { var crypto = symbolSplit[1]; return cryptoChannelLink + '/' + crypto; } return ''; }, generateFundLink: function generateFundLink(displayName, cnyesId) { var fundName = ('' + displayName).replace(/<(?:.|\n)*?>/gm, ''); return driverFundDetailLink + '/' + fundName + '/' + cnyesId; }, generateETFLink: function generateETFLink(symbol) { var symbolSplit = String(symbol).split(':'); if (!symbolSplit || symbolSplit.length < 2) { return ''; } if (symbolSplit[0] === 'TWS' && symbolSplit[2] === 'STOCK') { return stockTalk + '/market/TWS:' + symbolSplit[1] + ':' + symbolSplit[2]; } if (symbolSplit[0] === 'USS' && symbolSplit[2] === 'STOCK') { return invest + '/etf/us/detail/' + symbolSplit[1]; } return ''; }, generateSearchResultLink: function generateSearchResultLink(_ref) { var keyword = _ref.keyword, backLink = _ref.backLink; var params = { keyword: keyword, aink: backLink }; return wwwChannelLink + '/search/all?' + toUrlParams(params); }, generateForexLink: function generateForexLink(symbol) { var symbolSplit = String(symbol).split(':'); if (!symbolSplit || symbolSplit.length < 2) { return ''; } if (symbolSplit[0] === 'FX') { return forexDetailPageLink + '/' + symbolSplit[1] + '/overview'; } return ''; }, cnyesBaseUrl: cnyesBaseUrl, cookieDomain: cookieDomain, wwwChannelLink: wwwChannelLink, newsChannelLink: newsChannelLink, cryptoChannelLink: cryptoChannelLink, fundChannelLink: fundChannelLink, stockTalk: stockTalk, globalStockTalk: globalStockTalk, invest: invest, forexChannelLink: forexChannelLink, forexCrossListLink: forexCrossListLink, cryptoChannelBTCLink: cryptoChannelBTCLink, wdStockNewsLink: wdStockNewsLink, forexNewsLink: forexNewsLink, cryptoNewsLink: cryptoNewsLink, bcNewsLink: bcNewsLink, fundNewsLink: fundNewsLink, twStockNewsLink: twStockNewsLink, usStockNewsLink: usStockNewsLink, cnStockNewsLink: cnStockNewsLink, wdStockChannelLink: wdStockChannelLink, archiveUSStock: archiveUSStock, archiveTWStock: archiveTWStock, driverFundDetailLink: driverFundDetailLink, driverPageLink: driverPageLink, newsTagLink: newsTagLink, newsDetailLink: newsDetailLink, hotTagsApiUrl: hotTagsApiUrl, hotDriversApiUrl: hotDriversApiUrl, anueSearchAllApiUrl: anueSearchAllApiUrl, hotTradesApiUrl: hotTradesApiUrl, toUrlParams: toUrlParams, desktopFundsSearch: desktopFundsSearch, mobileFundsSearch: mobileFundsSearch }; } /***/ }), /***/ 114: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _regenerator = __webpack_require__(51); var _regenerator2 = _interopRequireDefault(_regenerator); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = __webpack_require__(1); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(0); var _propTypes2 = _interopRequireDefault(_propTypes); var _bind = __webpack_require__(2); var _bind2 = _interopRequireDefault(_bind); var _AnueSearchInput = __webpack_require__(43); var _AnueSearchInput2 = _interopRequireDefault(_AnueSearchInput); var _AnueSearchRealtimeResult = __webpack_require__(44); var _AnueSearchRealtimeResult2 = _interopRequireDefault(_AnueSearchRealtimeResult); var _AnueSearchFetch = __webpack_require__(117); var _AnueSearchFetch2 = _interopRequireDefault(_AnueSearchFetch); var _helpers = __webpack_require__(118); var _helpers2 = _interopRequireDefault(_helpers); var _debounce = __webpack_require__(119); var _debounce2 = _interopRequireDefault(_debounce); var _AnueSearch = __webpack_require__(120); var _AnueSearch2 = _interopRequireDefault(_AnueSearch); var _anueLink = __webpack_require__(10); var _anueLink2 = _interopRequireDefault(_anueLink); var _anueCookie = __webpack_require__(56); var _anueCookie2 = _interopRequireDefault(_anueCookie); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable space-infix-ops */ var cx = _bind2.default.bind(_AnueSearch2.default); var AnueSearch = function (_Component) { _inherits(AnueSearch, _Component); function AnueSearch(props) { var _this2 = this; _classCallCheck(this, AnueSearch); var _this = _possibleConstructorReturn(this, (AnueSearch.__proto__ || Object.getPrototypeOf(AnueSearch)).call(this, props)); _this.getSearchHistory = function () { var history = _this.anueCookieSingleton.getSearchCookies(); _this.setState({ recentSearch: _this.dataHelpers.recentSearchDataHelper(history) }); }; _this.storeSearchHistory = function (string, shouldDelete) { var _this$props = _this.props, maxRecentHistory = _this$props.maxRecentHistory, apiEnv = _this$props.apiEnv; _this.anueCookieSingleton.setSearchCookies({ string: string, shouldDelete: shouldDelete, cookieLimit: maxRecentHistory, env: apiEnv }); _this.getSearchHistory(); }; _this.removeAllTags = function () { var apiEnv = _this.props.apiEnv; _this.anueCookieSingleton.removeSearchCookies({ env: apiEnv }); _this.getSearchHistory(); }; _this.handleClickRecentTag = function (tagName) { var aink = _this.props.aink; var link = _this.anueUrlSingleton.generateSearchResultLink({ keyword: tagName, backLink: aink }); location.href = link; }; _this.handleClickHotTag = function (tag) { if (tag && tag.tagName) { var keyword = tag.tagName; _this.inputRef.value = keyword; _this.inputRef.focus(); _this.handleSearchChange(keyword); } }; _this.handleClickRemoveTag = function (tagName) { _this.storeSearchHistory(tagName, true); }; _this.handleFetch = (0, _debounce2.default)(_asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { var searchString, rawResult, result; return _regenerator2.default.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: searchString = _this.state.searchString; _context.next = 3; return _this.request.get('' + _this.anueUrlSingleton.anueSearchAllApiUrl + encodeURIComponent(searchString)); case 3: rawResult = _context.sent; result = _this.dataHelpers.searchTradesResponseHelper(rawResult); if (result && (result.quoteFunds || result.news || result.oldDrivers)) { _this.setState({ tradeResult: result.quoteFunds, newsResult: result.news, driversResult: result.oldDrivers }); } case 6: case 'end': return _context.stop(); } } }, _callee, _this2); })), 250); _this.handleSearchChange = function (value) { var onInputChange = _this.props.onInputChange; _this.setState({ searchString: value }); onInputChange(value); _this.handleFetch(); }; _this.handlePressEnter = function () { var _this$props2 = _this.props, onInputPressEnter = _this$props2.onInputPressEnter, aink = _this$props2.aink; var searchString = _this.state.searchString; onInputPressEnter(); if (!!searchString && typeof window !== 'undefined') { _this.storeSearchHistory(searchString); var link = _this.anueUrlSingleton.generateSearchResultLink({ keyword: searchString, backLink: aink }); location.href = link; } }; _this.handleClickSearchIcon = function () { var _this$props3 = _this.props, onIconClick = _this$props3.onIconClick, aink = _this$props3.aink; var _this$state = _this.state, searchString = _this$state.searchString, hover = _this$state.hover; onIconClick(); if (!!searchString && typeof window !== 'undefined') { _this.storeSearchHistory(searchString); var link = _this.anueUrlSingleton.generateSearchResultLink({ keyword: searchString, backLink: aink }); location.href = link; } if (hover) { _this.setState({ hover: false }); } }; _this.handleClickBackIcon = function () { var onBackIconClick = _this.props.onBackIconClick; _this.setState({ hover: false }); onBackIconClick(); }; _this.handleClickResultRow = function () { var searchString = _this.state.searchString; if (!!searchString && typeof window !== 'undefined') { _this.storeSearchHistory(searchString); } }; _this.handleSearchOnFocus = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { var onInputFocus, _this$state2, hotTags, hotTrades, hotDrivers, _hotTrades, _hotTags, _hotDrivers; return _regenerator2.default.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: onInputFocus = _this.props.onInputFocus; _this$state2 = _this.state, hotTags = _this$state2.hotTags, hotTrades = _this$state2.hotTrades, hotDrivers = _this$state2.hotDrivers; _this.setState({ hover: true }); onInputFocus(); if (!(!hotTags && !hotTrades && !hotDrivers)) { _context2.next = 16; break; } _context2.next = 7; return _this.request.get(_this.anueUrlSingleton.hotTradesApiUrl); case 7: _hotTrades = _context2.sent; _context2.next = 10; return _this.request.get(_this.anueUrlSingleton.hotTagsApiUrl); case 10: _hotTags = _context2.sent; _context2.next = 13; return _this.request.get(_this.anueUrlSingleton.hotDriversApiUrl); case 13: _hotDrivers = _context2.sent; _this.getSearchHistory(); _this.setState({ hotTags: _this.dataHelpers.hotTagsResponseHelper(_hotTags), hotTrades: _this.dataHelpers.hotTradesResponseHelper(_hotTrades), hotDrivers: _this.dataHelpers.hotDriversResponseHelper(_hotDrivers) }); case 16: case 'end': return _context2.stop(); } } }, _callee2, _this2); })); _this.handleHideSearchResult = function () { var hover = _this.state.hover; if (hover) { _this.setState({ hover: false }); } }; _this.handleSearchOnBlur = function () { var onInputBlur = _this.props.onInputBlur; onInputBlur(); }; _this.handleStopWrapperClickPropagation = function (e) { e.stopPropagation(); }; var defaultSearchString = props.defaultValue || ''; if (typeof window !== 'undefined' && props.defaultValue === null) { var keywordQueryStringRegex = location.search && decodeURIComponent(location.search).match(/keyword=([^&]*)/); if (keywordQueryStringRegex && keywordQueryStringRegex[1]) { defaultSearchString = keywordQueryStringRegex[1]; } } _this.state = { isInputHidden: false, isInputFocus: false, hotTags: null, hotTrades: null, recentSearch: null, hotDrivers: null, searchString: defaultSearchString, tradeResult: null, newsResult: null, driversResult: null, hover: false }; _this.request = new _AnueSearchFetch2.default(); _this.anueUrlSingleton = new _anueLink2.default(props.apiEnv); _this.anueCookieSingleton = new _anueCookie2.default(props.apiEnv); _this.dataHelpers = (0, _helpers2.default)(_this.anueUrlSingleton); return _this; } _createClass(AnueSearch, [{ key: 'componentDidMount', value: function componentDidMount() { if (typeof window !== 'undefined') { // The clicked event of AnueSearch is set to stopPropagation. // So click the anywhere outside of AnueSearch will hide the AnueRealtimeResult. window.addEventListener('click', this.handleHideSearchResult); } } }, { key: 'componentDidUpdate', value: function componentDidUpdate(prevPrev, prevState) { var theme = this.props.theme; var hover = this.state.hover; if (typeof window !== 'undefined' && prevState.hover !== hover) { var bodyStyles = document.body.style; var screenWidth = window.innerWidth || document.documentElement.clientWidth; var isSmallMode = theme === 'mobile' || screenWidth < _AnueSearch2.default.mobileScreenWidth; if (hover && isSmallMode) { document.body.style.overflowY = 'hidden'; } else if (bodyStyles) { document.body.style.overflowY = 'auto'; } } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { window.removeEventListener('click', this.handleHideSearchResult); } }, { key: 'render', value: function render() { var _this3 = this; var _props = this.props, theme = _props.theme, shouldAlwaysDisplayInput = _props.shouldAlwaysDisplayInput, shouldDisplayBackIcon = _props.shouldDisplayBackIcon, placeholder = _props.placeholder, customAttribute = _props.customAttribute, customWrapperStyles = _props.customWrapperStyles, customInputWrapperStyles = _props.customInputWrapperStyles, customResultWrapperStyles = _props.customResultWrapperStyles, customInputStyles = _props.customInputStyles, customIconStyles = _props.customIconStyles, onSearchVisibilityChange = _props.onSearchVisibilityChange, aink = _props.aink; var _state = this.state, hotTags = _state.hotTags, hotTrades = _state.hotTrades, hotDrivers = _state.hotDrivers, recentSearch = _state.recentSearch, searchString = _state.searchString, hover = _state.hover, tradeResult = _state.tradeResult, newsResult = _state.newsResult, driversResult = _state.driversResult; var searchResultLink = this.anueUrlSingleton.generateSearchResultLink({ keyword: searchString, backLink: aink }); return _react2.default.createElement( 'div', { className: cx('anue-search', theme), style: customWrapperStyles, onClick: this.handleStopWrapperClickPropagation }, _react2.default.createElement( 'div', { className: cx('input-wrapper', { active: hover }) }, _react2.default.createElement(_AnueSearchInput2.default, { theme: theme, placeholder: placeholder, onInputChange: this.handleSearchChange, onInputFocus: this.handleSearchOnFocus, onInputBlur: this.handleSearchOnBlur, onInputPressEnter: this.handlePressEnter, onIconClick: this.handleClickSearchIcon, onBackIconClick: this.handleClickBackIcon, shouldAlwaysDisplayInput: shouldAlwaysDisplayInput || !!searchString, shouldDisplayBackIcon: shouldDisplayBackIcon, defaultValue: searchString, customWrapperStyles: customInputWrapperStyles, customInputStyles: customInputStyles, customIconStyles: customIconStyles, onDisplayChange: onSearchVisibilityChange, customAttribute: _extends({}, customAttribute, { ref: function ref(input) { _this3.inputRef = input; } }) }) ), _react2.default.createElement( 'div', { className: cx('search-result', theme, { display: hover }) }, _react2.default.createElement(_AnueSearchRealtimeResult2.default, { hotTags: hotTags, hotTrades: hotTrades, hotDrivers: hotDrivers, recentSearch: recentSearch, searchString: searchString, tradeResult: tradeResult, newsResult: newsResult, driversResult: driversResult, onHotTagClick: this.handleClickHotTag, onRecentSearchRowClick: this.handleClickRecentTag, onRecentSearchRowRemoveClick: this.handleClickRemoveTag, onRecentSearchRemoveAllClick: this.removeAllTags, onResultSearchRowClick: this.handleClickResultRow, customWrapperStyles: customResultWrapperStyles, searchResultPageLink: searchResultLink }) ) ); } }]); return AnueSearch; }(_react.Component); AnueSearch.defaultProps = { maxRecentHistory: 10, theme: null, customAttribute: null, customWrapperStyles: null, customInputWrapperStyles: null, customResultWrapperStyles: null, customInputStyles: null, customIconStyles: null, customInputClassName: null, customResultClassName: null, shouldAlwaysDisplayInput: false, shouldDisplayBackIcon: false, placeholder: '搜尋新聞、代碼或名稱', onIconClick: function onIconClick() {}, onBackIconClick: function onBackIconClick() {}, onInputChange: function onInputChange() {}, onInputFocus: function onInputFocus() {}, onInputBlur: function onInputBlur() {}, onInputPressEnter: function onInputPressEnter() {}, onSearchVisibilityChange: function onSearchVisibilityChange() {}, apiEnv: 'prod', aink: null, defaultValue: null }; exports.default = AnueSearch; /***/ }), /***/ 115: /***/ (function(module, exports, __webpack_require__) { /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // This method of obtaining a reference to the global object needs to be // kept identical to the way it is obtained in runtime.js var g = (function() { return this })() || Function("return this")(); // Use `getOwnPropertyNames` because not all browsers support calling // `hasOwnProperty` on the global `self` object in a worker. See #183. var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; // Save the old regeneratorRuntime in case it needs to be restored later. var oldRuntime = hadRuntime && g.regeneratorRuntime; // Force reevalutation of runtime.js. g.regeneratorRuntime = undefined; module.exports = __webpack_require__(116); if (hadRuntime) { // Restore the original runtime. g.regeneratorRuntime = oldRuntime; } else { // Remove the global property added by runtime.js. try { delete g.regeneratorRuntime; } catch(e) { g.regeneratorRuntime = undefined; } } /***/ }), /***/ 116: /***/ (function(module, exports) { /** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ !(function(global) { "use strict"; var Op = Object.prototype; var hasOwn = Op.hasOwnProperty; var undefined; // More compressible than void 0. var $Symbol = typeof Symbol === "function" ? Symbol : {}; var iteratorSymbol = $Symbol.iterator || "@@iterator"; var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; var inModule = typeof module === "object"; var runtime = global.regeneratorRuntime; if (runtime) { if (inModule) { // If regeneratorRuntime is defined globally and we're in a module, // make the exports object identical to regeneratorRuntime. module.exports = runtime; } // Don't bother evaluating the rest of this file if the runtime was // already defined globally. return; } // Define the runtime globally (as expected by generated code) as either // module.exports (if we're in a module) or a new, empty object. runtime = global.regeneratorRuntime = inModule ? module.exports : {}; function wrap(innerFn, outerFn, self, tryLocsList) { // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; var generator = Object.create(protoGenerator.prototype); var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next, // .throw, and .return methods. generator._invoke = makeInvokeMethod(innerFn, self, context); return generator; } runtime.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion // record like context.tryEntries[i].completion. This interface could // have been (and was previously) designed to take a closure to be // invoked without arguments, but in all the cases we care about we // already have an existing method we want to call, so there's no need // to create a new function object. We can even get away with assuming // the method takes exactly one argument, since that happens to be true // in every case, so we don't have to touch the arguments object. The // only additional allocation required is the completion record, which // has a stable shape and so hopefully should be cheap to allocate. function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } var GenStateSuspendedStart = "suspendedStart"; var GenStateSuspendedYield = "suspendedYield"; var GenStateExecuting = "executing"; var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as // breaking out of the dispatch switch statement. var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and // .constructor.prototype properties for functions that return Generator // objects. For full spec compliance, you may wish to configure your // minifier not to mangle the names of these two functions. function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that // don't natively support it. var IteratorPrototype = {}; IteratorPrototype[iteratorSymbol] = function () { return this; }; var getProto = Object.getPrototypeOf; var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { // This environment has a native %IteratorPrototype%; use it instead // of the polyfill. IteratorPrototype = NativeIteratorPrototype; } var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; GeneratorFunctionPrototype.constructor = GeneratorFunction; GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the // Iterator interface in terms of a single ._invoke method. function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function(method) { prototype[method] = function(arg) { return this._invoke(method, arg); }; }); } runtime.isGeneratorFunction = function(genFun) { var ctor = typeof genFun === "function" && genFun.constructor; return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can // do is to check its .name property. (ctor.displayName || ctor.name) === "GeneratorFunction" : false; }; runtime.mark = function(genFun) { if (Object.setPrototypeOf) { Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); } else { genFun.__proto__ = GeneratorFunctionPrototype; if (!(toStringTagSymbol in genFun)) { genFun[toStringTagSymbol] = "GeneratorFunction"; } } genFun.prototype = Object.create(Gp); return genFun; }; // Within the body of any async function, `await x` is transformed to // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test // `hasOwn.call(value, "__await")` to determine if the yielded value is // meant to be awaited. runtime.awrap = function(arg) { return { __await: arg }; }; function AsyncIterator(generator) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (record.type === "throw") { reject(record.arg); } else { var result = record.arg; var value = result.value; if (value && typeof value === "object" && hasOwn.call(value, "__await")) { return Promise.resolve(value.__await).then(function(value) { invoke("next", value, resolve, reject); }, function(err) { invoke("throw", err, resolve, reject); }); } return Promise.resolve(value).then(function(unwrapped) { // When a yielded Promise is resolved, its final value becomes // the .value of the Promise<{value,done}> result for the // current iteration. If the Promise is rejected, however, the // result for this iteration will be rejected with the same // reason. Note that rejections of yielded Promises are not // thrown back into the generator function, as is the case // when an awaited Promise is rejected. This difference in // behavior between yield and await is important, because it // allows the consumer to decide what to do with the yielded // rejection (swallow it and continue, manually .throw it back // into the generator, abandon iteration, whatever). With // await, by contrast, there is no opportunity to examine the // rejection reason outside the generator function, so the // only option is to throw it from the await expression, and // let the generator function handle the exception. result.value = unwrapped; resolve(result); }, reject); } } var previousPromise; function enqueue(method, arg) { function callInvokeWithMethodAndArg() { return new Promise(function(resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = // If enqueue has been called before, then we want to wait until // all previous Promises have been resolved before calling invoke, // so that results are always delivered in the correct order. If // enqueue has not been called before, then it is important to // call invoke immediately, without waiting on a callback to fire, // so that the async generator function has the opportunity to do // any necessary setup in a predictable way. This predictability // is why the Promise constructor synchronously invokes its // executor callback, and why async functions synchronously // execute code before the first await. Since we implement simple // async functions in terms of async generators, it is especially // important to get this right, even though it requires care. previousPromise ? previousPromise.then( callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later // invocations of the iterator. callInvokeWithMethodAndArg ) : callInvokeWithMethodAndArg(); } // Define the unified helper method that is used to implement .next, // .throw, and .return (see defineIteratorMethods). this._invoke = enqueue; } defineIteratorMethods(AsyncIterator.prototype); AsyncIterator.prototype[asyncIteratorSymbol] = function () { return this; }; runtime.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of // AsyncIterator objects; they just return a Promise for the value of // the final result produced by the iterator. runtime.async = function(innerFn, outerFn, self, tryLocsList) { var iter = new AsyncIterator( wrap(innerFn, outerFn, self, tryLocsList) ); return runtime.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. : iter.next().then(function(result) { return result.done ? result.value : iter.next(); }); }; function makeInvokeMethod(innerFn, self, context) { var state = GenStateSuspendedStart; return function invoke(method, arg) { if (state === GenStateExecuting) { throw new Error("Generator is already running"); } if (state === GenStateCompleted) { if (method === "throw") { throw arg; } // Be forgiving, per 25.3.3.3.3 of the spec: // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume return doneResult(); } context.method = method; context.arg = arg; while (true) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (context.method === "next") { // Setting context._sent for legacy support of Babel's // function.sent implementation. context.sent = context._sent = context.arg; } else if (context.method === "throw") { if (state === GenStateSuspendedStart) { state = GenStateCompleted; throw context.arg; } context.dispatchException(context.arg); } else if (context.method === "return") { context.abrupt("return", context.arg); } state = GenStateExecuting; var record = tryCatch(innerFn, self, context); if (record.type === "normal") { // If an exception is thrown from innerFn, we leave state === // GenStateExecuting and loop back for another invocation. state = context.done ? GenStateCompleted : GenStateSuspendedYield; if (record.arg === ContinueSentinel) { continue; } return { value: record.arg, done: context.done }; } else if (record.type === "throw") { state = GenStateCompleted; // Dispatch the exception by looping back around to the // context.dispatchException(context.arg) call above. context.method = "throw"; context.arg = record.arg; } } }; } // Call delegate.iterator[context.method](context.arg) and handle the // result, either by returning a { value, done } result from the // delegate iterator, or by modifying context.method and context.arg, // setting context.delegate to null, and returning the ContinueSentinel. function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (method === undefined) { // A .throw or .return when the delegate iterator has no .throw // method always terminates the yield* loop. context.delegate = null; if (context.method === "throw") { if (delegate.iterator.return) { // If the delegate iterator has a return method, give it a // chance to clean up. context.method = "return"; context.arg = undefined; maybeInvokeDelegate(delegate, context); if (context.method === "throw") { // If maybeInvokeDelegate(context) changed context.method from // "return" to "throw", let that override the TypeError below. return ContinueSentinel; } } context.method = "throw"; context.arg = new TypeError( "The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if (record.type === "throw") { context.method = "throw"; context.arg = record.arg; context.delegate = null; return ContinueSentinel; } var info = record.arg; if (! info) { context.method = "throw"; context.arg = new TypeError("iterator result is not an object"); context.delegate = null; return ContinueSentinel; } if (info.done) { // Assign the result of the finished delegate to the temporary // variable specified by delegate.resultName (see delegateYield). context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield). context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the // exception, let the outer generator proceed normally. If // context.method was "next", forget context.arg since it has been // "consumed" by the delegate iterator. If context.method was // "return", allow the original .return call to continue in the // outer generator. if (context.method !== "return") { context.method = "next"; context.arg = undefined; } } else { // Re-yield the result returned by the delegate method. return info; } // The delegate iterator is finished, so forget it and continue with // the outer generator. context.delegate = null; return ContinueSentinel; } // Define Generator.prototype.{next,throw,return} in terms of the // unified ._invoke helper method. defineIteratorMethods(Gp); Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the // @@iterator function is called on it. Some browsers' implementations of the // iterator prototype chain incorrectly implement this, causing the Generator // object to not be returned from this call. This ensures that doesn't happen. // See https://github.com/facebook/regenerator/issues/274 for more details. Gp[iteratorSymbol] = function() { return this; }; Gp.toString = function() { return "[object Generator]"; }; function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; if (1 in locs) { entry.catchLoc = locs[1]; } if (2 in locs) { entry.finallyLoc = locs[2]; entry.afterLoc = locs[3]; } this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal"; delete record.arg; entry.completion = record; } function Context(tryLocsList) { // The root entry object (effectively a try statement without a catch // or a finally block) gives us a place to store values thrown from // locations where there is no enclosing try statement. this.tryEntries = [{ tryLoc: "root" }]; tryLocsList.forEach(pushTryEntry, this); this.reset(true); } runtime.keys = function(object) { var keys = []; for (var key in object) { keys.push(key); } keys.reverse(); // Rather than returning an object with a next method, we keep // things simple and return the next function itself. return function next() { while (keys.length) { var key = keys.pop(); if (key in object) { next.value = key; next.done = false; return next; } } // To avoid creating an additional object, we just hang the .value // and .done properties off the next function object itself. This // also ensures that the minifier will not anonymize the function. next.done = true; return next; }; }; function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) { return iteratorMethod.call(iterable); } if (typeof iterable.next === "function") { return iterable; } if (!isNaN(iterable.length)) { var i = -1, next = function next() { while (++i < iterable.length) { if (hasOwn.call(iterable, i)) { next.value = iterable[i]; next.done = false; return next; } } next.value = undefined; next.done = true; return next; }; return next.next = next; } } // Return an iterator with no values. return { next: doneResult }; } runtime.values = values; function doneResult() { return { value: undefined, done: true }; } Context.prototype = { constructor: Context, reset: function(skipTempReset) { this.prev = 0; this.next = 0; // Resetting context._sent for legacy support of Babel's // function.sent implementation. this.sent = this._sent = undefined; this.done = false; this.delegate = null; this.method = "next"; this.arg = undefined; this.tryEntries.forEach(resetTryEntry); if (!skipTempReset) { for (var name in this) { // Not sure about the optimal order of these conditions: if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { this[name] = undefined; } } } }, stop: function() { this.done = true; var rootEntry = this.tryEntries[0]; var rootRecord = rootEntry.completion; if (rootRecord.type === "throw") { throw rootRecord.arg; } return this.rval; }, dispatchException: function(exception) { if (this.done) { throw exception; } var context = this; function handle(loc, caught) { record.type = "throw"; record.arg = exception; context.next = loc; if (caught) { // If the dispatched exception was caught by a catch block, // then let that catch block handle the exception normally. context.method = "next"; context.arg = undefined; } return !! caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; var record = entry.completion; if (entry.tryLoc === "root") { // Exception thrown outside of any try block that could handle // it, so set the completion value of the entire function to // throw the exception. return handle("end"); } if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"); var hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) { return handle(entry.catchLoc, true); } else if (this.prev < entry.finallyLoc) { return handle(entry.finallyLoc); } } else if (hasCatch) { if (this.prev < entry.catchLoc) { return handle(entry.catchLoc, true); } } else if (hasFinally) { if (this.prev < entry.finallyLoc) { return handle(entry.finallyLoc); } } else { throw new Error("try statement without catch or finally"); } } } }, abrupt: function(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { // Ignore the finally entry if control is not jumping to a // location outside the try/catch block. finallyEntry = null; } var record = finallyEntry ? finallyEntry.completion : {}; record.type = type; record.arg = arg; if (finallyEntry) { this.method = "next"; this.next = finallyEntry.finallyLoc; return ContinueSentinel; } return this.complete(record); }, complete: function(record, afterLoc) { if (record.type === "throw") { throw record.arg; } if (record.type === "break" || record.type === "continue") { this.next = record.arg; } else if (record.type === "return") { this.rval = this.arg = record.arg; this.method = "return"; this.next = "end"; } else if (record.type === "normal" && afterLoc) { this.next = afterLoc; } return ContinueSentinel; }, finish: function(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) { this.complete(entry.completion, entry.afterLoc); resetTryEntry(entry); return ContinueSentinel; } } }, "catch": function(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (record.type === "throw") { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } // The context.catch method must only be called with a location // argument that corresponds to a known catch block. throw new Error("illegal catch attempt"); }, delegateYield: function(iterable, resultName, nextLoc) { this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }; if (this.method === "next") { // Deliberately forget the last sent value so that we don't // accidentally pass it on to the delegate. this.arg = undefined; } return ContinueSentinel; } }; })( // In sloppy mode, unbound `this` refers to the global object, fallback to // Function constructor if we're in global strict mode. That is sadly a form // of indirect eval which violates Content Security Policy. (function() { return this })() || Function("return this")() ); /***/ }), /***/ 117: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _regenerator = __webpack_require__(51); var _regenerator2 = _interopRequireDefault(_regenerator); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _axios = __webpack_require__(33); var _axios2 = _interopRequireDefault(_axios); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var AnueSearchFetch = function () { function AnueSearchFetch() { _classCallCheck(this, AnueSearchFetch); this.instance = _axios2.default.create(); this.instance.interceptors.request.use(function (config) { config.headers['content-type'] = 'application/json'; // eslint-disable-line no-param-reassign // custom header: https://cnyesrd.atlassian.net/wiki/spaces/PS/pages/682622993/API config.headers['X-platform'] = 'WEB'; // eslint-disable-line no-param-reassign return config; }, function (error) { return Promise.reject(error); }); } _createClass(AnueSearchFetch, [{ key: 'get', value: function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(url, callback) { var rawResult; return _regenerator2.default.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return this.instance.request(url); case 2: rawResult = _context.sent; if (callback) callback(rawResult); return _context.abrupt('return', rawResult); case 5: case 'end': return _context.stop(); } } }, _callee, this); })); function get(_x, _x2) { return _ref.apply(this, arguments); } return get; }() }]); return AnueSearchFetch; }(); exports.default = AnueSearchFetch; /***/ }), /***/ 118: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = SearchResultHelper; var _idx = __webpack_require__(34); var _idx2 = _interopRequireDefault(_idx); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function SearchResultHelper(urlHelper) { var generateFundLink = urlHelper.generateFundLink, generateStockLinkBySymbol = urlHelper.generateStockLinkBySymbol, driverPageLink = urlHelper.driverPageLink, newsDetailLink = urlHelper.newsDetailLink; var generateTradeSearchLink = function generateTradeSearchLink(item, type) { var link = void 0; switch (type) { case 'FUND': link = generateFundLink(item.displayNameLocal || item.displayName, item.cnyesId); break; case 'QUOTE': default: link = generateStockLinkBySymbol(item.symbol); } return link; }; var hotTagsResponseHelper = function hotTagsResponseHelper(data) { var items = (0, _idx2.default)(data, function (_) { return _.data.items; }); if (!items) return []; return items.map(function (tag) { return { tagName: tag.tag, link: null }; }); }; var hotDriverDataHelper = function hotDriverDataHelper(items) { if (!items) return []; return items.map(function (driver) { return { avatarPicture: driver.avatarPicture, driverId: driver.driverId, driverName: driver.nickname, return1year: driver.return1year || driver.return1Year, link: driverPageLink + '/' + driver.driverId }; }); }; var hotDriversResponseHelper = function hotDriversResponseHelper(data) { var items = (0, _idx2.default)(data, function (_) { return _.data.items; }); if (!items) return []; return hotDriverDataHelper(items); }; var hotTradesResponseHelper = function hotTradesResponseHelper(data) { var items = (0, _idx2.default)(data, function (_) { return _.data.data; }); if (!items) return []; return items.map(function (trade) { if (trade.market === 'FUND' && !trade.cnyesId) { // eslint-disable-next-line no-param-reassign trade.cnyesId = trade.symbol; } return { symbol: trade.symbol, displayName: trade.displayName, link: generateTradeSearchLink(trade, trade.market) }; }); }; var recentSearchDataHelper = function recentSearchDataHelper(keywordArr) { if (!keywordArr) return []; return keywordArr.reverse().map(function (keyword) { return { keyword: keyword }; }); }; var searchTradesResponseHelper = function searchTradesResponseHelper(data) { var items = (0, _idx2.default)(data, function (_) { return _.data.data; }); var quoteFunds = []; var news = []; var oldDrivers = []; if (!items) { return null; } quoteFunds = items.quoteFunds && items.quoteFunds.map(function (trade) { return { objectType: trade.objectType, market: trade.market, code: trade.code || trade.displayNameLocal, type: trade.type, mtype: trade.mtype, symbol: trade.symbol, chName: trade.chName, enName: trade.enName || trade.displayName, exchange: trade.exchange, link: generateTradeSearchLink(trade, trade.objectType) }; }); news = items.news && items.news.map(function (n) { return { newsId: n.newsId, title: n.title, summary: n.summary, publishAt: n.publishAt, link: newsDetailLink + '/' + n.newsId }; }); oldDrivers = hotDriverDataHelper(items.oldDrivers); return { quoteFunds: quoteFunds, news: news, oldDrivers: oldDrivers }; }; return { generateTradeSearchLink: generateTradeSearchLink, hotTagsResponseHelper: hotTagsResponseHelper, hotDriverDataHelper: hotDriverDataHelper, hotDriversResponseHelper: hotDriversResponseHelper, hotTradesResponseHelper: hotTradesResponseHelper, recentSearchDataHelper: recentSearchDataHelper, searchTradesResponseHelper: searchTradesResponseHelper }; } /***/ }), /***/ 119: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = debounce; function debounce(fn, threshold) { var interval = void 0; return function callback() { var _arguments = arguments; clearTimeout(interval); interval = setTimeout(function () { interval = null; // eslint-disable-next-line fn(_arguments); }, threshold); }; } /***/ }), /***/ 120: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin module.exports = {"mobileScreenWidth":"1024px","anue-search":"_1sdVe","anue-search__cover":"_1VR3K","display":"_1CLsH","input-wrapper":"_2cmuD","active":"_2mEwc","search-result":"_2wJdR"}; /***/ }), /***/ 2: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2016 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ /* global define */ (function () { 'use strict'; var hasOwn = {}.hasOwnProperty; function classNames () { var classes = []; for (var i = 0; i < arguments.length; i++) { var arg = arguments[i]; if (!arg) continue; var argType = typeof arg; if (argType === 'string' || argType === 'number') { classes.push(this && this[arg] || arg); } else if (Array.isArray(arg)) { classes.push(classNames.apply(this, arg)); } else if (argType === 'object') { for (var key in arg) { if (hasOwn.call(arg, key) && arg[key]) { classes.push(this && this[key] || key); } } } } return classes.join(' '); } if (typeof module !== 'undefined' && module.exports) { module.exports = classNames; } else if (true) { // register as 'classnames', consistent with npm package name !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { return classNames; }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else { window.classNames = classNames; } }()); /***/ }), /***/ 24: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin module.exports = {"icon-template":"_aaBGP","anue-search-result":"_3RffD","content-rows":"_ROk_h","row":"_2q1sD","icon--hot":"_oBnHd","icon--time":"_CLiKU","section":"_1rK69","mark":"_1Hocp","empty":"_Qb08q","desktop":"_1zi9t","current-search":"_3UODZ","hot-tags":"_8YczV","limit-length":"_Ln_aR","result":"_qNeiO","title":"_2k0-p","summary":"_1iIba","icon-cross":"_25Jm7","content-cols":"_3Mxpd","col":"_nk_ej","avatar":"_3kV9G","name":"_NWqu6","sub-title":"_1vV3r","perf":"_MWDCy","red":"_2LbmQ","green":"_2xSXQ","search-result-content-wrapper":"_Qpfo6","display":"_37iOW","search-result-content-wrapper__header":"_GAt7c"}; /***/ }), /***/ 25: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = __webpack_require__(1); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(0); var _propTypes2 = _interopRequireDefault(_propTypes); var _bind = __webpack_require__(2); var _bind2 = _interopRequireDefault(_bind); var _LazyImage = __webpack_require__(32); var _LazyImage2 = _interopRequireDefault(_LazyImage); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var cx = _bind2.default.bind(_LazyImage2.default); var LazyImage = function (_Component) { _inherits(LazyImage, _Component); function LazyImage() { _classCallCheck(this, LazyImage); var _this = _possibleConstructorReturn(this, (LazyImage.__proto__ || Object.getPrototypeOf(LazyImage)).call(this)); _this.handleOnLoaded = function () { _this.setState({ isLoaded: true }); }; _this.source = new Image(); _this.state = { isLoaded: false }; return _this; } _createClass(LazyImage, [{ key: 'componentDidMount', value: function componentDidMount() { var src = this.props.src; this.source.addEventListener('load', this.handleOnLoaded); this.source.src = src; } }, { key: 'render', value: function render() { var _props = this.props, src = _props.src, isRounded = _props.isRounded; var isLoaded = this.state.isLoaded; return _react2.default.createElement( 'div', { className: cx('lazy-img', { loaded: isLoaded, rounded: isRounded }) }, _react2.default.createElement('img', { src: src, alt: 'Anue \u9245\u4EA8' }) ); } }]); return LazyImage; }(_react.Component); LazyImage.defaultProps = { src: null, isRounded: false }; exports.default = LazyImage; /***/ }), /***/ 31: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var numSignHelper = exports.numSignHelper = function numSignHelper(digit, _ref) { var isPercentage = _ref.isPercentage; var percentage = isPercentage ? '%' : ''; var num = '' + digit + percentage; return digit > 0 ? '+' + num : '' + num; }; exports.default = { numSignHelper: numSignHelper }; /***/ }), /***/ 32: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin module.exports = {"placeholder-background-animation":"_1fgx4","lazy-img":"_3bofm","animate":"_23bZj","loaded":"_1sb3m","rounded":"_2FkDV"}; /***/ }), /***/ 33: /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_33__; /***/ }), /***/ 34: /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ // eslint-disable-line strict /** * Traverses properties on objects and arrays. If an intermediate property is * either null or undefined, it is instead returned. The purpose of this method * is to simplify extracting properties from a chain of maybe-typed properties. * * === EXAMPLE === * * Consider the following type: * * const props: { * user: ?{ * name: string, * friends: ?Array<User>, * } * }; * * Getting to the friends of my first friend would resemble: * * props.user && * props.user.friends && * props.user.friends[0] && * props.user.friends[0].friends * * Instead, `idx` allows us to safely write: * * idx(props, _ => _.user.friends[0].friends) * * The second argument must be a function that returns one or more nested member * expressions. Any other expression has undefined behavior. * * === NOTE === * * The code below exists for the purpose of illustrating expected behavior and * is not meant to be executed. The `idx` function is used in conjunction with a * Babel transform that replaces it with better performing code: * * props.user == null ? props.user : * props.user.friends == null ? props.user.friends : * props.user.friends[0] == null ? props.user.friends[0] : * props.user.friends[0].friends * * All this machinery exists due to the fact that an existential operator does * not currently exist in JavaScript. */ function idx(input, accessor) { try { return accessor(input); } catch (error) { if (error instanceof TypeError) { if (nullPattern.test(error)) { return null; } else if (undefinedPattern.test(error)) { return undefined; } } throw error; } } /** * Some actual error messages for null: * * TypeError: Cannot read property 'bar' of null * TypeError: Cannot convert null value to object * TypeError: foo is null * TypeError: null has no properties * TypeError: null is not an object (evaluating 'foo.bar') * TypeError: null is not an object (evaluating '(" undefined ", null).bar') */ var nullPattern = /^null | null$|^[^(]* null /i; var undefinedPattern = /^undefined | undefined$|^[^(]* undefined /i; idx.default = idx; module.exports = idx; /***/ }), /***/ 358: /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(114); /***/ }), /***/ 43: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = __webpack_require__(1); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(0); var _propTypes2 = _interopRequireDefault(_propTypes); var _bind = __webpack_require__(2); var _bind2 = _interopRequireDefault(_bind); var _AnueSearchInput = __webpack_require__(52); var _AnueSearchInput2 = _interopRequireDefault(_AnueSearchInput); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var cx = _bind2.default.bind(_AnueSearchInput2.default); var AnueSearchInput = function (_React$Component) { _inherits(AnueSearchInput, _React$Component); function AnueSearchInput(props) { _classCallCheck(this, AnueSearchInput); var _this = _possibleConstructorReturn(this, (AnueSearchInput.__proto__ || Object.getPrototypeOf(AnueSearchInput)).call(this, props)); _this.setInputDefaultValue = function (value) { _this.setState({ value: value }); }; _this.handleChange = function (e) { var onInputChange = _this.props.onInputChange; var value = e.target.value; _this.setState({ value: value }); onInputChange(value); }; _this.handleClickIcon = function () { var _this$props = _this.props, onIconClick = _this$props.onIconClick, shouldAlwaysDisplayInput = _this$props.shouldAlwaysDisplayInput, onDisplayChange = _this$props.onDisplayChange; var _this$state = _this.state, value = _this$state.value, shouldDisplayInput = _this$state.shouldDisplayInput; onIconClick(value); if (!shouldAlwaysDisplayInput) { _this.setState({ shouldDisplayInput: !shouldDisplayInput }); onDisplayChange(!shouldDisplayInput); } }; _this.handleBackIcon = function () { var _this$props2 = _this.props, onDisplayChange = _this$props2.onDisplayChange, onInputChange = _this$props2.onInputChange, onBackIconClick = _this$props2.onBackIconClick; _this.setState({ shouldDisplayInput: false, value: '' }); onBackIconClick(); onInputChange(''); onDisplayChange(false); }; _this.handleKeyDown = function (e) { if (e.keyCode === 13) { var onInputPressEnter = _this.props.onInputPressEnter; var value = _this.state.value; if (value) { onInputPressEnter(value); } } }; _this.handleResetValue = function () { var onInputChange = _this.props.onInputChange; _this.setState({ value: '' }); onInputChange(''); }; _this.state = { value: props.defaultValue || '', shouldDisplayInput: props.shouldAlwaysDisplayInput || props.theme !== 'mobile' }; return _this; } _createClass(AnueSearchInput, [{ key: 'componentDidUpdate', value: function componentDidUpdate(prevProps) { if (this.props.defaultValue && prevProps.defaultValue !== this.props.defaultValue) { this.setInputDefaultValue(this.props.defaultValue); } } }, { key: 'render', value: function render() { var _props = this.props, placeholder = _props.placeholder, onInputFocus = _props.onInputFocus, onInputBlur = _props.onInputBlur, customAttribute = _props.customAttribute, customWrapperStyles = _props.customWrapperStyles, customInputStyles = _props.customInputStyles, customIconStyles = _props.customIconStyles, theme = _props.theme, customInputClassName = _props.customInputClassName, shouldDisplayBackIcon = _props.shouldDisplayBackIcon; var _state = this.state, shouldDisplayInput = _state.shouldDisplayInput, value = _state.value; var showClearBtn = value; return _react2.default.createElement( 'div', { className: cx('anue-search-input--wrapper', theme, customInputClassName), style: customWrapperStyles }, shouldDisplayBackIcon && _react2.default.createElement('div', { className: cx('back-icon', theme, { display: shouldDisplayInput }), onClick: this.handleBackIcon }), _react2.default.createElement('input', _extends({ className: cx('anue-search-input', theme, { display: shouldDisplayInput }), value: value, onChange: this.handleChange, onFocus: onInputFocus, onBlur: onInputBlur, onKeyDown: this.handleKeyDown, style: customInputStyles, placeholder: placeholder }, customAttribute)), _react2.default.createElement('div', { className: cx('search-icon', theme), onClick: this.handleClickIcon, style: customIconStyles }), showClearBtn && _react2.default.createElement('div', { className: cx('clear-icon', theme), onClick: this.handleResetValue }) ); } }]); return AnueSearchInput; }(_react2.default.Component); AnueSearchInput.defaultProps = { customAttribute: null, customWrapperStyles: null, customInputStyles: null, customIconStyles: null, shouldAlwaysDisplayInput: false, shouldDisplayBackIcon: false, theme: null, // mobile | desktop placeholder: '搜尋新聞、代碼或名稱', defaultValue: null, customInputClassName: null, onDisplayChange: function onDisplayChange() {}, onIconClick: function onIconClick() {}, onBackIconClick: function onBackIconClick() {}, onInputChange: function onInputChange() {}, onInputFocus: function onInputFocus() {}, onInputBlur: function onInputBlur() {}, onInputPressEnter: function onInputPressEnter() {} }; exports.default = AnueSearchInput; /***/ }), /***/ 44: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _react = __webpack_require__(1); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(0); var _propTypes2 = _interopRequireDefault(_propTypes); var _bind = __webpack_require__(2); var _bind2 = _interopRequireDefault(_bind); var _SearchResultContentWrapper = __webpack_require__(53); var _SearchResultContentWrapper2 = _interopRequireDefault(_SearchResultContentWrapper); var _num = __webpack_require__(31); var _propTypes3 = __webpack_require__(5); var _iconDefaultDriver = __webpack_require__(54); var _iconDefaultDriver2 = _interopRequireDefault(_iconDefaultDriver); var _AnueSearchRealtimeResult = __webpack_require__(24); var _AnueSearchRealtimeResult2 = _interopRequireDefault(_AnueSearchRealtimeResult); var _LazyImage = __webpack_require__(25); var _LazyImage2 = _interopRequireDefault(_LazyImage); var _anueLink = __webpack_require__(10); var _anueLink2 = _interopRequireDefault(_anueLink); var _helpers = __webpack_require__(55); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var cx = _bind2.default.bind(_AnueSearchRealtimeResult2.default); /* eslint-disable no-trailing-spaces */ var anueUtilLink = new _anueLink2.default('prod'); var MAX_RECENT_SEARCH = 5; var MAX_SEARCH_NEWS = 2; function AnueSearchRealtimeResult(_ref) { var hotTags = _ref.hotTags, hotTrades = _ref.hotTrades, hotDrivers = _ref.hotDrivers, recentSearch = _ref.recentSearch, tradeResult = _ref.tradeResult, newsResult = _ref.newsResult, driversResult = _ref.driversResult, searchString = _ref.searchString, customWrapperStyles = _ref.customWrapperStyles, onHotTagClick = _ref.onHotTagClick, onRecentSearchRowClick = _ref.onRecentSearchRowClick, onRecentSearchRowRemoveClick = _ref.onRecentSearchRowRemoveClick, onRecentSearchRemoveAllClick = _ref.onRecentSearchRemoveAllClick, onResultSearchRowClick = _ref.onResultSearchRowClick, searchResultPageLink = _ref.searchResultPageLink; var defaultSearchPageLink = anueUtilLink.generateSearchResultLink({ keyword: searchString }); var searchPageLink = searchResultPageLink || defaultSearchPageLink; var getCode = function getCode(symbol) { var symbolSplit = String(symbol).split(':'); if (!symbolSplit || symbolSplit.length < 2) { return null; } return symbolSplit[1]; }; var renderHotTags = function renderHotTags() { return ( // Display nothing if receive a empty array _react2.default.createElement( _SearchResultContentWrapper2.default, { isLoaded: hotTags && hotTags.length > 0 }, _react2.default.createElement( 'div', { className: cx('hot-tags') }, _react2.default.createElement( 'div', null, _react2.default.createElement( 'p', null, '\u71B1\u641C\uFF1A' ) ), _react2.default.createElement( 'div', null, hotTags && hotTags.map(function (tag) { var handleClick = function handleClick() { return onHotTagClick(tag); }; return _react2.default.createElement( 'a', { key: tag.tagName, href: tag.link, onClick: handleClick }, tag.tagName ); }) ) ) ) ); }; var renderHotTrades = function renderHotTrades() { return ( // Display nothing if receive a empty array _react2.default.createElement( _SearchResultContentWrapper2.default, { title: '\u71B1\u9580\u884C\u60C5', isLoaded: hotTrades && hotTrades.length > 0 }, _react2.default.createElement( 'div', { className: cx('content-rows') }, hotTrades && hotTrades.map(function (trade, i) { var code = getCode(trade.symbol); var display = trade.displayName || code; return display && trade.link ? // eslint-disable-next-line react/no-array-index-key _react2.default.createElement( 'a', { key: 'hot-trade' + i, className: cx('row', 'icon--hot'), href: trade.link }, display ) : null; }) ) ) ); }; var renderRecentSearch = function renderRecentSearch() { return ( // Display nothing if receive a empty array _react2.default.createElement( _SearchResultContentWrapper2.default, { title: '\u6700\u8FD1\u641C\u5C0B', headerActionName: '\u5168\u90E8\u522A\u9664', isLoaded: recentSearch && recentSearch.length > 0, onHeaderActionClick: onRecentSearchRemoveAllClick }, _react2.default.createElement( 'div', { className: cx('content-rows') }, recentSearch && recentSearch.slice(0, MAX_RECENT_SEARCH).map(function (search, i) { var handleClickRow = function handleClickRow() { return onRecentSearchRowClick(search.keyword); }; var handleClickRemove = function handleClickRemove() { return onRecentSearchRowRemoveClick(search.keyword); }; return ( // eslint-disable-next-line react/no-array-index-key _react2.default.createElement( 'div', { key: 'recent-search' + i, className: cx('row', 'limit-length', 'icon--time') }, _react2.default.createElement( 'a', { onClick: handleClickRow }, search.keyword ), _react2.default.createElement('p', { className: cx('icon-cross'), onClick: handleClickRemove }) ) ); }) ) ) ); }; var renderDrivers = function renderDrivers(driverList, isSearchResult) { return ( // isSearchResult ? Display the default message if receive a empty array : // Display nothing if receive a empty array _react2.default.createElement( _SearchResultContentWrapper2.default, { title: '\u57FA\u91D1\u8001\u53F8\u6A5F', isLoaded: isSearchResult ? driverList : driverList && driverList.length > 0, isCols: true }, _react2.default.createElement( 'div', { className: cx('content-cols') }, driverList && driverList.length > 0 ? driverList.map(function (driver, i) { return _react2.default.createElement( 'a', { // eslint-disable-next-line react/no-array-index-key key: 'driver' + i, className: cx('col'), href: driver.link, onClick: isSearchResult ? onResultSearchRowClick : null }, _react2.default.createElement( 'div', { className: cx('avatar') }, _react2.default.createElement(_LazyImage2.default, { isRounded: true, src: driver.avatarPicture || _iconDefaultDriver2.default }) ), _react2.default.createElement('p', { className: cx('mark', 'name'), dangerouslySetInnerHTML: { __html: (0, _helpers.driverNameEllipsisHelper)(driver.driverName) } }), _react2.default.createElement( 'span', { className: cx('sub-title') }, '\u4E00\u5E74\u7E3E\u6548' ), _react2.default.createElement( 'span', { className: cx('perf', { red: driver.return1year > 0, green: driver.return1year < 0 }) }, typeof driver.return1year !== 'undefined' ? (0, _num.numSignHelper)(driver.return1year.toFixed(2), { isPercentage: true }) : '----' ) ); }) : _react2.default.createElement( 'div', { className: cx('empty') }, '\u6C92\u6709\u7B26\u5408\u641C\u5C0B\u689D\u4EF6\u7684\u8CC7\u6599' ) ) ) ); }; var renderSearchTradeResult = function renderSearchTradeResult() { return ( // Display the default message if receive a empty array. _react2.default.createElement( _SearchResultContentWrapper2.default, { title: '\u884C\u60C5', isLoaded: tradeResult }, _react2.default.createElement( 'div', { className: cx('content-rows') }, tradeResult && tradeResult.length > 0 ? tradeResult.map(function (trade, i) { var exchange = ''; if (trade.objectType === 'FUND') { exchange = trade.objectType; } else if (trade.objectType === 'QUOTE' && trade.mtype === 'FOREX' && trade.market !== 'CC') { exchange = '外匯'; } else if (trade.objectType === 'QUOTE' && trade.mtype && trade.exchange) { var cat = trade.type === 'ETF' ? 'ETF' : trade.mtype; exchange = cat + '-' + trade.exchange; } return ( // eslint-disable-next-line react/no-array-index-key _react2.default.createElement( 'a', { key: 'trade' + i, className: cx('row', 'result'), href: trade.link, onClick: onResultSearchRowClick }, _react2.default.createElement( 'p', { className: cx('title') }, _react2.default.createElement('span', { className: cx('mark'), dangerouslySetInnerHTML: { __html: trade.code } }), _react2.default.createElement( 'small', null, exchange ) ), _react2.default.createElement( 'p', { className: cx('summary') }, _react2.default.createElement('span', { className: cx('mark'), dangerouslySetInnerHTML: { __html: trade.chName } }), _react2.default.createElement('span', { className: cx('mark'), dangerouslySetInnerHTML: { __html: trade.enName } }) ) ) ); }) : _react2.default.createElement( 'div', { className: cx('empty') }, '\u6C92\u6709\u7B26\u5408\u641C\u5C0B\u689D\u4EF6\u7684\u8CC7\u6599' ) ) ) ); }; var renderSearchNewsResult = function renderSearchNewsResult() { return ( // Display the default message if receive a empty array. _react2.default.createElement( _SearchResultContentWrapper2.default, { title: '\u65B0\u805E', isLoaded: newsResult }, _react2.default.createElement( 'div', { className: cx('content-rows') }, newsResult && newsResult.length > 0 ? newsResult.slice(0, MAX_SEARCH_NEWS).map(function (n, i) { return ( // eslint-disable-next-line react/no-array-index-key _react2.default.createElement( 'a', { key: 'news' + i, className: cx('row', 'result'), href: n.link, onClick: onResultSearchRowClick }, _react2.default.createElement( 'p', { className: cx('title') }, _react2.default.createElement('span', { className: cx('mark'), dangerouslySetInnerHTML: { __html: n.title } }) ), _react2.default.createElement( 'p', { className: cx('summary') }, _react2.default.createElement( 'span', null, (0, _helpers.newsPublishedDateHelper)(n.publishAt) ), _react2.default.createElement( 'span', null, n.summary ) ) ) ); }) : _react2.default.createElement( 'div', { className: cx('empty') }, '\u6C92\u6709\u7B26\u5408\u641C\u5C0B\u689D\u4EF6\u7684\u8CC7\u6599' ) ) ) ); }; return _react2.default.createElement( 'div', { className: cx('anue-search-result'), style: customWrapperStyles }, searchString ? _react2.default.createElement( 'div', { className: cx('search-sections', 'section') }, _react2.default.createElement( 'a', { className: cx('current-search'), href: searchPageLink, onClick: onResultSearchRowClick }, '\u67E5\u770B\u300C', searchString, '\u300D\u7684\u6240\u6709\u641C\u5C0B\u7D50\u679C\uFF1E' ), renderSearchTradeResult(), renderSearchNewsResult(), renderDrivers(driversResult, true) ) : _react2.default.createElement( 'div', { className: cx('hot-sections', 'section') }, renderHotTags(), renderHotTrades(), renderRecentSearch(), renderDrivers(hotDrivers) ) ); } AnueSearchRealtimeResult.defaultProps = { hotTags: null, hotTrades: null, hotDrivers: null, recentSearch: null, tradeResult: null, newsResult: null, driversResult: null, searchTradeResult: null, searchDriverResult: null, searchNewsResult: null, searchString: null, customWrapperStyles: null, searchResultPageLink: null, onHotTagClick: function onHotTagClick() {}, onRecentSearchRowClick: function onRecentSearchRowClick() {}, onRecentSearchRowRemoveClick: function onRecentSearchRowRemoveClick() {}, onRecentSearchRemoveAllClick: function onRecentSearchRemoveAllClick() {}, onResultSearchRowClick: function onResultSearchRowClick() {} }; exports.default = AnueSearchRealtimeResult; /***/ }), /***/ 5: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.newsResultType = exports.tradeResultType = exports.recentSearchType = exports.hotDriversType = exports.hotTradesType = exports.hotTagsType = exports.adProfileType = exports.newsItemType = exports.userProfileType = exports.authType = exports.locationShape = exports.footerNavItem = exports.catNavsType = exports.catNavItemShape = exports.catNavSubItemShape = exports.navsMobileType = exports.navItemMobileShape = exports.navItemMobilShape = exports.accountNavsType = exports.accountNavItemShape = exports.navsType = exports.navItemShape = exports.navUrlShape = exports.navDownloadType = exports.navDownloadShape = exports.requestType = undefined; var _propTypes = __webpack_require__(0); var _propTypes2 = _interopRequireDefault(_propTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var requestType = exports.requestType = _propTypes2.default.func; /* eslint-disable import/prefer-default-export */ var navDownloadShape = exports.navDownloadShape = _propTypes2.default.shape({ title: _propTypes2.default.string.isRequired, url: _propTypes2.default.string.isRequired }); var navDownloadType = exports.navDownloadType = _propTypes2.default.arrayOf(navDownloadShape); var navUrlShape = exports.navUrlShape = _propTypes2.default.shape({ title: _propTypes2.default.string.isRequired, url: _propTypes2.default.string.isRequired }); var navItemShape = exports.navItemShape = _propTypes2.default.shape({ title: _propTypes2.default.string.isRequired, url: _propTypes2.default.string, leftList: _propTypes2.default.arrayOf(navUrlShape), rightListTitle: _propTypes2.default.string, rightList: _propTypes2.default.arrayOf(navUrlShape) }); var navsType = exports.navsType = _propTypes2.default.arrayOf(navItemShape); var accountNavItemShape = exports.accountNavItemShape = _propTypes2.default.shape({ id: _propTypes2.default.string.isRequired, title: _propTypes2.default.string.isRequired, defaultUrl: _propTypes2.default.string.isRequired, notify: _propTypes2.default.arrayOf(_propTypes2.default.shape({ id: _propTypes2.default.string.isRequired, gotoUrl: _propTypes2.default.string.isRequired })) }); var accountNavsType = exports.accountNavsType = _propTypes2.default.arrayOf(accountNavItemShape); var navItemMobilShape = exports.navItemMobilShape = _propTypes2.default.shape({ name: _propTypes2.default.string.isRequired, title: _propTypes2.default.string.isRequired, url: _propTypes2.default.string.isRequired, external: _propTypes2.default.bool }); var navItemMobileShape = exports.navItemMobileShape = _propTypes2.default.shape({ name: _propTypes2.default.string.isRequired, title: _propTypes2.default.string.isRequired, items: _propTypes2.default.arrayOf(navItemMobilShape) }); var navsMobileType = exports.navsMobileType = _propTypes2.default.arrayOf(navItemMobileShape); var catNavSubItemShape = exports.catNavSubItemShape = _propTypes2.default.shape({ name: _propTypes2.default.string, url: _propTypes2.default.string, title: _propTypes2.default.string, external: _propTypes2.default.bool }); var catNavItemShape = exports.catNavItemShape = _propTypes2.default.shape({ name: _propTypes2.default.string.isRequired, url: _propTypes2.default.string.isRequired, title: _propTypes2.default.string.isRequired, external: _propTypes2.default.bool, subItems: _propTypes2.default.arrayOf(catNavSubItemShape) }); var catNavsType = exports.catNavsType = _propTypes2.default.arrayOf(catNavItemShape); var footerNavItem = exports.footerNavItem = _propTypes2.default.shape({ title: _propTypes2.default.string.isRequired, name: _propTypes2.default.string.isRequired, url: _propTypes2.default.string, onClick: _propTypes2.default.func }); var locationShape = exports.locationShape = _propTypes2.default.shape({ key: _propTypes2.default.string, pathname: _propTypes2.default.string, search: _propTypes2.default.string, hash: _propTypes2.default.string, state: _propTypes2.default.object }); var authType = exports.authType = _propTypes2.default.shape({ init: _propTypes2.default.func.isRequired, loginFB: _propTypes2.default.func.isRequired, loginGoogle: _propTypes2.default.func.isRequired, logout: _propTypes2.default.func.isRequired, showLogin: _propTypes2.default.func.isRequired, hideLogin: _propTypes2.default.func.isRequired, getToken: _propTypes2.default.func.isRequired, refreshToken: _propTypes2.default.func.isRequired, getProfile: _propTypes2.default.func.isRequired }); var userProfileType = exports.userProfileType = _propTypes2.default.shape({ uid: _propTypes2.default.string.isRequired, name: _propTypes2.default.string.isRequired, nickname: _propTypes2.default.string, email: _propTypes2.default.string, avatar: _propTypes2.default.string.isRequired, gender: _propTypes2.default.oneOf(['', 'male', 'female']), vip: _propTypes2.default.oneOf([0, 1]) }); var newsItemType = exports.newsItemType = _propTypes2.default.shape({ newsId: _propTypes2.default.number.isRequired, title: _propTypes2.default.string.isRequired, hasCoverPhoto: _propTypes2.default.oneOf([0, 1]).isRequired, coverSrc: _propTypes2.default.shape({ m: _propTypes2.default.shape({ src: _propTypes2.default.string }), l: _propTypes2.default.shape({ src: _propTypes2.default.string }), xl: _propTypes2.default.shape({ src: _propTypes2.default.string }) }) }); var adProfileType = exports.adProfileType = _propTypes2.default.shape({ name: _propTypes2.default.string.isRequired, path: _propTypes2.default.string.isRequired, hideOnInitial: _propTypes2.default.bool }); var hotTagsType = exports.hotTagsType = _propTypes2.default.shape({ tagName: _propTypes2.default.string, link: _propTypes2.default.string }); var hotTradesType = exports.hotTradesType = _propTypes2.default.shape({ localName: _propTypes2.default.string, link: _propTypes2.default.string }); var hotDriversType = exports.hotDriversType = _propTypes2.default.shape({ avatarPicture: _propTypes2.default.string, driverId: _propTypes2.default.string, driverName: _propTypes2.default.string, return1year: _propTypes2.default.number, link: _propTypes2.default.string }); var recentSearchType = exports.recentSearchType = _propTypes2.default.shape({ keyword: _propTypes2.default.string, link: _propTypes2.default.string }); var tradeResultType = exports.tradeResultType = _propTypes2.default.shape({ market: _propTypes2.default.string, code: _propTypes2.default.string, type: _propTypes2.default.string, mtype: _propTypes2.default.string, symbol: _propTypes2.default.string, chName: _propTypes2.default.string, enName: _propTypes2.default.string, exchange: _propTypes2.default.string, link: _propTypes2.default.string }); var newsResultType = exports.newsResultType = _propTypes2.default.shape({ newsId: _propTypes2.default.string, title: _propTypes2.default.string, summary: _propTypes2.default.string, publishAt: _propTypes2.default.number, link: _propTypes2.default.string }); /***/ }), /***/ 51: /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(115); /***/ }), /***/ 52: /***/ (function(module, exports) { // removed by extract-text-webpack-plugin module.exports = {"anue-search-input--wrapper":"_2FuhZ","search-icon":"_1TJnw","clear-icon":"_2ajF-","back-icon":"_3FFxo","mobile":"_1q3Tm","display":"_2TQmr","test1":"_3p1bb","test2":"_3OSc-","anue-search-input":"_2GtYE","desktop":"_1xlWU"}; /***/ }), /***/ 53: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = SearchResultContentWrapper; var _react = __webpack_require__(1); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(0); var _propTypes2 = _interopRequireDefault(_propTypes); var _bind = __webpack_require__(2); var _bind2 = _interopRequireDefault(_bind); var _AnueSearchRealtimeResult = __webpack_require__(24); var _AnueSearchRealtimeResult2 = _interopRequireDefault(_AnueSearchRealtimeResult); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var cx = _bind2.default.bind(_AnueSearchRealtimeResult2.default); function SearchResultContentWrapper(_ref) { var title = _ref.title, headerActionName = _ref.headerActionName, onHeaderActionClick = _ref.onHeaderActionClick, isLoaded = _ref.isLoaded, children = _ref.children; return _react2.default.createElement( 'div', { className: cx('search-result-content-wrapper', { display: isLoaded }) }, title && _react2.default.createElement( 'div', { className: cx('search-result-content-wrapper__header') }, _react2.default.createElement( 'p', null, title ), headerActionName && _react2.default.createElement( 'span', { onClick: onHeaderActionClick }, headerActionName ) ), children ); } SearchResultContentWrapper.defaultProps = { title: null, headerActionName: null, onHeaderActionClick: function onHeaderActionClick() {}, onRowActionClick: function onRowActionClick() {}, isLoaded: false, isCols: false, children: null }; /***/ }), /***/ 54: /***/ (function(module, exports) { module.exports = "https://sfiles.cnyes.cool/fe-common/dd46e5ee/17b66d364430e36cb72e58896890f44f.svg"; /***/ }), /***/ 55: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ZERO_CHART_CODE_AT = '0'.charCodeAt(); var NINE_CHART_CODE_AT = '9'.charCodeAt(); var FIRST_ALPHABET_CHART_CODE_AT = 'a'.charCodeAt(); var LAST_ALPHABET_CHART_CODE_AT = 'z'.charCodeAt(); var FIRST_CAPITAL_ALPHABET_CHART_CODE_AT = 'A'.charCodeAt(); var LAST_CAPITAL_ALPHABET_CHART_CODE_AT = 'Z'.charCodeAt(); var MAX_TEXT_LENGTH = 24; var findMarkTagIdx = exports.findMarkTagIdx = function findMarkTagIdx(string) { var startRegex = string.match('<mark>'); var endRegex = string.replace('<mark>', '').match('</mark>'); var markStartIdx = startRegex && startRegex.index; var markEndIdx = endRegex && endRegex.index; return { markStartIdx: markStartIdx, markEndIdx: markEndIdx }; }; var driverNameEllipsisHelper = exports.driverNameEllipsisHelper = function driverNameEllipsisHelper(htmlString) { if (!htmlString) { return null; } var lengthCount = 0; var map = ['<mark>', '</mark>']; var stringArry = htmlString.split(/<\/?mark>/); var next = []; for (var i = 0; i < stringArry.length; i++) { var currentChunk = stringArry[i]; for (var j = 0; j < currentChunk.length; j++) { var c = currentChunk[j].charCodeAt(); if (ZERO_CHART_CODE_AT <= c && NINE_CHART_CODE_AT >= c || FIRST_ALPHABET_CHART_CODE_AT <= c && LAST_ALPHABET_CHART_CODE_AT >= c) { // eslint-disable-next-line no-param-reassign lengthCount += 1; } else if (FIRST_CAPITAL_ALPHABET_CHART_CODE_AT <= c && LAST_CAPITAL_ALPHABET_CHART_CODE_AT >= c) { // eslint-disable-next-line no-param-reassign lengthCount += 1.5; } else { // eslint-disable-next-line no-param-reassign lengthCount += 2; } if (lengthCount >= MAX_TEXT_LENGTH) { break; } next.push(currentChunk[j]); } if (i !== stringArry.length - 1) { next.push(map[i % 2]); } if (lengthCount >= MAX_TEXT_LENGTH) { break; } } return lengthCount >= MAX_TEXT_LENGTH ? next.join('') + '...' : next.join(''); }; var newsPublishedDateHelper = exports.newsPublishedDateHelper = function newsPublishedDateHelper(phpTs) { var ts = phpTs * 1000; var hoursBackTimestamp = Date.now() - ts; if (hoursBackTimestamp < 24 * 60 * 60 * 1000) { return Math.floor(hoursBackTimestamp / (60 * 60 * 1000)) + ' \u5C0F\u6642\u524D'; } var d = new Date(ts); return d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate(); }; /***/ }), /***/ 56: /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = AnueCookie; var SEARCH_HISTORY_STORED_COOKIE_NAME = 'anue.search.history'; function AnueCookie(env) { var isProd = env === 'prod'; var cookieDomain = isProd ? '.cnyes.com' : '.cnyes.cool'; var getSearchCookies = function getSearchCookies() { var history = ('; ' + document.cookie).split('; ' + SEARCH_HISTORY_STORED_COOKIE_NAME + '=').pop().split(';').shift(); var _history = []; if (history) { try { _history = JSON.parse(history); } catch (e) { console.log('the stored values has incorrect format. Store the new value and truncate the old data', e); _history = []; } } return _history; }; return { getSearchCookies: getSearchCookies, setSearchCookies: function setSearchCookies(_ref) { var string = _ref.string, _ref$shouldDelete = _ref.shouldDelete, shouldDelete = _ref$shouldDelete === undefined ? false : _ref$shouldDelete, _ref$cookieLimit = _ref.cookieLimit, cookieLimit = _ref$cookieLimit === undefined ? 5 : _ref$cookieLimit; var next = getSearchCookies(); var legalSearchStr = string; if (!legalSearchStr) { return; } if (legalSearchStr.length > 30) { legalSearchStr = legalSearchStr.substring(0, 30); } if (next.length > 0) { if (shouldDelete && next.indexOf(legalSearchStr) > -1) { next.splice(next.indexOf(legalSearchStr), 1); } else if (next.indexOf(legalSearchStr) > -1) { // Do nothing if the keyword is duplicated. return; } else { next.push(legalSearchStr); } while (next.length > cookieLimit) { next.shift(); } document.cookie = SEARCH_HISTORY_STORED_COOKIE_NAME + '=' + JSON.stringify(next) + '; domain=' + cookieDomain + '; path=/'; } else { document.cookie = SEARCH_HISTORY_STORED_COOKIE_NAME + '=' + JSON.stringify([legalSearchStr]) + '; domain=' + cookieDomain + '; path=/'; } }, removeSearchCookies: function removeSearchCookies() { document.cookie = SEARCH_HISTORY_STORED_COOKIE_NAME + '=' + JSON.stringify([]) + '; domain=' + cookieDomain + '; path=/'; }, cookieDomain: cookieDomain }; } /***/ }) /******/ }); });