diff --git a/README.md b/README.md index 0d37dec..2d99090 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Adlerka.Top +# Adlerka.space -The code for https://adlerka.top +The code for https://adlerka.space [![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) diff --git a/assets/3rdparty/sliderm.js b/assets/3rdparty/sliderm.js index 94696d6..60db632 100644 --- a/assets/3rdparty/sliderm.js +++ b/assets/3rdparty/sliderm.js @@ -28,7 +28,7 @@ } var r = function bold(t) { - var e = {1: "thin", 2: "regular", 3: "bold"}; + const e = {1: "thin", 2: "regular", 3: "bold"}; return void 0 !== e[t] ? e[t] : "regular" }, a = function shape(t) { return "none" === t || "square" === t ? t : "circle" @@ -43,7 +43,7 @@ }; function queue(t) { - var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0; + const e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0; return setTimeout((function () { t() }), e) @@ -52,36 +52,41 @@ var p = [function breakpoint(t, e) { if (t.getOption("breakpoint")) { !function init() { - var n = t.getOption("columns"), o = t.getOption("breakpoint.columns"), + const n = t.getOption("columns"), o = t.getOption("breakpoint.columns"), i = Number(e.getAttribute("data-columns")), r = function calculate(t, e) { - var n = window.innerWidth, o = Object.keys(t).filter((function (e) { + const n = window.innerWidth, o = Object.keys(t).filter((function (e) { return n < t[e] })); return void 0 !== o[0] ? Number(o[0]) : e }(o, n); if (e.setAttribute("data-columns", n), void 0 !== r && i !== r) { - var a = t.getItems(); + const a = t.getItems(); t.updateOption("columns", r), t.updateCurrentItems(); - for (var s = 0; s < a.length; s += 1) t.go("columns", a[s]); + for (let s = 0; s < a.length; s += 1) t.go("columns", a[s]); t.emit("breakpoint.changed") } }() } }, function transition(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i]; - var r = o[0], a = t.getOption("duration"); + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let i = 2; + for (; i < n; i++) o[i - 2] = arguments[i]; + const r = o[0], a = t.getOption("duration"); "stop" !== r ? (e.style.setProperty("transition-duration", "".concat(a, "ms")), t.on("destory", (function () { e.style.removeProperty("transition-duration") }))) : e.style.removeProperty("transition-duration") }, function transform(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i]; - var r = o[0]; + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let i = 2; + for (; i < n; i++) o[i - 2] = arguments[i]; + const r = o[0]; e.style.setProperty("transform", "translateX(".concat(r, "px)")), t.on("destory", (function () { e.style.removeProperty("transform") })) }, function autoplay(t) { if (t.getOption("autoplay")) { - var e = t.getOption("autoplay.duration"), n = "left" === t.getOption("autoplay.direction") ? "<" : ">", + const e = t.getOption("autoplay.duration"), + n = "left" === t.getOption("autoplay.direction") ? "<" : ">", o = function repeat(t) { return setInterval((function () { t() @@ -96,86 +101,99 @@ })) } }, function grouping(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i]; - var r = o[0], a = o[1], s = t.getOption("grouping"), l = a + 1; + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let i = 2; + for (; i < n; i++) o[i - 2] = arguments[i]; + const r = o[0], a = o[1], s = t.getOption("grouping"), l = a + 1; if (s) { - var u = t.getOption("columns"), c = Math.ceil((a + 1) / u); + const u = t.getOption("columns"), c = Math.ceil((a + 1) / u); r.setAttribute("data-order", c) } else r.setAttribute("data-order", l); t.on("destory", (function () { r.removeAttribute("data-order") })) }, function columns(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i]; - var r = o[0], a = t.getOption("columns"), s = parseFloat((1 / a * 100).toFixed(2)); + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let i = 2; + for (; i < n; i++) o[i - 2] = arguments[i]; + const r = o[0], a = t.getOption("columns"), s = parseFloat((1 / a * 100).toFixed(2)); r.style.setProperty("flex", "0 0 ".concat(s, "%")), t.on("destory", (function () { r.style.removeProperty("flex") })) }, function preview(t, e) { if (t.getOption("preview")) { - var n = t.getOption("preview.edge"); + const n = t.getOption("preview.edge"); e.style.setProperty("padding", "0 ".concat(n, "px")), t.on("destory", (function () { e.style.removeProperty("padding") })) } }, function spacing(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i]; - var r = o[0], a = Math.floor(t.getOption("spacing") / 2); + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let i = 2; + for (; i < n; i++) o[i - 2] = arguments[i]; + const r = o[0], a = Math.floor(t.getOption("spacing") / 2); r.style.setProperty("padding", "0px ".concat(a, "px")), t.on("destory", (function () { r.style.removeProperty("padding") })) }, function align(t, e) { - var n = t.getOption("align"); + const n = t.getOption("align"); "center" === n ? e.style.setProperty("align-items", "center") : "bottom" === n && e.style.setProperty("align-items", "flex-end"), t.on("destory", (function () { e.style.removeProperty("align-items") })) }, function touch(t, e) { if (t.getOption("touch")) { !function init() { - var n = t.getOption("touch.threshold"), o = t.getOption("touch.duration"), i = t.adaptEvent(e), + const n = t.getOption("touch.threshold"), o = t.getOption("touch.duration"), i = t.adaptEvent(e), r = {x: 0, y: 0, time: 0}; i.on("touchstart", (function (t) { t.preventDefault(); - var e = t.changedTouches[0]; + const e = t.changedTouches[0]; r.x = e.pageX, r.y = e.pageY, r.time = (new Date).getTime() })), i.on("touchmove", (function (t) { t.preventDefault() })), i.on("touchend", (function (e) { e.preventDefault(); - var i = e.changedTouches[0], a = (new Date).getTime() - r.time, s = Math.abs(i.pageX - r.x); + const i = e.changedTouches[0], a = (new Date).getTime() - r.time, s = Math.abs(i.pageX - r.x); if (!(a > o || s < n)) { - var l = i.pageX > r.x ? ">" : "<"; + const l = i.pageX > r.x ? ">" : "<"; t.slideTo(l) } })) }() } }, function clone(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), r = 2; r < n; r++) o[r - 2] = arguments[r]; - var a = o[0], s = o[1], l = t.getOption("columns"), u = t.getOption("preview"), c = t.getOption("loop"); + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let r = 2; + for (; r < n; r++) o[r - 2] = arguments[r]; + const a = o[0], s = o[1], l = t.getOption("columns"), u = t.getOption("preview"), c = t.getOption("loop"); if (u || c) { - var p = t.getItemCount(), d = t.getItems(), f = l, h = a.cloneNode(!0), v = null, m = !1; + const p = t.getItemCount(), d = t.getItems(), f = l, h = a.cloneNode(!0); + let v = null, m = !1; h.classList.add(i), s < f && (e.appendChild(h), m = !0), s >= p - f && (m ? ((v = a.cloneNode(!0)).classList.add(i), e.insertBefore(v, d[0])) : e.insertBefore(h, d[0])), t.on("destory", (function () { h.remove(), v && v.remove() })) } }, function slide(t, e) { - for (var n = arguments.length, o = new Array(n > 2 ? n - 2 : 0), i = 2; i < n; i++) o[i - 2] = arguments[i]; - var r = o[0], a = o[1], s = t.getOption("grouping"), l = t.getOption("preview"), + const n = arguments.length, o = new Array(n > 2 ? n - 2 : 0); + let i = 2; + for (; i < n; i++) o[i - 2] = arguments[i]; + const r = o[0], a = o[1], s = t.getOption("grouping"), l = t.getOption("preview"), u = t.getOption("duration"), c = t.getOption("columns"), p = t.getOption("loop"), - d = t.getItems()[0].offsetWidth, f = t.getPage(), h = p || l, v = f.maximum(), m = f.calculate(r, !1), - g = m < 1 || m > v, y = 0; + d = t.getItems()[0].offsetWidth, f = t.getPage(), h = p || l, v = f.maximum(); + let m = f.calculate(r, !1); + const g = m < 1 || m > v; + let y = 0; !p && g || (y = s ? d * (0 - (h ? 0 : -1) - m) * c : d * (1 - (h ? c : 0) - m), t.emit("slide.start"), t.go("transition", a), t.go("transform", y), t.updatePosition(m), g ? queue((function () { m = f.calculate(r, g), y = s ? d * (0 - m) * c : d * (1 - c - m), t.go("transition", "stop"), t.go("transform", y), t.updatePosition(m), t.emit("slide.end") }), u + 10) : t.emit("slide.end")) }, function loop(t, e) { - var n = t.getOption("loop"), o = t.getOption("grouping"); + const n = t.getOption("loop"), o = t.getOption("grouping"); if (n && o) { - var i = t.getItems(), r = t.getOption("columns"), a = t.getItemCount(), s = i[i.length - 1], + const i = t.getItems(), r = t.getOption("columns"), a = t.getItemCount(), s = i[i.length - 1], l = r - a % r, u = []; if (l !== r && 1 !== r) { - for (var c = 1; c <= l; c += 1) { - var p = s.cloneNode(!0); + for (let c = 1; c <= l; c += 1) { + const p = s.cloneNode(!0); p.classList.add("sliderm__slide--empty"), p.innerHTML = "", e.appendChild(p), u.push(p) } t.updateCurrentItems(), t.on("destory", (function () { @@ -186,32 +204,35 @@ } } }, function init(e) { - var n = e.getOption("duration"), o = e.getRoot(); + const n = e.getOption("duration"), o = e.getRoot(); o.classList.add(t), o.classList.remove("".concat(t, "--initialized")), o.classList.add("".concat(t, "--initialize")), e.on("initialized", (function () { queue((function () { o.classList.remove("".concat(t, "--initialize")), o.classList.add("".concat(t, "--initialized")) }), n + 50) })) }], d = [function pagination(t) { - var e, i, r, a = function click(e) { + let e, i, r; + const a = function click(e) { if (o === e.target.className) { - var n = Array.prototype.indexOf.call(i.childNodes, e.target) + 1; + const n = Array.prototype.indexOf.call(i.childNodes, e.target) + 1; t.slideTo(n) } - }, s = function mark() { - var e = t.getPosition(), o = findDom(t.getRoot(), ".".concat(n)).children; + }; + let s = function mark() { + const e = t.getPosition(), o = findDom(t.getRoot(), ".".concat(n)).children; Array.from(o).forEach((function (t, n) { - var o = n + 1; + const o = n + 1; t.removeAttribute("data-active"), o === e && t.setAttribute("data-active", !0) })) - }, l = function destory() { + }; + const l = function destory() { r.off("click", a), t.off("slide.end", s), i.remove() }, u = function init() { !function render() { - var a = setDom("div", n); + const a = setDom("div", n); e = t.getPage().maximum(); - for (var s = 0; s < e; s += 1) { - var l = setDom("div", o); + for (let s = 0; s < e; s += 1) { + const l = setDom("div", o); 0 === s && l.setAttribute("data-active", !0), a.append(l) } i = a, r = t.adaptEvent(i), t.getRoot().append(i) @@ -224,7 +245,7 @@ })), u() }, function spinner(t) { !function init() { - var e = t.getOption("spinner.color"), n = setDom("div", "sliderm__spinner"); + const e = t.getOption("spinner.color"), n = setDom("div", "sliderm__spinner"); n.style.setProperty("color", e), t.getRoot().append(n), t.on("destory", (function () { n.remove() })) @@ -232,7 +253,7 @@ }, function arrow(t) { !function init() { for (var e = [s, r, a, u, l, c], n = setDom("div", "sliderm__button--previous"), o = setDom("div", "sliderm__button--next"), i = t.adaptEvent(n), p = t.adaptEvent(o), d = null, f = null, h = 0; h < e.length; h += 1) { - var v = e[h].name, m = e[h](t.getOption("arrow.".concat(v))); + let v = e[h].name, m = e[h](t.getOption("arrow.".concat(v))); null !== m && ("bold" === v ? (d = setDom("span", "sliderm__icon-left--".concat(m)), f = setDom("span", "sliderm__icon-right--".concat(m))) : "shape" === v ? (n.classList.add("sliderm__button--".concat(m)), o.classList.add("sliderm__button--".concat(m))) : ("bgColor" === v ? v = "background-color" : "size" === v && (v = "font-size", m = "".concat(m, "px")), n.style.setProperty(v, m), o.style.setProperty(v, m))) } n.append(d), o.append(f), t.getRoot().append(n), t.getRoot().append(o), i.on("click", (function () { @@ -246,8 +267,8 @@ }]; function _defineProperties(t, e) { - for (var n = 0; n < e.length; n++) { - var o = e[n]; + for (let n = 0; n < e.length; n++) { + const o = e[n]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o) } } @@ -267,7 +288,7 @@ } }, { key: "off", value: function off(t, e) { - var n = this; + const n = this; void 0 === e ? delete this.events[t] : this.events[t].forEach((function (o, i) { o === e && n.events[t].splice(i, 1) })) @@ -287,8 +308,8 @@ }(); function event_adapter_defineProperties(t, e) { - for (var n = 0; n < e.length; n++) { - var o = e[n]; + for (let n = 0; n < e.length; n++) { + const o = e[n]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o) } } @@ -316,7 +337,9 @@ } }, { key: "destory", value: function destory() { - for (var t = Object.keys(this.events), e = 0; e < t.length; e += 1) this.off(t[e]); + const t = Object.keys(this.events); + let e = 0; + for (; e < t.length; e += 1) this.off(t[e]); delete this.events } }, { @@ -354,8 +377,8 @@ }; function page_defineProperties(t, e) { - for (var n = 0; n < e.length; n++) { - var o = e[n]; + for (let n = 0; n < e.length; n++) { + const o = e[n]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o) } } @@ -371,19 +394,22 @@ return e && page_defineProperties(t.prototype, e), n && page_defineProperties(t, n), Object.defineProperty(t, "prototype", {writable: !1}), t }(Page, [{ key: "calculate", value: function calculate() { - for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n]; - var o = e[0], i = e[1], r = this.sliderm.getOption("columns"), + const t = arguments.length, e = new Array(t); + let n = 0; + for (; n < t; n++) e[n] = arguments[n]; + const o = e[0], i = e[1], r = this.sliderm.getOption("columns"), a = this.sliderm.getOption("grouping"), s = this.sliderm.getItemCount(), - l = this.sliderm.getGroupCount(), u = this.sliderm.getPosition(), c = a ? l : s, p = u, d = 0; + l = this.sliderm.getGroupCount(), u = this.sliderm.getPosition(), c = a ? l : s; + let p = u, d = 0; if (a) { - var f = Math.ceil(u * r / r); + const f = Math.ceil(u * r / r); p = f } return "number" == typeof o ? d = o : ">" === o ? (d = p + 1) > c && i && (d = 1) : "<" === o && (d = p - 1) <= 0 && i && (d = c), d } }, { key: "maximum", value: function maximum() { - var t = this.sliderm.getOption("loop"), e = this.sliderm.getOption("preview"), + const t = this.sliderm.getOption("loop"), e = this.sliderm.getOption("preview"), n = this.sliderm.getOption("grouping"), o = this.sliderm.getOption("columns"), i = t || e; return n ? this.sliderm.getGroupCount() : i ? this.sliderm.getItemCount() : this.sliderm.getItemCount() - o + 1 } @@ -404,9 +430,11 @@ return function _arrayWithHoles(t) { if (Array.isArray(t)) return t }(t) || function _iterableToArrayLimit(t, e) { - var n = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"]; + let n = null == t ? null : "undefined" != typeof Symbol && t[Symbol.iterator] || t["@@iterator"]; if (null == n) return; - var o, i, r = [], a = !0, s = !1; + let o, i; + const r = []; + let a = !0, s = !1; try { for (n = n.call(t); !(a = (o = n.next()).done) && (r.push(o.value), !e || r.length !== e); a = !0) ; } catch (t) { @@ -427,7 +455,7 @@ function _unsupportedIterableToArray(t, e) { if (t) { if ("string" == typeof t) return _arrayLikeToArray(t, e); - var n = Object.prototype.toString.call(t).slice(8, -1); + let n = Object.prototype.toString.call(t).slice(8, -1); return "Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(t, e) : void 0 } } @@ -439,8 +467,8 @@ } function sliderm_defineProperties(t, e) { - for (var n = 0; n < e.length; n++) { - var o = e[n]; + for (let n = 0; n < e.length; n++) { + const o = e[n]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o) } } @@ -461,7 +489,7 @@ !function sliderm_classCallCheck(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") }(this, Sliderm), _classPrivateMethodInitSpec(this, P), _classPrivateMethodInitSpec(this, b), _classPrivateMethodInitSpec(this, _), _classPrivateMethodInitSpec(this, y), _classPrivateMethodInitSpec(this, g); - var o = getDom(t); + const o = getDom(t); o ? (this.options = Object.assign(v, n), this.event = new f, this.page = new m(this), this.root = o, this.initialized = !1, this.domEvents = [], this.itemCount = 0, this.position = 1, this.modules = {}, this.slider = findDom(this.root, ".".concat(e)), this.items = [], _classPrivateMethodGet(this, g, _initialize2).call(this)) : error('The DOM "'.concat(t, '" is invalid.')) } @@ -469,7 +497,7 @@ return e && sliderm_defineProperties(t.prototype, e), n && sliderm_defineProperties(t, n), Object.defineProperty(t, "prototype", {writable: !1}), t }(Sliderm, [{ key: "adaptEvent", value: function adaptEvent(t) { - var e = new h(t); + const e = new h(t); return this.domEvents.push(e), e } }, { @@ -506,10 +534,10 @@ } }, { key: "getOption", value: function getOption(t) { - var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null, + const e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null, n = void 0 !== this.options[t] ? this.options[t] : e; if (t.includes(".")) try { - var o = t.split("."), i = _slicedToArray(o, 2), r = i[0], a = i[1]; + const o = t.split("."), i = _slicedToArray(o, 2), r = i[0], a = i[1]; return this.options["_".concat(r)][a] } catch (t) { return e @@ -519,7 +547,7 @@ }, { key: "updateOption", value: function updateOption(t, e) { if (t.includes(".")) try { - var n = _slicedToArray(t.split("."), 2), o = n[0], i = n[1]; + const n = _slicedToArray(t.split("."), 2), o = n[0], i = n[1]; this.options["_".concat(o)][i] = e } catch (t) { } else this.options[t] = e @@ -530,7 +558,7 @@ } }, { key: "go", value: function go(t) { - var e; + let e; if (void 0 !== this.modules[t]) { for (var n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++) o[i - 1] = arguments[i]; (e = this.modules)[t].apply(e, [this, this.slider].concat(o)) @@ -547,7 +575,7 @@ }, { key: "emit", value: function emit(t) { for (var e, n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), i = 1; i < n; i++) o[i - 1] = arguments[i]; - var r = [this].concat(o); + const r = [this].concat(o); (e = this.event).emit.apply(e, [t].concat(_toConsumableArray(r))) } }, { @@ -560,15 +588,15 @@ }(); function _initialize2() { - var t = this; + const t = this; this.emit("initialize"), _classPrivateMethodGet(this, _, _updateItems2).call(this), _classPrivateMethodGet(this, b, _updateGroupCount2).call(this), _classPrivateMethodGet(this, P, _beforeMountExtensions2).call(this), _classPrivateMethodGet(this, y, _mountExtensions2).call(this), this.go("init"), this.go("breakpoint"), this.go("loop"), this.go("align"), this.go("touch"), this.go("preview"), this.go("autoplay"), this.items.forEach((function (e, n) { t.go("columns", e), t.go("spacing", e), t.go("grouping", e, n), t.go("clone", e, n) })), this.slideTo(1), this.initialized = !0, this.emit("initialized") } function _mountExtensions2() { - for (var t = 0; t < p.length; t += 1) "function" == typeof p[t] && (this.modules[p[t].name] = p[t]); - for (var e = 0; e < d.length; e += 1) "function" == typeof d[e] && this.getOption(d[e].name) && d[e](this) + for (let t = 0; t < p.length; t += 1) "function" == typeof p[t] && (this.modules[p[t].name] = p[t]); + for (let e = 0; e < d.length; e += 1) "function" == typeof d[e] && this.getOption(d[e].name) && d[e](this) } function _updateItems2() { @@ -576,15 +604,15 @@ } function _updateGroupCount2() { - var t = this.getOption("columns"); + const t = this.getOption("columns"); this.groupCount = Math.ceil(this.itemCount / t) } function _beforeMountExtensions2() { - for (var t = 0; t < this.options.extensions.length; t += 1) { - var e = this.options.extensions[t].name; + for (let t = 0; t < this.options.extensions.length; t += 1) { + const e = this.options.extensions[t].name; if ("" !== e) { - var n = this.options.extensions[t]; + const n = this.options.extensions[t]; void 0 === this.options[e] ? p.push(n) : d.push(n) } } diff --git a/assets/adlerka_client.mrpack b/assets/adlerka_client.mrpack deleted file mode 100644 index 08e68e8..0000000 Binary files a/assets/adlerka_client.mrpack and /dev/null differ diff --git a/assets/images/city.png b/assets/images/city.png deleted file mode 100644 index a6b2bb0..0000000 Binary files a/assets/images/city.png and /dev/null differ diff --git a/assets/images/ye.jpg b/assets/images/ye.jpg deleted file mode 100644 index e3fe833..0000000 Binary files a/assets/images/ye.jpg and /dev/null differ diff --git a/assets/script.js b/assets/script.js index 873e89f..b3df92f 100644 --- a/assets/script.js +++ b/assets/script.js @@ -220,14 +220,6 @@ async function togglearticlecreate() { articleContainerElement.classList.toggle("hidden"); } -async function togglememecreate() { - "use strict"; - let memeContainerElement = document.getElementById("memecreatecontainer"); - - await getMemeImages(); - memeContainerElement.classList.toggle("hidden"); -} - async function renderarticles() { "use strict"; let template = document.querySelector('template[data-template-name="article"]').innerHTML; @@ -313,9 +305,6 @@ async function onPageLoad() { if (currentSite === "account" && currentPage === "files") { await listFiles(); } - if (currentSite === "memes" && currentPage === "index") { - await getMemeImages(); - } await doSlicks(); } @@ -626,142 +615,6 @@ async function listFiles() { await displayList(fileList, "filelist", deleteFile); } } - -async function addMeme() { - let memeTitleElement = document.getElementById("meme_title_input"); - let memeTextElement = document.getElementById("meme_text_input"); - let memeImageElement = document.getElementById("meme_image_input"); - - await doAction("/meme", { - action: "addMeme", - meme_title: memeTitleElement.value, - meme_text: memeTextElement.value, - meme_image_id: memeImageElement.value - }, "Meme bol zmazaný", "Nastala chyba pri mazaní meme-u", false); - memeTitleElement.value = ""; - memeTextElement.value = ""; - memeImageElement.selectedIndex = 0; - await togglememecreate(); -} - -async function deleteMeme(memeId) { - await doAction("/meme", { - action: "deleteMeme", - meme_id: memeId - }, "Meme bol zmazaný", "Nastala chyba pri mazaní meme-u", false); - await softReload(); -} - -async function getMemeImages() { - let memeImageSelector = document.getElementById("meme_image_input"); - let fileList = await getFileList(); - fileList.forEach((item) => { - let option = document.createElement("option"); - option.value = item.ID; - let splitPath = item.Path.split("/"); - option.text = `${splitPath[splitPath.length - 1]} - ID: (${item.ID}) Autor: [${item.UploadedBy} (${item.UploadedByID})]`; - memeImageSelector.appendChild(option); - }); - -} - -async function reloadMemeVotes(memeID) { - let memeVoteCounterElement = document.getElementById(`meme_votes_counter_${memeID}`); - let memeVoteUpvoteElement = document.getElementById(`meme_votes_upvote_${memeID}`); - let memeVoteDownvoteElement = document.getElementById(`meme_votes_downvote_${memeID}`); - let memeVoteUpvoteButtonElement = document.getElementById(`meme_votes_upvote_button_${memeID}`); - let memeVoteDownvoteButtonElement = document.getElementById(`meme_votes_downvote_button_${memeID}`); - - - let memeVoteResponse = await doAction('/meme', { - action: "getMemeVotes", - meme_id: memeID - }, "Počet hlasov k meme-u bol stiahnutý", "Nastala chyba pri sťahovaní počtu hlasov k meme-u", true); - - let memeVotes = memeVoteResponse.NetVotes; - let userVote = memeVoteResponse.UserVote; - memeVoteCounterElement.innerText = memeVotes; - memeVoteCounterElement.classList.remove("positive", "negative", "neutral"); - - if (0 < memeVotes) { - memeVoteCounterElement.classList.add("positive"); - } else if (0 > memeVotes) { - memeVoteCounterElement.classList.add("negative"); - } else { - memeVoteCounterElement.classList.add("neutral"); - } - - memeVoteUpvoteButtonElement.classList.remove('visual_hover'); - memeVoteDownvoteButtonElement.classList.remove('visual_hover'); - let memeUpvoteVariant = "line"; - let memeDownvoteVariant = "line"; - if (0 < userVote) { - memeUpvoteVariant = "fill"; - memeVoteUpvoteButtonElement.classList.add('visual_hover'); - } else if (0 > userVote) { - memeDownvoteVariant = "fill"; - memeVoteDownvoteButtonElement.classList.add('visual_hover'); - } - - await setElementClasses(memeVoteUpvoteElement, [`ri-arrow-up-circle-${memeUpvoteVariant}`]); - await setElementClasses(memeVoteDownvoteElement, [`ri-arrow-down-circle-${memeDownvoteVariant}`]) - -} - -async function voteMeme(memeID, isUpvote) { - let memeVoteUpvoteElement = document.getElementById(`meme_votes_upvote_${memeID}`); - let memeVoteDownvoteElement = document.getElementById(`meme_votes_downvote_${memeID}`); - let memeVoteDelete = false; - if (isUpvote) { - if (memeVoteUpvoteElement.classList.contains("ri-arrow-up-circle-fill")) { - await deleteVoteMeme(memeID); - memeVoteDelete = true; - } - } else { - if (memeVoteDownvoteElement.classList.contains("ri-arrow-down-circle-fill")) { - await deleteVoteMeme(memeID); - memeVoteDelete = true; - } - } - if (!memeVoteDelete) { - await doAction("/meme", { - action: "voteMeme", - meme_id: memeID, - is_upvote: isUpvote - }, "Meme bol votovaný", "Nastala chyba pri votovaný", true); - } - await reloadMemeVotes(memeID); -} - -async function deleteVoteMeme(memeId) { - await doAction("/meme", { - action: "deleteVoteMeme", - meme_id: memeId - }, "Hlas na meme bol zmazaný", "Nastala chyba pri mazaní hlasu na meme", true); - await reloadMemeVotes(memeId); -} - -async function surveySubmit() { - const satisfaction = document.querySelector('input[name="satisfaction"]:checked'); - const functionality = document.querySelector('input[name="functionality"]:checked'); - const content = document.querySelector('input[name="content"]:checked'); - const comment = document.querySelector('textarea[name="comment"]'); - if (satisfaction && functionality && content && comment.value) { - await doAction("/survey", { - action: "surveySubmit", - satisfaction: satisfaction.value, - functionality: functionality.value, - content: content.value, - comment: comment.value - }, "Zaznamenané", - "Nastala chyba"); - satisfaction.checked = false; - functionality.checked = false; - content.checked = false; - comment.value = ""; - } -} - async function toggleRegister() { let loginForm = document.getElementById("sign_in_form"); let registerForm = document.getElementById("sign_up_form"); diff --git a/assets/style.css b/assets/style.css index da4b5de..9d9f077 100644 --- a/assets/style.css +++ b/assets/style.css @@ -288,13 +288,7 @@ textarea{ width: 175px; } -span#ye-span:hover + body{ - background: url('/assets/images/ye.jpg') repeat !important; - background-size: 20% !important; -} - - -#articlecreate, #memecreate { +#articlecreate { border: 5px solid var(--pico-primary); z-index: 5; margin: auto; @@ -311,7 +305,7 @@ span#ye-span:hover + body{ display: none; } -#articlecreatecontainer, #memecreatecontainer{ +#articlecreatecontainer{ display: flex; align-items: center; justify-content: center; @@ -353,33 +347,6 @@ div#articleslist>article{ flex-direction: column; } -.meme_image { - max-width: 500px; - max-height: 300px; - width: auto; - height: auto; -} - -.meme_link { - width: fit-content; - height: fit-content; -} - -.meme_info, .meme_topbar { - display: flex; - flex-direction: row; - height: fit-content; - width: 100%; - justify-content: right; -} - -.meme, .meme_body { - display: flex; - flex-direction: column; - padding: 0; - margin: 0; -} - .positive { color: #008000; } @@ -399,30 +366,8 @@ div#articleslist>article{ --pico-color: var(--pico-primary-inverse); } -.visual_hover.meme_upvote { - --pico-background-color: #008000; - --pico-border-color: unset; -} - -.visual_hover.meme_downvote { - --pico-background-color: #ff0000; - --pico-border-color: unset; -} - -#meme_gallery { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(600px, 1fr)); - grid-auto-rows: 1fr; - gap: 20px -} - @media (max-width: 1050px) { - - table .rozvrh { - overflow: auto; - } - .navsite_item .navpage_list { max-height: unset !important; } @@ -493,11 +438,6 @@ div#articleslist>article{ flex-direction: column; } - .meme_image { - max-width: 200px; - max-height: 200px; - } - .navsite_link { width: 100%; } diff --git a/endpoints/meme.php b/endpoints/meme.php deleted file mode 100644 index f474f5a..0000000 --- a/endpoints/meme.php +++ /dev/null @@ -1,17 +0,0 @@ - addMeme($endpoint_data['meme_title'], $endpoint_data['meme_text'], $endpoint_data['meme_image_id']), - "getMemes" => getMemeGallery($endpoint_data['offset'], $endpoint_data['meme_author'], $endpoint_data['meme_id'], $endpoint_data['meme_keyword']), - "deleteMeme" => deleteMeme($endpoint_data['meme_id']), - "getMemeVotes" => getMemeVotes($endpoint_data['meme_id']), - "deleteVoteMeme" => deleteVoteMeme($endpoint_data['meme_id']), - "voteMeme" => voteMeme($endpoint_data['meme_id'], $endpoint_data['is_upvote']), - default => ["Status" => "Fail", "Message" => "Invalid action"], - }; -} \ No newline at end of file diff --git a/endpoints/survey.php b/endpoints/survey.php deleted file mode 100644 index a69a6f3..0000000 --- a/endpoints/survey.php +++ /dev/null @@ -1,11 +0,0 @@ - submitSurvey($endpoint_data["satisfaction"], $endpoint_data["functionality"], $endpoint_data["content"], $endpoint_data["comment"]), - default => ["Status" => "Fail", "message" => "Invalid action"], - }; -} \ No newline at end of file diff --git a/lib/account.php b/lib/account.php index e2d2a9c..c239368 100644 --- a/lib/account.php +++ b/lib/account.php @@ -1,6 +1,7 @@ "Fail"]; // Default Status is "Fail" - if (is_numeric($count) && $count > 0 && isUserAdmin() && isLoggedIn()) { + if ($count > 0 && isUserAdmin() && isLoggedIn()) { $stmt = $mysqli->prepare("INSERT INTO Users (ActivationToken, CreatedAt, CreatedBy) VALUES (?, NOW(), ?)"); for ($i = 0; $i < $count; $i++) { diff --git a/lib/config.php b/lib/config.php index bc7b01f..d99aba5 100644 --- a/lib/config.php +++ b/lib/config.php @@ -29,7 +29,7 @@ function loadRouterConfig(): array return [ 'inlining' => false, 'domain' => 'adlerka', - 'tld' => 'top', + 'tld' => 'space', 'default_page' => 'index', 'default_site' => 'home', 'template_dir' => 'templates/', @@ -58,9 +58,9 @@ function loadRouterConfig(): array 'per_page' => 10 ], 'seo' => [ - 'author' => 'Tím AdlerkaTop', - 'description' => 'Toto je neoficiánla študentská stránka pre Adlerku, kde môžete nájsť plno zaujímavostí.', - 'keywords' => 'adlerka, alderka, studenti, studentska stranka, web, dev, webdev, web dev, skola, zabava', + 'author' => 'Tím Adlerka space', + 'description' => 'Toto je oficiálna stránka pre Adlerácky vesmírny program, kde môžete nájsť plno zaujímavostí o ňom.', + 'keywords' => 'adlerka, alderka, studenti, vesmir, space, project, projekt, web, dev, webdev, web dev, skola, zabava', 'generator' => 'TurboRoute', 'robots' => 'follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large' ] diff --git a/lib/meme.php b/lib/meme.php deleted file mode 100644 index 03b8dd3..0000000 --- a/lib/meme.php +++ /dev/null @@ -1,316 +0,0 @@ - "Fail"]; - if (isLoggedIn() && fileExists($imageID, false) && !empty($title) && !empty($memeText) && !empty($imageID) && $imageID > 0) { - $stmtMemeAdd = $mysqli->prepare('INSERT INTO Memes (AuthorID, Title, TextContent, FileID) VALUES (?, ?, ?, ?)'); - $stmtMemeAdd->bind_param('issi', $_SESSION['ID'], htmlspecialchars($title), htmlspecialchars($memeText), $imageID); - if ($stmtMemeAdd->execute() && $stmtMemeAdd->affected_rows > 0) { - $output["Status"] = "Success"; - $output["Meme"] = "Funny"; - } - } - return $output; -} - -function executeAndRenderMemes(mysqli_stmt $stmt): string { - global $routerConfig; - $stmt->execute(); - $stmt->store_result(); - $stmt->bind_result($memeID, $title, $textContent, $createdAt, $authorID, $filePath, $imageWidth, $imageHeight, $userNickname); - - $memes_out = ''; - $meme_template = file_get_contents($routerConfig['template_dir'] . "meme.html"); - $meme_gallery_template = file_get_contents($routerConfig['template_dir'] . 'meme_gallery.html'); - - while ($stmt->fetch()) { - $memes_out .= renderMeme($memeID, $authorID, $title, $textContent, $createdAt, $filePath, $imageWidth, $imageHeight, $userNickname, $meme_template); - } - - $meme_add = isLoggedIn() ? file_get_contents($routerConfig['template_dir'] . 'meme_add.html') : ''; - $meme_gallery_out = str_replace('__TEMPLATE_MEMES_HERE__', $memes_out, $meme_gallery_template); - $meme_gallery_out = str_replace('__TEMPLATE_MEME_ADD__', $meme_add, $meme_gallery_out); - - $stmt->close(); - return $meme_gallery_out; -} - -/** - * Renders a meme into HTML based on provided data and a template. - * - * @param int $id The ID of the meme. - * @param int $authorId The author's user ID. - * @param string $title The title of the meme. - * @param string $textContent The text content of the meme. - * @param string $createdAt The creation timestamp of the meme. - * @param string $filePath The file path of the associated image. - * @param int $imageWidth The width of the image. - * @param int $imageHeight The height of the image. - * @param string $userNickname The nickname of the meme's author. - * @param string $meme_template The HTML template for a meme. (used to not read the template over and over when rendering more memes) - * @return string Returns the rendered HTML of the meme. - */ -function renderMeme(int $id, int $authorId, string $title, string $textContent, string $createdAt, string $filePath, int $imageWidth, int $imageHeight, string $userNickname, string $meme_template): string -{ - - $meme_out = str_replace('__TEMPLATE_MEME_TITLE__', htmlspecialchars($title), $meme_template); - $meme_out = str_replace('__TEMPLATE_MEME_AUTHOR__', htmlspecialchars($userNickname), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_DATE__', htmlspecialchars($createdAt), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_IMAGE__', '/' . htmlspecialchars($filePath), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_IMAGE_WIDTH__', strval($imageWidth), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_IMAGE_HEIGHT__', strval($imageHeight), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_DELETE_BUTTON__', (isModerator() || $_SESSION['ID'] == $authorId) ? "" : '', $meme_out); - - $meme_votes = calculateNetVotes($id); - $meme_net_votes = $meme_votes['NetVotes']; - - if ($meme_votes['UserVote'] > 0) { - $meme_upvote_active = 'fill'; - $meme_downvote_active = 'line'; - $meme_vote_counter_class = 'positive'; - $meme_upvote_button_class = ' visual_hover'; - $meme_downvote_button_class = ''; - } elseif (($meme_votes['UserVote'] < 0)) { - $meme_upvote_active = 'line'; - $meme_downvote_active = 'fill'; - $meme_vote_counter_class = 'negative'; - $meme_upvote_button_class = ''; - $meme_downvote_button_class = ' visual_hover'; - } else { - $meme_downvote_active = 'line'; - $meme_upvote_active = 'line'; - $meme_vote_counter_class = 'neutral'; - $meme_upvote_button_class = ''; - $meme_downvote_button_class = ''; - } - $meme_upvote = isLoggedIn() ? "" : ''; - $meme_downvote = isLoggedIn() ? "" : ''; - - $meme_out = str_replace('__TEMPLATE_MEME_VOTES_NUMBER__', strval($meme_net_votes), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_UPVOTE__', $meme_upvote, $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_DOWNVOTE__', $meme_downvote, $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_ID__', strval($id), $meme_out); - $meme_out = str_replace('__TEMPLATE_MEME_VOTE_COUNTER_CLASS__', $meme_vote_counter_class, $meme_out); - - return str_replace('__TEMPLATE_MEME_TEXT__', htmlspecialchars($textContent), $meme_out); -} - -/** - * Renders a gallery of memes, optionally filtered by author ID, meme ID, or a keyword. - * - * This function retrieves memes from the database and returns an HTML string representation. - * It supports filtering by author ID, meme ID, or a keyword that is searched in titles and text content. - * It also supports pagination through an offset parameter. - * - * @param int|null $offset Pagination offset, used to calculate the starting point for records to return. - * @param int|null $authorId Optional author ID for filtering memes by a specific author. - * @param int|null $memeId Optional meme ID for rendering a single meme. - * @param string|null $keyword Optional keyword for full-text search in meme titles and content. - * @return string Returns the complete HTML content of the meme gallery, optionally filtered. - */ - -function getMemeGallery(?int $offset = null, ?int $authorId = null, ?int $memeId = null, ?string $keyword = null): array { - return [ - "Status" => "Success", - "Output" => renderMemeGallery($offset, $authorId, $memeId, $keyword) - ]; -} - -function renderMemeGallery(?int $offset = null, ?int $authorId = null, ?int $memeId = null, ?string $keyword = null): string { - global $mysqli, $routerConfig; - - // Start building the SQL query - $query = 'SELECT Memes.ID, Memes.Title, Memes.TextContent, Memes.CreatedAt, Memes.AuthorID, - Files.Path, Files.Width, Files.Height, Users.Nickname - FROM Memes - INNER JOIN Users ON Memes.AuthorID = Users.ID - INNER JOIN Files ON Memes.FileID = Files.ID'; - - $conditions = []; - $params = []; - $types = ''; - - // Add conditions based on provided parameters - if ($authorId !== null) { - $conditions[] = 'Memes.AuthorID = ?'; - $params[] = $authorId; - $types .= 'i'; - } - if ($memeId !== null) { - $conditions[] = 'Memes.ID = ?'; - $params[] = $memeId; - $types .= 'i'; - } - if ($keyword !== null) { - $conditions[] = '(Memes.Title LIKE CONCAT("%", ?, "%") OR Memes.TextContent LIKE CONCAT("%", ?, "%"))'; - $params[] = $keyword; - $params[] = $keyword; - $types .= 'ss'; - } - - // Append conditions to the query - if (!empty($conditions)) { - $query .= ' WHERE ' . join(' AND ', $conditions); - } - - if($offset == null) { - $offset = 0; - } - // Add pagination and limit - $query .= ' LIMIT ? OFFSET ?'; - $params[] = $routerConfig['meme']['per_page']; - $params[] = $routerConfig['meme']['per_page'] * $offset; - $types .= 'ii'; - - $stmt = $mysqli->prepare($query); - $stmt->bind_param($types, ...$params); - return executeAndRenderMemes($stmt); -} - - -/** - * Deletes a meme from the database if the current user has the right permissions. - * - * @param int $memeID The ID of the meme to delete. - * @return array Returns an associative array with the status of the operation. - * @global mysqli $mysqli The database connection object. - */ -function deleteMeme(int $memeID): array -{ - global $mysqli; - $out = ["Status" => "Fail"]; - if (isLoggedIn()) { - $query = !isModerator() ? 'DELETE FROM Memes WHERE ID = ? AND AuthorID = ?' : 'DELETE FROM Memes WHERE ID = ?'; - $stmtDelete = $mysqli->prepare($query); - if (!isModerator()) { - $stmtDelete->bind_param('ii', $memeID, $_SESSION['ID']); - } else { - $stmtDelete->bind_param('i', $memeID); - } - $stmtDelete->execute(); - if ($stmtDelete->affected_rows > 0) { - $out['Status'] = 'Success'; - } - $stmtDelete->close(); - } - return $out; -} - -/** - * Records or updates a vote on a meme by the current user. - * - * @param int $memeID The ID of the meme to be voted on. - * @param int $isUpvote Indicates whether the vote is an upvote (1) or downvote (0). - * @return array Returns an associative array with the status of the vote operation. - * @global mysqli $mysqli The database connection object. - */ -function voteMeme(int $memeID, int $isUpvote): array -{ - global $mysqli; - $out = ["Status" => "Fail"]; - if ($isUpvote != 1) { - $isUpvote = 0; - } - $memeVoteConn = $mysqli->prepare('INSERT INTO MemeVotes (MemeID, UserID, isUpvote) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE isUpvote = VALUES(isUpvote)'); - $memeVoteConn->bind_param('iii', $memeID, $_SESSION['ID'], $isUpvote); - $memeVoteConn->execute(); - if ($memeVoteConn->affected_rows > 0) { - $out['Status'] = 'Success'; - } - $memeVoteConn->close(); - return $out; -} - -/** - * Deletes a vote previously made by the current user on a meme. - * - * @param int $memeID The ID of the meme whose vote is to be deleted. - * @return array Returns an associative array with the status of the deletion. - * @global mysqli $mysqli The database connection object. - */ -function deleteVoteMeme(int $memeID): array -{ - global $mysqli; - $out = ["Status" => "Fail"]; - $memeVoteConn = $mysqli->prepare('DELETE FROM MemeVotes WHERE MemeID = ? AND UserID = ?'); - $memeVoteConn->bind_param('ii', $memeID, $_SESSION['ID']); - $memeVoteConn->execute(); - if ($memeVoteConn->affected_rows > 0) { - $out['Status'] = 'Success'; - } - $memeVoteConn->close(); - return $out; -} - -/** - * Calculates the net votes for a meme and determines if the current user has voted on it. - * The array has both the net votes and the user vote(0 when the user hasn't voted) - * - * @param int $memeID The ID of the meme for which votes are being calculated. - * @return array Returns an array with net votes and the user's vote status. - * @global mysqli $mysqli The database connection object. - */ -function calculateNetVotes(int $memeID): array -{ - global $mysqli; - - // Adjusted query to calculate net votes and get the user's vote in one go - $query = " - SELECT - SUM(CASE WHEN isUpvote = 1 THEN 1 ELSE -1 END) AS NetVotes, - ( - SELECT CASE WHEN isUpvote = 1 THEN 1 ELSE -1 END - FROM MemeVotes - WHERE MemeID = ? AND UserID = ? - ) AS UserVote - FROM MemeVotes - WHERE MemeID = ?"; - - $stmt = $mysqli->prepare($query); - $userID = $_SESSION['ID']; - $stmt->bind_param('iii', $memeID, $userID, $memeID); - $stmt->execute(); - $result = $stmt->get_result(); - - $data = $result->fetch_assoc(); - - $netVotes = $data['NetVotes'] ?? 0; // Null coalescing operator in case no votes are found - $userVote = $data['UserVote'] ?? 0; // Default to 0 if the user hasn't voted - - $stmt->close(); - - return [ - "NetVotes" => $netVotes, - "UserVote" => $userVote - ]; -} - -/** - * Fetches the net votes and user's vote status for a specific meme. - * Essentially just a wrapper of getMemeVotes for an API call - * - * @param int $memeID The ID of the meme to fetch votes for. - * @return array Returns an array with the net votes and the user's vote status, along with operation status. - */ -function getMemeVotes(int $memeID): array -{ - $voteData = calculateNetVotes($memeID); - return [ - "Status" => "Success", - "NetVotes" => $voteData['NetVotes'], - "UserVote" => $voteData['UserVote'] - ]; -} \ No newline at end of file diff --git a/lib/script_data.php b/lib/script_data.php index 217fc1f..1267c6b 100644 --- a/lib/script_data.php +++ b/lib/script_data.php @@ -11,7 +11,7 @@ */ function generateScriptData(array $phpArray):string { // Check if the array is associative and single-level - if (is_array($phpArray) && count($phpArray) > 0 && count(array_filter(array_keys($phpArray), 'is_string')) === count($phpArray)) { + if (count($phpArray) > 0 && count(array_filter(array_keys($phpArray), 'is_string')) === count($phpArray)) { // Generate JavaScript code to save each array element to local storage $out = "