|
@@ -1,83 +1,5 @@
|
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
|
|
-// https://css-tricks.com/how-to-animate-the-details-element/
|
|
|
|
|
-class Accordion {
|
|
|
|
|
- constructor(el) {
|
|
|
|
|
- this.el = el;
|
|
|
|
|
- this.summary = el.querySelector('summary');
|
|
|
|
|
- this.content = el.querySelector('.opennamu_folding');
|
|
|
|
|
-
|
|
|
|
|
- this.animation = null;
|
|
|
|
|
- this.isClosing = false;
|
|
|
|
|
- this.isExpanding = false;
|
|
|
|
|
- this.summary.addEventListener('click', (e) => this.onClick(e));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- onClick(e) {
|
|
|
|
|
- e.preventDefault();
|
|
|
|
|
- this.el.style.overflow = 'hidden';
|
|
|
|
|
- if(this.isClosing || !this.el.open) {
|
|
|
|
|
- this.open();
|
|
|
|
|
- } else if(this.isExpanding || this.el.open) {
|
|
|
|
|
- this.shrink();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- shrink() {
|
|
|
|
|
- this.isClosing = true;
|
|
|
|
|
-
|
|
|
|
|
- const startHeight = `${this.el.offsetHeight}px`;
|
|
|
|
|
- const endHeight = `${this.summary.offsetHeight}px`;
|
|
|
|
|
-
|
|
|
|
|
- if(this.animation) {
|
|
|
|
|
- this.animation.cancel();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.animation = this.el.animate({
|
|
|
|
|
- height: [startHeight, endHeight]
|
|
|
|
|
- }, {
|
|
|
|
|
- duration: 200,
|
|
|
|
|
- easing: 'ease-out'
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- this.animation.onfinish = () => this.onAnimationFinish(false);
|
|
|
|
|
- this.animation.oncancel = () => this.isClosing = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- open() {
|
|
|
|
|
- this.el.style.height = `${this.el.offsetHeight}px`;
|
|
|
|
|
- this.el.open = true;
|
|
|
|
|
- window.requestAnimationFrame(() => this.expand());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- expand() {
|
|
|
|
|
- this.isExpanding = true;
|
|
|
|
|
- const startHeight = `${this.el.offsetHeight}px`;
|
|
|
|
|
- const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight}px`;
|
|
|
|
|
-
|
|
|
|
|
- if(this.animation) {
|
|
|
|
|
- this.animation.cancel();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.animation = this.el.animate({
|
|
|
|
|
- height: [startHeight, endHeight]
|
|
|
|
|
- }, {
|
|
|
|
|
- duration: 200,
|
|
|
|
|
- easing: 'ease-out'
|
|
|
|
|
- });
|
|
|
|
|
- this.animation.onfinish = () => this.onAnimationFinish(true);
|
|
|
|
|
- this.animation.oncancel = () => this.isExpanding = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- onAnimationFinish(open) {
|
|
|
|
|
- this.el.open = open;
|
|
|
|
|
- this.animation = null;
|
|
|
|
|
- this.isClosing = false;
|
|
|
|
|
- this.isExpanding = false;
|
|
|
|
|
- this.el.style.height = this.el.style.overflow = '';
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
function opennamu_do_id_check(data) {
|
|
function opennamu_do_id_check(data) {
|
|
|
if(data.match(/\.|\:/)) {
|
|
if(data.match(/\.|\:/)) {
|
|
|
return 0;
|
|
return 0;
|
|
@@ -86,6 +8,24 @@ function opennamu_do_id_check(data) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function opennamu_do_ip_render() {
|
|
|
|
|
+ let temp = {};
|
|
|
|
|
+ for(let for_a = 0; for_a < document.getElementsByClassName('opennamu_render_ip').length; for_a++) {
|
|
|
|
|
+ let ip = document.getElementsByClassName('opennamu_render_ip')[for_a].innerHTML.replace(/&/g, '&');
|
|
|
|
|
+
|
|
|
|
|
+ if(temp[ip]) {
|
|
|
|
|
+ document.getElementsByClassName('opennamu_render_ip')[for_a].innerHTML = temp[ip];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fetch('/api/ip/' + opennamu_do_url_encode(ip)).then(function(res) {
|
|
|
|
|
+ return res.json();
|
|
|
|
|
+ }).then(function(data) {
|
|
|
|
|
+ document.getElementsByClassName('opennamu_render_ip')[for_a].innerHTML = data["data"];
|
|
|
|
|
+ temp[ip] = data["data"];
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
function opennamu_do_url_encode(data) {
|
|
function opennamu_do_url_encode(data) {
|
|
|
return encodeURIComponent(data);
|
|
return encodeURIComponent(data);
|
|
|
}
|
|
}
|