Rework categories and stuff
This commit is contained in:
		
							
								
								
									
										31
									
								
								indexer.py
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								indexer.py
									
									
									
									
									
								
							@@ -11,26 +11,29 @@ app = Flask(__name__)
 | 
				
			|||||||
strings = None
 | 
					strings = None
 | 
				
			||||||
settings = None
 | 
					settings = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_categories():
 | 
				
			||||||
 | 
						return settings["categories"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route("/")
 | 
					@app.route("/")
 | 
				
			||||||
def index():
 | 
					def index():
 | 
				
			||||||
	return render_template("search.html", language="english", categories=settings["categories"], strings=strings)
 | 
						return render_template("search.html", language="english", categories=get_categories(), strings=strings)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route("/categories")
 | 
					@app.route("/categories")
 | 
				
			||||||
def categorys():
 | 
					def categorys():
 | 
				
			||||||
	global strings
 | 
						global strings
 | 
				
			||||||
	return render_template("categories.html", categories=settings["categories"], strings=strings)
 | 
						return render_template("categories.html", categories=get_categories(), strings=strings)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route("/create", methods=['GET','POST'])
 | 
					@app.route("/create", methods=['GET','POST'])
 | 
				
			||||||
def create():
 | 
					def create():
 | 
				
			||||||
	if request.method == "GET":
 | 
						if request.method == "GET":
 | 
				
			||||||
		return render_template("create.html", language="english", categories=settings["categories"], strings=strings, errors=None)
 | 
							return render_template("create.html", language="english", categories=get_categories(), strings=strings, errors=None)
 | 
				
			||||||
	elif request.method == "POST":
 | 
						elif request.method == "POST":
 | 
				
			||||||
		newTorrent = createNewTorrent(request)
 | 
							newTorrent = createNewTorrent(request)
 | 
				
			||||||
		if len(newTorrent.errors) == 0:
 | 
							if len(newTorrent.errors) == 0:
 | 
				
			||||||
			message = "Successfully created torrent <a href=\"/search?h={}\">{}</a>".format(newTorrent.fileid, newTorrent.fileid[:-20])
 | 
								message = "Successfully created torrent <a href=\"/search?h={}\">{}</a>".format(newTorrent.fileid, newTorrent.fileid[:-20])
 | 
				
			||||||
			return render_template("create.html", language="english", categories=settings["categories"], strings=strings, messages=[message])
 | 
								return render_template("create.html", language="english", categories=get_categories(), strings=strings, messages=[message])
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			return render_template("create.html", language="english", categories=settings["categories"], strings=strings, errors=newTorrent.errors)
 | 
								return render_template("create.html", language="english", categories=get_categories(), strings=strings, errors=newTorrent.errors)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route("/download/<filename>")
 | 
					@app.route("/download/<filename>")
 | 
				
			||||||
def download(filename):
 | 
					def download(filename):
 | 
				
			||||||
@@ -72,20 +75,18 @@ def search():
 | 
				
			|||||||
				search += " AND ".join(["torrents.fileid LIKE (?)"] * len(query.split(" ")))
 | 
									search += " AND ".join(["torrents.fileid LIKE (?)"] * len(query.split(" ")))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	print(search)
 | 
						print(search)
 | 
				
			||||||
	#c.execute("SELECT torrents.fileid, torrents.name, metadata.torrentsize FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE " + search, search_params)
 | 
					 | 
				
			||||||
	#results = c.fetchall()
 | 
					 | 
				
			||||||
	results = list()
 | 
						results = list()
 | 
				
			||||||
	for row in c.execute("SELECT torrents.fileid, torrents.name, metadata.torrentsize FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE " + search, search_params):
 | 
						for row in c.execute("SELECT torrents.fileid, torrents.name, metadata.torrentsize FROM torrents LEFT JOIN metadata on metadata.fileid = torrents.fileid WHERE " + search, search_params):
 | 
				
			||||||
		r = row[0:2] + (size(float(row[2])) , )  + row[3:]
 | 
							r = row[0:2] + (size(float(row[2])) , )  + row[3:]
 | 
				
			||||||
		results.append(r)
 | 
							results.append(r)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return render_template("result.html", results=results, strings=strings, language="english", categories=settings["categories"])
 | 
						return render_template("result.html", results=results, strings=strings, language="english", categories=get_categories())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.route("/details", methods=['GET'])
 | 
					@app.route("/details", methods=['GET'])
 | 
				
			||||||
def details():
 | 
					def details():
 | 
				
			||||||
	info_hash = request.args["h"]
 | 
						info_hash = request.args["h"]
 | 
				
			||||||
	print(info_hash)
 | 
						print(info_hash)
 | 
				
			||||||
	return render_template("details.html", strings=strings, language="english", categories=settings["categories"])
 | 
						return render_template("details.html", strings=strings, language="english", categories=get_categories())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def scrapeAll():
 | 
					def scrapeAll():
 | 
				
			||||||
	TRACKER_URL = "http://tracker.lootbox.cf:6969/"
 | 
						TRACKER_URL = "http://tracker.lootbox.cf:6969/"
 | 
				
			||||||
@@ -171,17 +172,17 @@ class Metadata():
 | 
				
			|||||||
			torrent = f.read()
 | 
								torrent = f.read()
 | 
				
			||||||
		self.fileid = fileid
 | 
							self.fileid = fileid
 | 
				
			||||||
		self.bcoded = bencoder.decode(torrent)
 | 
							self.bcoded = bencoder.decode(torrent)
 | 
				
			||||||
		self.created_by = self.bcoded.get(b'created by', "")
 | 
							self.created_by = self.bcoded.get(b'created by', b"")
 | 
				
			||||||
		self.creation_date = self.bcoded.get(b'creation date', "")
 | 
							self.creation_date = self.bcoded.get(b'creation date', b"")
 | 
				
			||||||
		self.announce_url = self.bcoded.get(b'info', dict()).get(b'', "")
 | 
							self.announce_url = self.bcoded.get(b'info', dict()).get(b'', "")
 | 
				
			||||||
		self.source = self.bcoded.get(b'info', dict()).get(b'source', "")
 | 
							self.source = self.bcoded.get(b'info', dict()).get(b'source', b"")
 | 
				
			||||||
		self.torrentsize = ((len(self.bcoded.get(b'info', dict()).get(b'pieces', "")) / 20) * self.bcoded.get(b'info', dict()).get(b'piece length'))
 | 
							self.torrentsize = ((len(self.bcoded.get(b'info', dict()).get(b'pieces', "")) / 20) * self.bcoded.get(b'info', dict()).get(b'piece length'))
 | 
				
			||||||
		self.name = self.bcoded.get(b'info', dict()).get(b'name', "")
 | 
							self.name = self.bcoded.get(b'info', dict()).get(b'name', b"")
 | 
				
			||||||
		self.private = self.bcoded.get(b'info', dict()).get(b'private', "")
 | 
							self.private = self.bcoded.get(b'info', dict()).get(b'private', b"")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def writeToDb(self, cursor):
 | 
						def writeToDb(self, cursor):
 | 
				
			||||||
		c = cursor
 | 
							c = cursor
 | 
				
			||||||
		b64created_by = base64.b64encode(self.created_by)
 | 
							b64created_by = base64.b64encode(self.created_by) if self.created_by else ""
 | 
				
			||||||
		b64announce_url = base64.b64encode(self.announce_url.decode()) if self.announce_url else ""
 | 
							b64announce_url = base64.b64encode(self.announce_url.decode()) if self.announce_url else ""
 | 
				
			||||||
		b64source = base64.b64encode(self.source) if self.source else ""
 | 
							b64source = base64.b64encode(self.source) if self.source else ""
 | 
				
			||||||
		b64name = base64.b64encode(self.name)
 | 
							b64name = base64.b64encode(self.name)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										195
									
								
								settings.json
									
									
									
									
									
								
							
							
						
						
									
										195
									
								
								settings.json
									
									
									
									
									
								
							@@ -1,10 +1,189 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	"categories": {
 | 
						"categories": [
 | 
				
			||||||
		"audio" : [ "lossless", "lossy", "audiobooks", "other" ],
 | 
							{
 | 
				
			||||||
		"video" : [ "movies_3d", "movies_4k", "movies_hd", "movies_sd", "series_hd", "series_sd", "clips", "other" ],
 | 
								"id": 1,
 | 
				
			||||||
		"porn" : [ "movies_3d", "movies_4k", "movies_hd", "movies_sd", "series_hd", "series_sd", "clips", "pictures", "other" ],
 | 
								"label": "Audio",
 | 
				
			||||||
		"games" : [ "pc", "mac", "ios", "android", "consoles", "other" ],
 | 
								"subcategories": [
 | 
				
			||||||
		"applications" : [ "windows", "mac", "unix", "ios", "android", "other" ],
 | 
									{
 | 
				
			||||||
		"other" : [ "ebooks", "comics", "pictures", "other" ]
 | 
										"id": 1,
 | 
				
			||||||
	}
 | 
										"label": "Lossless"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 2,
 | 
				
			||||||
 | 
										"label": "Lossy"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 3,
 | 
				
			||||||
 | 
										"label": "Audio book"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 4,
 | 
				
			||||||
 | 
										"label": "Other"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"id": 2,
 | 
				
			||||||
 | 
								"label": "Video",
 | 
				
			||||||
 | 
								"subcategories": [
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 5,
 | 
				
			||||||
 | 
										"label": "3D Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 6,
 | 
				
			||||||
 | 
										"label": "4k Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 7,
 | 
				
			||||||
 | 
										"label": "HD Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 8,
 | 
				
			||||||
 | 
										"label": "SD Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 9,
 | 
				
			||||||
 | 
										"label": "HD Series"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 10,
 | 
				
			||||||
 | 
										"label": "SD Series"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 11,
 | 
				
			||||||
 | 
										"label": "Clip"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 12,
 | 
				
			||||||
 | 
										"label": "Other"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"id": 3,
 | 
				
			||||||
 | 
								"label": "Porn",
 | 
				
			||||||
 | 
								"subcategories": [
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 13,
 | 
				
			||||||
 | 
										"label": "3D Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 14,
 | 
				
			||||||
 | 
										"label": "4k Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 15,
 | 
				
			||||||
 | 
										"label": "HD Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 16,
 | 
				
			||||||
 | 
										"label": "SD Movie"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 17,
 | 
				
			||||||
 | 
										"label": "HD Series"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 18,
 | 
				
			||||||
 | 
										"label": "SD Series"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 19,
 | 
				
			||||||
 | 
										"label": "Clip"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 20,
 | 
				
			||||||
 | 
										"label": "Pictures"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 21,
 | 
				
			||||||
 | 
										"label": "Other"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"id": 4,
 | 
				
			||||||
 | 
								"label": "Games",
 | 
				
			||||||
 | 
								"subcategories": [
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 22,
 | 
				
			||||||
 | 
										"label": "Windows"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 23,
 | 
				
			||||||
 | 
										"label": "Mac"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 24,
 | 
				
			||||||
 | 
										"label": "iOS"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 25,
 | 
				
			||||||
 | 
										"label": "Android"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 26,
 | 
				
			||||||
 | 
										"label": "Consoles"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 27,
 | 
				
			||||||
 | 
										"label": "Other"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"id": 5,
 | 
				
			||||||
 | 
								"label": "Application",
 | 
				
			||||||
 | 
								"subcategories": [
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 28,
 | 
				
			||||||
 | 
										"label": "Windows"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 29,
 | 
				
			||||||
 | 
										"label": "Mac"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 30,
 | 
				
			||||||
 | 
										"label": "*nix"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 31,
 | 
				
			||||||
 | 
										"label": "iOS"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 32,
 | 
				
			||||||
 | 
										"label": "Android"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 33,
 | 
				
			||||||
 | 
										"label": "Other"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"id": 6,
 | 
				
			||||||
 | 
								"label": "Other",
 | 
				
			||||||
 | 
								"subcategories": [
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 34,
 | 
				
			||||||
 | 
										"label": "eBook"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 35,
 | 
				
			||||||
 | 
										"label": "Comic"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 36,
 | 
				
			||||||
 | 
										"label": "Picture"
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										"id": 37,
 | 
				
			||||||
 | 
										"label": "Other"
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						]
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,19 +1,12 @@
 | 
				
			|||||||
window.onload = function () {
 | 
					window.onload = function () {
 | 
				
			||||||
	$('.dropdown li > a').click(function(e){
 | 
						$('#subcategory').prop('disabled', true);
 | 
				
			||||||
		setDropdownButtonText(this.innerHTML, this.parentElement.parentElement.parentElement) //set the display-text to the selected value
 | 
						$('#category').change(function() {
 | 
				
			||||||
		fillDropdownByValue(this.innerHTML, $(".dropdown")["1"])
 | 
							fillSubcategory(this.value)
 | 
				
			||||||
		this.parentElement.parentElement.parentElement.classList.remove("open");
 | 
					 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	customizeUploadButton()
 | 
						customizeUploadButton()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function setDropdownButtonText(text, dropdownButton) {
 | 
					 | 
				
			||||||
	var dropdownTextSpan = dropdownButton.getElementsByClassName("text")[0]
 | 
					 | 
				
			||||||
	dropdownTextSpan.innerHTML = text
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function sortCategories(categories) {
 | 
					function sortCategories(categories) {
 | 
				
			||||||
	var sortedCategories = []
 | 
						var sortedCategories = []
 | 
				
			||||||
	for(var key in categories) {
 | 
						for(var key in categories) {
 | 
				
			||||||
@@ -80,33 +73,28 @@ function fillDetectedFilelist(file) {
 | 
				
			|||||||
	reader.readAsArrayBuffer(file)
 | 
						reader.readAsArrayBuffer(file)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Fill a defined dropdown with values.
 | 
					function fillSubcategory(value) {
 | 
				
			||||||
// These values will be generated out of the categories.json
 | 
						var subSelect = $('#subcategory')
 | 
				
			||||||
function fillDropdownByValue(value, dropdownToFill) {
 | 
						subSelect.empty();
 | 
				
			||||||
	dropdownToFill.getElementsByTagName("button")[0].disabled = false
 | 
						subSelect.append($('<option value="-1" selected>--- Select Subcategory ---</selected>'))
 | 
				
			||||||
	dropdownToFill.getElementsByClassName("text")[0].innerHTML = "Subcategorie"
 | 
						if (value >= 0) {
 | 
				
			||||||
	var dropdownToFillUl = dropdownToFill.getElementsByClassName("dropdown-menu")[0]
 | 
							var subcategories = null
 | 
				
			||||||
	dropdownToFillUl.innerHTML = ""
 | 
							for(var i = 0; i < global_categories.length; i++) {
 | 
				
			||||||
	valueDescriptor = getDescriptorByLocalString("english", value)
 | 
								if (global_categories[i]["id"] == value) {
 | 
				
			||||||
	subcategories = global_categories[valueDescriptor]
 | 
									subcategories = global_categories[i]["subcategories"]
 | 
				
			||||||
	subcategories = sortCategories(subcategories)
 | 
									break
 | 
				
			||||||
	for(subcategoryIndex in subcategories) {
 | 
								}
 | 
				
			||||||
		subcategoryLocalString = getLocalString("english", subcategories[subcategoryIndex])
 | 
							}
 | 
				
			||||||
		var newEntry = document.createElement("li")
 | 
							if(subcategories) {
 | 
				
			||||||
		var newEntryLink = document.createElement("a")
 | 
								for(subcategoryIndex in subcategories) {
 | 
				
			||||||
		newEntry.setAttribute("role", "presentation")
 | 
									var subcategoryId = subcategories[subcategoryIndex]["id"]
 | 
				
			||||||
		newEntryLink.setAttribute("role", "menuitem")
 | 
									var subcategoryLocalString = subcategories[subcategoryIndex]["label"]
 | 
				
			||||||
		newEntryLink.tabIndex = -1
 | 
									var node = $('<option value="'+subcategoryId+'">'+subcategoryLocalString+'</string>')
 | 
				
			||||||
		newEntryLink.href = "#"
 | 
									subSelect.append(node)
 | 
				
			||||||
		newEntryLink.innerHTML = subcategoryLocalString
 | 
								}
 | 
				
			||||||
		newEntryLink.onclick = function(e){
 | 
					 | 
				
			||||||
			setDropdownButtonText(this.innerHTML, this.parentElement.parentElement.parentElement)
 | 
					 | 
				
			||||||
			this.parentElement.parentElement.parentElement.classList.remove("open");
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		newEntry.appendChild(newEntryLink)
 | 
					 | 
				
			||||||
		dropdownToFillUl.appendChild(newEntry)
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						subSelect.prop('disabled', value < 0)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Hides the default browser-upload-form and replaces it by an button
 | 
					// Hides the default browser-upload-form and replaces it by an button
 | 
				
			||||||
@@ -129,19 +117,11 @@ function setButtonToFilename(event) {
 | 
				
			|||||||
	});
 | 
						});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Sets the text of a given dropdown-button to a given value
 | 
					 | 
				
			||||||
function setDropdownButtonText(text, dropdownButton) {
 | 
					 | 
				
			||||||
	var dropdownTextSpan = dropdownButton.getElementsByClassName("text")[0]
 | 
					 | 
				
			||||||
	dropdownHiddenValue = dropdownButton.getElementsByTagName("input")[0]
 | 
					 | 
				
			||||||
	dropdownHiddenValue.setAttribute("value", getDescriptorByLocalString("english", text))
 | 
					 | 
				
			||||||
	dropdownTextSpan.innerHTML = text
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
function validateForm() {
 | 
					function validateForm() {
 | 
				
			||||||
	valid = true
 | 
						valid = true
 | 
				
			||||||
	file = document.querySelectorAll("input.file")[0]
 | 
						file = document.querySelectorAll("input.file")[0]
 | 
				
			||||||
	category = document.querySelectorAll("input.category")[0]
 | 
						category = document.querySelectorAll("#category")[0]
 | 
				
			||||||
	subcategory = document.querySelectorAll("input.subcategory")[0]
 | 
						subcategory = document.querySelectorAll("#subcategory")[0]
 | 
				
			||||||
	torrentname = document.querySelectorAll("input.name")[0]
 | 
						torrentname = document.querySelectorAll("input.name")[0]
 | 
				
			||||||
	description = document.querySelectorAll("textarea.description")[0]
 | 
						description = document.querySelectorAll("textarea.description")[0]
 | 
				
			||||||
	if(file.value.length <= 0) {
 | 
						if(file.value.length <= 0) {
 | 
				
			||||||
@@ -153,7 +133,7 @@ function validateForm() {
 | 
				
			|||||||
		file.parentElement.parentElement.classList.remove("has-error")
 | 
							file.parentElement.parentElement.classList.remove("has-error")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(category.value.length <= 0) {
 | 
						if(category.value < 0) {
 | 
				
			||||||
		valid = false
 | 
							valid = false
 | 
				
			||||||
		category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.add("has-error")
 | 
							category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.add("has-error")
 | 
				
			||||||
		category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.remove("has-success")
 | 
							category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.remove("has-success")
 | 
				
			||||||
@@ -162,7 +142,7 @@ function validateForm() {
 | 
				
			|||||||
		category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.remove("has-error")
 | 
							category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.remove("has-error")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(subcategory.value.length <= 0) {
 | 
						if(subcategory.value < 0) {
 | 
				
			||||||
		valid = false
 | 
							valid = false
 | 
				
			||||||
		category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.add("has-error")
 | 
							category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.add("has-error")
 | 
				
			||||||
		category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.remove("has-success")
 | 
							category.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.classList.remove("has-success")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,11 +12,11 @@ vim: ts=2 noexpandtab
 | 
				
			|||||||
		<div>
 | 
							<div>
 | 
				
			||||||
			<ul>
 | 
								<ul>
 | 
				
			||||||
				<li>
 | 
									<li>
 | 
				
			||||||
					<a href="search?c={{ category }}">{{ category }}</a>
 | 
										<a href="search?c={{ category.id }}">{{ category.label }}</a>
 | 
				
			||||||
					<ul>
 | 
										<ul>
 | 
				
			||||||
					{% for sub_category in categories[category] %}
 | 
										{% for sub_category in category.subcategories %}
 | 
				
			||||||
						<li>
 | 
											<li>
 | 
				
			||||||
						<a href="search?s={{ sub_category }}">{{ sub_category }}</a>
 | 
											<a href="search?s={{ sub_category.id }}">{{ sub_category.label }}</a>
 | 
				
			||||||
						</li>
 | 
											</li>
 | 
				
			||||||
					{% endfor %}
 | 
										{% endfor %}
 | 
				
			||||||
					</ul>
 | 
										</ul>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,29 +57,17 @@ vim: ts=2 noexpandtab
 | 
				
			|||||||
				<div class="col-sm-9">
 | 
									<div class="col-sm-9">
 | 
				
			||||||
					<div class="row row-container">
 | 
										<div class="row row-container">
 | 
				
			||||||
						<div class="col-md-6 category-column">
 | 
											<div class="col-md-6 category-column">
 | 
				
			||||||
							<div class="dropdown">
 | 
												<select class="form-control dropdown" id="category" name="category">
 | 
				
			||||||
								<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
 | 
													<option value="-1" selected>--- Select Category ---</option>
 | 
				
			||||||
									<span class="text">{{ getLocalString(language, "category") }}</span>
 | 
												{% for category in categories %}
 | 
				
			||||||
									<span class="caret"></span>
 | 
													<option value="{{ category.id }}">{{ category.label }}</option>
 | 
				
			||||||
									<input type="hidden" name="category" class="category">
 | 
												{% endfor %}
 | 
				
			||||||
								</button>
 | 
												</select>
 | 
				
			||||||
								<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
 | 
					 | 
				
			||||||
									{% for category in sorted(categories.keys()) %}
 | 
					 | 
				
			||||||
									<li role="presentation"><a role="menuitem" tabindex="-1" href="#">{{ getLocalString(language, category) }}</a></li>
 | 
					 | 
				
			||||||
									{% endfor %}
 | 
					 | 
				
			||||||
								</ul>
 | 
					 | 
				
			||||||
							</div>
 | 
					 | 
				
			||||||
						</div>
 | 
											</div>
 | 
				
			||||||
						<div class="col-md-6 subcategory-column">
 | 
											<div class="col-md-6 subcategory-column">
 | 
				
			||||||
							<div class="dropdown">
 | 
												<select class="form-control dropdown" id="subcategory" name="subcategory">
 | 
				
			||||||
								<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true" disabled>
 | 
													<option value="-1" selected>--- Select Subcategory ---</option>
 | 
				
			||||||
									<span class="text">{{ getLocalString(language, "subcategory") }}</span>
 | 
												</select>
 | 
				
			||||||
									<span class="caret"></span>
 | 
					 | 
				
			||||||
									<input type="hidden" name="subcategory" class="subcategory">
 | 
					 | 
				
			||||||
								</button>
 | 
					 | 
				
			||||||
								<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
 | 
					 | 
				
			||||||
								</ul>
 | 
					 | 
				
			||||||
							</div>
 | 
					 | 
				
			||||||
						</div>
 | 
											</div>
 | 
				
			||||||
					</div>
 | 
										</div>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user