aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl/directory_header.tpl
blob: 50c29eab9521190c33187917d91936a8f1f70c26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<div class="generic-content-wrapper">
	<div class="section-title-wrapper clearfix">
		<div class="btn-group float-end">
			<button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="{{$sort}}">
				<i class="bi bi-arrow-down-up"></i>
			</button>
			<div class="dropdown-menu dropdown-menu-end">
				<a class="dropdown-item" href="directory?f=&order=date{{$suggest}}">{{$date}}</a>
				<a class="dropdown-item" href="directory?f=&order=normal{{$suggest}}">{{$normal}}</a>
				<a class="dropdown-item" href="directory?f=&order=reversedate{{$suggest}}">{{$reversedate}}</a>
				<a class="dropdown-item" href="directory?f=&order=reverse{{$suggest}}">{{$reverse}}</a>
			</div>
		</div>
		<h2>{{$dirlbl}}{{if $search}}:&nbsp;{{$safetxt}}{{/if}}</h2>
	</div>
	{{foreach $entries as $entry}}
		{{include file="direntry.tpl"}}
	{{/foreach}}
	{{** make sure this element is at the bottom - we rely on that in endless scroll **}}
	<div id="page-end" class="float-start w-100"></div>
</div>
<div id="page-spinner" class="spinner-wrapper">
	<div class="spinner m"></div>
</div>
<script>
	$(document).ready(function() {
		loadingPage = false;
		{{if $directory_admin}}
		$(document).on('click', '.directory-censor', function (e) {
			e.preventDefault();

			let that = this;
			let url;
			let path;
			let severity;
			let parent = this.closest('.directory-actions');
			let el;

			url = new URL(that.href)

			severity = url.searchParams.get('severity');
			path = url.pathname;

			console.log(url.searchParams.get('severity'));

			$.get(
				path,
				{
					aj: 1,
					severity : severity
				},
				function(data) {
					console.log(data)
					if (data.success) {

						if (that.classList.contains('directory-censor-unsafe')) {
							severity = data.flag ? 0 : 1;
							el = parent.getElementsByClassName('directory-censor-hide')[0];
							if (el.classList.contains('active')) {
								el.classList.toggle('active');
								url.searchParams.set('severity', 2);
								el.href = url.toString();
							}
						}

						if (that.classList.contains('directory-censor-hide')) {
							severity = data.flag ? 0 : 2;
							el = parent.getElementsByClassName('directory-censor-unsafe')[0];
							if (el.classList.contains('active')) {
								el.classList.toggle('active');
								url.searchParams.set('severity', 1);
								el.href = url.toString();
							}
						}

						url.searchParams.set('severity', severity);
						that.href = url.toString();
						that.classList.toggle('active');

					}
				}
			);
		});
		{{/if}}
	});
</script>