diff --git a/src/containers/monitor.jsx b/src/containers/monitor.jsx index e2c88222018d94c35d1c9ef31af8f6e8ec23b018..039fa060d616d2df878f75eff8140fcbdcb51ecb 100644 --- a/src/containers/monitor.jsx +++ b/src/containers/monitor.jsx @@ -8,7 +8,7 @@ import MonitorComponent, {monitorModes} from '../components/monitor/monitor.jsx' import {addMonitorRect, getInitialPosition, resizeMonitorRect, removeMonitorRect} from '../reducers/monitor-layout'; import {getVariable, setVariableValue} from '../lib/variable-utils'; import importCSV from '../lib/import-csv'; -import downloadText from '../lib/download-text'; +import download from '../lib/download-url'; import {connect} from 'react-redux'; import {Map} from 'immutable'; @@ -155,7 +155,8 @@ class Monitor extends React.Component { handleExport () { const {vm, targetId, id: variableId} = this.props; const variable = getVariable(vm, targetId, variableId); - downloadText(`${variable.name}.txt`, variable.value.join('\r\n')); + const text = variable.value.join('\r\n'); + download(`${variable.name}.txt`, `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`); } render () { const monitorProps = monitorAdapter(this.props); diff --git a/src/lib/download-text.js b/src/lib/download-text.js deleted file mode 100644 index 2c0bc91a511b6f6d20011dbbc23a71d4cf0fdd1a..0000000000000000000000000000000000000000 --- a/src/lib/download-text.js +++ /dev/null @@ -1,13 +0,0 @@ -export default (filename, text) => { - const pom = document.createElement('a'); - pom.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(text)}`); - pom.setAttribute('download', filename); - - if (document.createEvent) { - const event = document.createEvent('MouseEvents'); - event.initEvent('click', true, true); - pom.dispatchEvent(event); - } else { - pom.click(); - } -};