- Rename JS/CSS for main.html to be consistent (main.js, main.css) - Add hx.js module to reduce virtual-dom boilerplate - Move state.js into renderer/lib.js where it belongs - Rename torrent-list.js -> home.js for consistency - Rename create-torrent-page.js -> create-torrent.js for consistency
34 lines
951 B
JavaScript
34 lines
951 B
JavaScript
module.exports = OpenTorrentAddressModal
|
|
|
|
var {dispatch} = require('../lib/dispatcher')
|
|
var hx = require('../lib/hx')
|
|
|
|
function OpenTorrentAddressModal (state) {
|
|
return hx`
|
|
<div class='open-torrent-address-modal'>
|
|
<p><label>Enter torrent address or magnet link</label></p>
|
|
<p>
|
|
<input id='add-torrent-url' type='text' onkeypress=${handleKeyPress} />
|
|
</p>
|
|
<p class='float-right'>
|
|
<button class='button button-flat' onclick=${handleCancel}>CANCEL</button>
|
|
<button class='button button-raised' onclick=${handleOK}>OK</button>
|
|
</p>
|
|
<script>document.querySelector('#add-torrent-url').focus()</script>
|
|
</div>
|
|
`
|
|
}
|
|
|
|
function handleKeyPress (e) {
|
|
if (e.which === 13) handleOK() /* hit Enter to submit */
|
|
}
|
|
|
|
function handleOK () {
|
|
dispatch('exitModal')
|
|
dispatch('addTorrent', document.querySelector('#add-torrent-url').value)
|
|
}
|
|
|
|
function handleCancel () {
|
|
dispatch('exitModal')
|
|
}
|