added tags

This commit is contained in:
DerTyp187
2021-11-11 18:40:50 +01:00
parent faef6f16ba
commit 43eac1907d
4 changed files with 29 additions and 7 deletions

View File

@@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-11 07:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0003_topic_version'),
]
operations = [
migrations.AddField(
model_name='topic',
name='tags',
field=models.CharField(blank=True, max_length=200),
),
]

View File

@@ -16,6 +16,7 @@ class Topic(models.Model):
date_created = models.DateTimeField(default=timezone.now)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
version = models.CharField(max_length=100, blank=True)
tags = models.CharField(max_length=200, blank=True)
def __str__(self):
return self.category.title + " - " + self.title

View File

@@ -137,8 +137,8 @@ body main #main-content .note p{
#button-content div{
height: 60px;
width: 200px;
margin-left: 25px;
width: 150px;
margin-left: 60px;
display: block;
float:left;
}
@@ -150,8 +150,8 @@ body main #main-content .note p{
font-size: 13pt;
font-weight: bold;
text-decoration: none;
padding-top: 15px;
padding-bottom: 15px;
padding-top: 10px;
padding-bottom: 10px;
background-color: rgba(95, 255, 175, 0.1);
border: 5px solid rgb(34, 102, 71);
transition: 0.1s;

View File

@@ -19,6 +19,7 @@
<div class="list-item" onclick="openTopic('{{ topic.title }}')">
<!--<img src="c_icon.png"/>-->
<p>{{ topic.title }}</p>
<small style="display:none;">{{ topic.tags }}</small>
</div>
{% endfor %}
@@ -33,10 +34,12 @@
for (let index = 0; index < items.length; index++) {
const item = items[index];
const p = item.getElementsByTagName("p")[0];
item.style.display = "none";
const tags = item.getElementsByTagName("small")[0].innerHTML;
var value = input.value.toLowerCase().replace(".", "").replace(";", "").replace(",", "").replace(" ", "")
if(p.innerHTML.toLowerCase().includes(input.value.toLowerCase())){
item.style.display = "none";
if(p.innerHTML.toLowerCase().includes(value) || tags.toLowerCase().includes(value)){
item.style.display = "block";
}