fixed #8 added option for ripping audio from youtube-dl sites;fixed bugs
This commit is contained in:
@@ -40,6 +40,9 @@ const createInputBox = (event, type) => {
|
||||
selectOptions.push({ name: 'TPB', label: 'THEPIRATEBAY', selected: 1 });
|
||||
container = inputBox.getInstance(name, type, path).createOptions(selectOptions).create().addSpinner();
|
||||
//container.appendChild(inputBox.createLoading());
|
||||
} else if (type === 'ytdl') {
|
||||
let checkbox = [{id:'audio-only',label:'Audio Only'}];
|
||||
container = inputBox.getInstance(name, type, path).createCheckbox(checkbox).create().getContainer();
|
||||
} else {
|
||||
container = inputBox.getInstance(name, type, path).create().getContainer();
|
||||
}
|
||||
@@ -69,11 +72,13 @@ const inputHandler = (event) => {
|
||||
|
||||
let inputData = helper.getData('form-input-wrapper');
|
||||
let inputValue = inputData.form_input_text;
|
||||
|
||||
if (inputData.type !== 'search' && !helper.isURL(inputValue) && !helper.isMagnetURI(inputValue)) {
|
||||
helper.message(t("ncdownloader", "Invalid url"));
|
||||
return;
|
||||
}
|
||||
if (inputData.type === 'ytdl') {
|
||||
inputData.audioOnly = document.getElementById('audio-only').checked;
|
||||
helper.message(t("ncdownloader", "Your download has started!"), 5000);
|
||||
}
|
||||
if (inputData.type === 'search') {
|
||||
|
||||
@@ -5,6 +5,7 @@ import helper from './helper'
|
||||
class inputBox {
|
||||
path;
|
||||
selectOptions = [];
|
||||
checkbox = [];
|
||||
constructor(btnName, id, path = null) {
|
||||
this.btnName = btnName;
|
||||
this.id = id;
|
||||
@@ -18,6 +19,9 @@ class inputBox {
|
||||
this.textInput = this._createTextInput(this.id);
|
||||
this.buttonContainer = this._createButtonContainer();
|
||||
this.formContainer.appendChild(this.textInput);
|
||||
if (this.checkbox.length !== 0) {
|
||||
this.formContainer.appendChild(this._createCheckbox());
|
||||
}
|
||||
if (this.selectOptions.length !== 0) {
|
||||
this.formContainer.appendChild(this._createSelect());
|
||||
}
|
||||
@@ -60,6 +64,42 @@ class inputBox {
|
||||
return select;
|
||||
}
|
||||
|
||||
_createCheckbox() {
|
||||
let div = document.createElement("div");
|
||||
div.classList.add("checkboxes");
|
||||
this.checkbox.forEach(element => {
|
||||
div.appendChild(element);
|
||||
})
|
||||
return div;
|
||||
}
|
||||
|
||||
createCheckbox(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
data.forEach(element => {
|
||||
let div = document.createElement('div');
|
||||
let label = document.createElement('label');
|
||||
let text = document.createTextNode(element.label);
|
||||
let span = document.createElement('span');
|
||||
span.appendChild(text);
|
||||
|
||||
let input = document.createElement('input');
|
||||
input.setAttribute('type', 'checkbox');
|
||||
input.setAttribute('id', element.id);
|
||||
input.setAttribute('value', 'off');
|
||||
input.setAttribute('name', element.name || element.id);
|
||||
|
||||
label.setAttribute('for',element.id);
|
||||
label.classList.add("checkbox-label");
|
||||
label.appendChild(input);
|
||||
label.appendChild(span);
|
||||
div.appendChild(label);
|
||||
this.checkbox.push(div);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
createOptions(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user