changed create dialog
This commit is contained in:
@ -28,35 +28,71 @@ function fillDetectedFilelist(file) {
|
||||
fileList = document.querySelectorAll(".detectedFiles ul")[0]
|
||||
fileList.innerHTML = ""
|
||||
reader.onload = function() {
|
||||
autodetectSuccess = false
|
||||
b = new bencode()
|
||||
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)
|
||||
try {
|
||||
torrentObject = b.decode(reader.result)
|
||||
} catch(err) {
|
||||
|
||||
}
|
||||
|
||||
document.querySelectorAll("input.name")[0].value = torrentObject.info.name
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user