Progress Adding More Fields

This commit is contained in:
Leo Herzog
2020-06-21 15:50:06 -04:00
parent 88a9210cdb
commit 31649fc59b
4 changed files with 49 additions and 6 deletions

View File

@@ -2379,6 +2379,10 @@ const Buffer = require('Buffer');
const size = require('filesize');
var name = document.getElementById('name');
var creationDate = document.getElementById('creationDate');
var createdBy = document.getElementById('createdBy');
var comment = document.getElementById('comment');
var hash = document.getElementById('hash');
var parsed;
document.addEventListener('DOMContentLoaded', start);
@@ -2400,7 +2404,6 @@ function start() {
}
function parse(toLoad) {
console.info(toLoad);
if (typeof toLoad === "string" && toLoad.toLowerCase().trim().startsWith("http")) {
parser.remote(toLoad, handleRemote);
} else {
@@ -2416,7 +2419,17 @@ function handleRemote(err, result) {
function display() {
console.log(parsed);
name.value = parsed.name;
name.value = parsed.name || "";
if (parsed.created) {
creationDate.disabled = false;
creationDate.value = parsed.created.toISOString().slice(0, 19);
} else {
creationDate.disabled = true;
creationDate.value = "";
}
createdBy.value = parsed.createdBy || "";
comment.value = parsed.comment || "";
hash.value = parsed.infoHash;
}
},{"Buffer":1,"filesize":6,"parse-torrent":9}],21:[function(require,module,exports){
'use strict'

View File

@@ -14,7 +14,24 @@
<div class="form-group">
<label class="col-form-label" for="name">Torrent Name</label>
<input id="name" type="text" class="form-control" value="" />
<input id="name" type="text" class="form-control" value="" placeholder="No name" />
</div>
<div class="form-group">
<label class="col-form-label" for="creationDate">Created</label>
<input id="creationDate" type="datetime-local" class="form-control" value="" placeholder="Empty" />
<label class="col-form-label" for="createdBy">with</label>
<input id="createdBy" type="text" class="form-control" value="" placeholder="Unspecified" disabled />
</div>
<div class="form-group">
<label class="col-form-label" for="comment">Comment</label>
<input id="comment" type="text" class="form-control" value="" placeholder="Empty" />
</div>
<div class="form-group">
<label class="col-form-label" for="hash">Unique Hash</label>
<input id="hash" type="text" class="form-control" value="" placeholder="" disabled/>
</div>
<script src="bundle.js"></script>

View File

@@ -1,7 +1,7 @@
{
"name": "torrentparts",
"version": "0.0.1",
"description": "🗃️ A website to inspect and edit Torrent files and Magnet URLs",
"description": "📑 A website to inspect and edit Torrent files and Magnet URLs",
"main": "bundle.js",
"dependencies": {
"browserify": "latest",

View File

@@ -3,6 +3,10 @@ const Buffer = require('Buffer');
const size = require('filesize');
var name = document.getElementById('name');
var creationDate = document.getElementById('creationDate');
var createdBy = document.getElementById('createdBy');
var comment = document.getElementById('comment');
var hash = document.getElementById('hash');
var parsed;
document.addEventListener('DOMContentLoaded', start);
@@ -24,7 +28,6 @@ function start() {
}
function parse(toLoad) {
console.info(toLoad);
if (typeof toLoad === "string" && toLoad.toLowerCase().trim().startsWith("http")) {
parser.remote(toLoad, handleRemote);
} else {
@@ -40,5 +43,15 @@ function handleRemote(err, result) {
function display() {
console.log(parsed);
name.value = parsed.name;
name.value = parsed.name || "";
if (parsed.created) {
creationDate.disabled = false;
creationDate.value = parsed.created.toISOString().slice(0, 19);
} else {
creationDate.disabled = true;
creationDate.value = "";
}
createdBy.value = parsed.createdBy || "";
comment.value = parsed.comment || "";
hash.value = parsed.infoHash;
}