Start working on remote upload (Chrome-only so far)

This commit is contained in:
Kabir Sala 2014-02-11 18:32:23 +01:00
parent d22dceea5a
commit f0bd6b1b04
10 changed files with 98 additions and 12 deletions

View File

@ -1,5 +1,5 @@
/*
* 4chan X - Version 1.3.5 - 2014-02-10
* 4chan X - Version 1.3.5 - 2014-02-11
*
* Licensed under the MIT license.
* https://github.com/Spittie/4chan-x/blob/master/LICENSE

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -17,6 +17,8 @@
"homepage_url": "http://seaweedchan.github.io/4chan-x/",
"minimum_chrome_version": "31",
"permissions": [
"storage"
"storage",
"http://*/",
"https://*/"
]
}

File diff suppressed because one or more lines are too long

View File

@ -783,6 +783,7 @@ span.hide-announcement {
}
#qr select,
#dump-button,
#url-button,
.remove,
.captcha-img {
cursor: pointer;
@ -837,6 +838,14 @@ span.hide-announcement {
padding: 1px 0px 2px;
opacity: 0.6;
}
#url-button {
width: 10%;
margin: 0;
margin-right: 4px;
font: 13px sans-serif;
padding: 1px 0px 2px;
opacity: 0.6;
}
.persona .field:not(#dump) {
width: 95px;
min-width: 33.3%;

View File

@ -28,6 +28,7 @@
<input id="qr-filename" data-name="filename" spellcheck="false">
<span id=qr-extras-container>
<a id=qr-filerm href=javascript:; title='Remove file'>×</a>
<a id=url-button title='Post from url'>!</a>
<a id=dump-button title='Dump list'>+</a>
</span>
</span>

View File

@ -17,6 +17,8 @@
"homepage_url": "<%= meta.page %>",
"minimum_chrome_version": "<%= meta.min.chrome %>",
"permissions": [
"storage"
"storage",
"http://*/",
"https://*/"
]
}

View File

@ -111,7 +111,7 @@ QR.captcha =
@clear()
count: ->
count = @captchas.length
count = if @captchas then @captchas.length else 0
@nodes.input.placeholder = switch count
when 0
'Verification (Shift + Enter to cache)'

View File

@ -268,6 +268,26 @@ QR =
QR.handleFiles files
$.addClass QR.nodes.el, 'dump'
handleUrl: ->
url = prompt("insert url")
xhr = new XMLHttpRequest();
xhr.open('GET', url, true)
xhr.responseType = 'blob'
xhr.onload = (e) ->
if this.readyState == this.DONE && xhr.status == 200
urlBlob = new Blob([this.response], {type: 'image/jpeg'})
QR.handleFiles([urlBlob])
null
xhr.onerror = (e) ->
console.log("error" + e)
null
xhr.send()
null
handleFiles: (files) ->
if @ isnt QR # file input
files = [@files...]
@ -343,6 +363,7 @@ QR =
close: '.close'
form: 'form'
dumpButton: '#dump-button'
urlButton: '#url-button'
name: '[data-name=name]'
email: '[data-name=email]'
sub: '[data-name=sub]'
@ -412,6 +433,7 @@ QR =
$.on nodes.autohide, 'change', QR.toggleHide
$.on nodes.close, 'click', QR.close
$.on nodes.dumpButton, 'click', -> nodes.el.classList.toggle 'dump'
$.on nodes.urlButton, 'click', QR.handleUrl
$.on nodes.addPost, 'click', -> new QR.post true
$.on nodes.form, 'submit', QR.submit
$.on nodes.fileRM, 'click', -> QR.selected.rmFile()