changed create dialog
This commit is contained in:
parent
ebc7da1d05
commit
3092c2e615
@ -115,4 +115,4 @@ if __name__ == "__main__":
|
||||
app.jinja_env.globals.update(getLocalString=getLocalString)
|
||||
app.jinja_env.globals.update(json=json)
|
||||
app.jinja_env.globals.update(sorted=sorted)
|
||||
app.run(debug=True)
|
||||
app.run(debug=False, host="0.0.0.0")
|
||||
|
@ -117,6 +117,10 @@ body {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.detectedInfosGroup {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
@ -28,35 +28,71 @@ function fillDetectedFilelist(file) {
|
||||
fileList = document.querySelectorAll(".detectedFiles ul")[0]
|
||||
fileList.innerHTML = ""
|
||||
reader.onload = function() {
|
||||
autodetectSuccess = false
|
||||
b = new bencode()
|
||||
try {
|
||||
torrentObject = b.decode(reader.result)
|
||||
for(var fileIndex = 0; fileIndex < torrentObject.info.files.length; fileIndex++){
|
||||
newListElement = document.createElement("li")
|
||||
newListElement.innerHTML = torrentObject.info.files[fileIndex].path[0]
|
||||
fileList.appendChild(newListElement)
|
||||
} catch(err) {
|
||||
|
||||
}
|
||||
|
||||
if(torrentObject.info.name) {
|
||||
document.querySelectorAll("input.name")[0].value = torrentObject.info.name
|
||||
}
|
||||
|
||||
sizeGroup = document.querySelectorAll(".sizeGroup")[0]
|
||||
if(torrentObject.info.pieces.length && torrentObject.info["piece length"]){
|
||||
if(torrentObject.info.pieces.length && torrentObject.info["piece length"]) {
|
||||
sizeGroup.style.display = ""
|
||||
document.querySelectorAll(".detectedSize")[0].innerHTML = ((Math.round((torrentObject.info.pieces.length / 20) * torrentObject.info["piece length"]) / 1024 / 1024 * 100) / 100) + " MB"
|
||||
size = (torrentObject.info.pieces.length / 20) * torrentObject.info["piece length"]
|
||||
size = getNextUnit(size)
|
||||
document.querySelectorAll(".detectedSize")[0].innerHTML = ((Math.round(size[0] * 100)) / 100) + " " + size[1]
|
||||
autodetectSuccess = true
|
||||
} else {
|
||||
sizeGroup.style.display = "none"
|
||||
}
|
||||
|
||||
trackerGroup = document.querySelectorAll(".trackerGroup")[0]
|
||||
if(torrentObject.announce){
|
||||
if(torrentObject.announce) {
|
||||
trackerGroup.style.display = ""
|
||||
document.querySelectorAll(".detectedTracker")[0].innerHTML = torrentObject.announce
|
||||
autodetectSuccess = true
|
||||
} else {
|
||||
trackerGroup.style.display = "none"
|
||||
}
|
||||
|
||||
filesGroup = document.querySelectorAll(".filesGroup")[0]
|
||||
if(torrentObject.info.files.length > 0) {
|
||||
autodetectSuccess = true
|
||||
for(var fileIndex = 0; fileIndex < torrentObject.info.files.length; fileIndex++){
|
||||
newListElement = document.createElement("li")
|
||||
newListElement.innerHTML = torrentObject.info.files[fileIndex].path[0]
|
||||
fileList.appendChild(newListElement)
|
||||
}
|
||||
}
|
||||
|
||||
var detectInfosGroup = document.querySelectorAll(".detectedInfosGroup")[0]
|
||||
if(autodetectSuccess) {
|
||||
detectInfosGroup.style.display = "block"
|
||||
} else {
|
||||
detectInfosGroup.style.display = "none"
|
||||
}
|
||||
}
|
||||
reader.readAsArrayBuffer(file)
|
||||
}
|
||||
|
||||
function getNextUnit(bSize) {
|
||||
units = ["B", "kB", "MB", "GB", "TB", "PB", "To damn high"]
|
||||
iters = 0
|
||||
size = bSize
|
||||
do {
|
||||
size /= 1024
|
||||
iters++
|
||||
} while(size >= 1)
|
||||
size *= 1024
|
||||
if(iters > units.length) { iters = units.length }
|
||||
return [size, units[iters - 1]]
|
||||
}
|
||||
|
||||
// Fill a defined dropdown with values.
|
||||
// These values will be generated out of the categories.json
|
||||
function fillDropdownByValue(value, dropdownToFill) {
|
||||
|
@ -38,6 +38,9 @@
|
||||
"create_new_torrent" : "Create a new torrent",
|
||||
"description" : "Description",
|
||||
"audio_quality" : "Audio quality",
|
||||
"video_quality" : "Video quality"
|
||||
"video_quality" : "Video quality",
|
||||
"size" : "Size",
|
||||
"tracker" : "Tracker",
|
||||
"detected_files" : "Detected files"
|
||||
}
|
||||
}
|
||||
|
@ -21,22 +21,22 @@ vim: ts=2 noexpandtab
|
||||
<div class="form-group">
|
||||
<label for="inputTorrentFile" class="col-sm-3 control-label">{{ getLocalString(language, "torrent_file") }}</label>
|
||||
<div class="col-sm-9">
|
||||
<input name="torrentFile" class="file" type="file" size="50" maxlength="100000" accept="text/*" onchange="setButtonToFilename(event)">
|
||||
<input name="torrentFile" class="file" type="file" size="50" maxlength="100000" accept="application/x-bittorrent" onchange="setButtonToFilename(event)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group detectedInfosGroup">
|
||||
<label for="inputTorrentFile" class="col-sm-3 control-label">File info</label>
|
||||
<div class="col-sm-9 detectedInfos">
|
||||
<div class="detectedGroup sizeGroup">
|
||||
<h5>Size:</h5>
|
||||
<p class="detectedSize">123MB</p>
|
||||
<h5>{{ getLocalString(language, "size") }}:</h5>
|
||||
<p class="detectedSize"></p>
|
||||
</div>
|
||||
<div class="detectedGroup trackerGroup">
|
||||
<h5>Tracker:</h5>
|
||||
<p class="detectedTracker">http://foo.bar/tracker</p>
|
||||
<h5>{{ getLocalString(language, "tracker") }}:</h5>
|
||||
<p class="detectedTracker"></p>
|
||||
</div>
|
||||
<div class="detectedGroup filesGroup">
|
||||
<h5>Detected files:</h5>
|
||||
<h5>{{ getLocalString(language, "detected_files") }}:</h5>
|
||||
<div class="detectedFiles">
|
||||
<ul>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user