added one more bt site;added the option for choosing a site to search torrents
This commit is contained in:
@@ -36,7 +36,10 @@ const createInputBox = (event, type) => {
|
||||
}
|
||||
let container;
|
||||
if (type === 'search') {
|
||||
container = inputBox.getInstance(name, type, path).create().addSpinner();
|
||||
let selectOptions = [];
|
||||
selectOptions.push({name:'bitSearch',label:'BITSEARCH',default:0});
|
||||
selectOptions.push({name:'TPB',label:'THEPIRATEBAY',selected:1});
|
||||
container = inputBox.getInstance(name, type, path).createOptions(selectOptions).create().addSpinner();
|
||||
//container.appendChild(inputBox.createLoading());
|
||||
} else {
|
||||
container = inputBox.getInstance(name, type, path).create().getContainer();
|
||||
@@ -63,6 +66,8 @@ const inputHandler = (event) => {
|
||||
event.preventDefault();
|
||||
let element = event.target;
|
||||
toggleSpinner(element);
|
||||
let formWrapper = element.closest('form');
|
||||
|
||||
let inputData = helper.getData('form-input-wrapper');
|
||||
let inputValue = inputData.form_input_text;
|
||||
if (inputData.type !== 'search' && !helper.isURL(inputValue) && !helper.isMagnetURI(inputValue)) {
|
||||
@@ -82,7 +87,7 @@ const inputHandler = (event) => {
|
||||
if (data !== null && data.hasOwnProperty("file")) {
|
||||
helper.message(t("ncdownloader", "Downloading" + " " + data.file));
|
||||
}
|
||||
toggleSpinner(element);
|
||||
toggleSpinner(element);
|
||||
if (data && data.title) {
|
||||
const tableInst = nctable.getInstance(data.title, data.row);
|
||||
tableInst.actionLink = false;
|
||||
@@ -90,7 +95,7 @@ const inputHandler = (event) => {
|
||||
tableInst.create();
|
||||
}
|
||||
}
|
||||
const path = inputData.path || basePath + "/new";
|
||||
const path = formWrapper.dataset.path || basePath + "/new";
|
||||
let url = helper.generateUrl(path);
|
||||
Http.getInstance(url).setData(inputData).setHandler(function (data) {
|
||||
successCallback(data, element);
|
||||
|
||||
@@ -4,43 +4,78 @@ import helper from './helper'
|
||||
|
||||
class inputBox {
|
||||
path;
|
||||
constructor(name, id, path = null) {
|
||||
this.name = name;
|
||||
selectOptions = [];
|
||||
constructor(btnName, id, path = null) {
|
||||
this.btnName = btnName;
|
||||
this.id = id;
|
||||
this.path = path;
|
||||
}
|
||||
static getInstance(name, id, path = null) {
|
||||
return new inputBox(name, id, path);
|
||||
static getInstance(btnName, id, path = null) {
|
||||
return new inputBox(btnName, id, path);
|
||||
}
|
||||
create() {
|
||||
this.container = this._createForm();
|
||||
this.formContainer = this._createForm();
|
||||
this.textInput = this._createTextInput(this.id);
|
||||
this.controlsContainer = this._createControlsContainer();
|
||||
this.container.appendChild(this.textInput);
|
||||
this.controlsContainer.appendChild(this._createControls());
|
||||
this.container.appendChild(this.controlsContainer);
|
||||
this.buttonContainer = this._createButtonContainer();
|
||||
this.formContainer.appendChild(this.textInput);
|
||||
if (this.selectOptions.length !== 0) {
|
||||
this.formContainer.appendChild(this._createSelect());
|
||||
}
|
||||
this.buttonContainer.appendChild(this._createButton());
|
||||
this.formContainer.appendChild(this.buttonContainer);
|
||||
return this;
|
||||
}
|
||||
|
||||
getContainer() {
|
||||
return this.container;
|
||||
return this.formContainer;
|
||||
}
|
||||
setPath(path) {
|
||||
this.path = path;
|
||||
return this;
|
||||
}
|
||||
_createControlsContainer() {
|
||||
_createButtonContainer() {
|
||||
let div = document.createElement("div");
|
||||
|
||||
div.classList.add("controls-container");
|
||||
div.classList.add("button-container");
|
||||
return div;
|
||||
}
|
||||
_createForm() {
|
||||
let container = document.createElement("form");
|
||||
container.classList.add("form-input-wrapper");
|
||||
container.setAttribute('id', 'form-input-wrapper');
|
||||
if (this.path) {
|
||||
container.setAttribute('data-path', this.path);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
_createSelect(id) {
|
||||
id = id || this.id;
|
||||
let select = document.createElement('select');
|
||||
select.setAttribute('id', "select-value-" + id);
|
||||
select.setAttribute('value', '');
|
||||
select.classList.add('form-select');
|
||||
this.selectOptions.forEach(element => {
|
||||
select.appendChild(element);
|
||||
});
|
||||
return select;
|
||||
}
|
||||
|
||||
createOptions(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
data.forEach(element => {
|
||||
let option = document.createElement('option');
|
||||
option.setAttribute('value', element.name);
|
||||
let text = document.createTextNode(element.label);
|
||||
option.appendChild(text);
|
||||
if (element.selected) {
|
||||
option.setAttribute("selected", "selected");
|
||||
}
|
||||
this.selectOptions.push(option);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
_createTextInput(id) {
|
||||
id = id || 'general';
|
||||
let textInput = document.createElement('input');
|
||||
@@ -48,18 +83,15 @@ class inputBox {
|
||||
textInput.setAttribute('id', "form_input_text");
|
||||
textInput.setAttribute('data-type', id);
|
||||
textInput.setAttribute('value', '');
|
||||
if (this.path) {
|
||||
textInput.setAttribute('data-path', this.path);
|
||||
}
|
||||
textInput.classList.add('form-input-text');
|
||||
return textInput;
|
||||
}
|
||||
_createControls() {
|
||||
_createButton() {
|
||||
let button = document.createElement('button');
|
||||
button.setAttribute('type', this.name);
|
||||
button.setAttribute('type', this.btnName);
|
||||
button.setAttribute('id', 'form-input-button');
|
||||
//buttonInput.setAttribute('value', t('ncdownloader', helper.ucfirst(name)));
|
||||
let text = document.createTextNode(t('ncdownloader', helper.ucfirst(this.name)));
|
||||
//buttonInput.setAttribute('value', t('ncdownloader', helper.ucfirst(btnName)));
|
||||
let text = document.createTextNode(t('ncdownloader', helper.ucfirst(this.btnName)));
|
||||
button.appendChild(text);
|
||||
return button;
|
||||
}
|
||||
@@ -69,8 +101,8 @@ class inputBox {
|
||||
let doc = parser.parseFromString(htmlString, "text/html")
|
||||
let element = doc.querySelector(".bs-spinner");
|
||||
element.style.display = 'none';
|
||||
this.controlsContainer.appendChild(element);
|
||||
return this.container;
|
||||
this.buttonContainer.appendChild(element);
|
||||
return this.formContainer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user