-
Notifications
You must be signed in to change notification settings - Fork 0
/
rora.min.js
1 lines (1 loc) · 14 KB
/
rora.min.js
1
onDomTreeReading = a => { var b = document.onreadystatechange; document.onreadystatechange = () => { b && b(); a(), console.debug("\u2592\u2592\u2592 rora : dom three status colling >>> Dom Tree under reading (load and reload)\n\u2592\u2592\u2592 \u2514[info: low cpu and doesn't consider the extra fires called]") } }, onDomTreeReaded = a => { var b = document.onreadystatechange; document.onreadystatechange = () => { "complete" === document.readyState && (b && b(), a(), console.log("\u2592\u2592\u2592 rora : dom three status colling >>> after Dom Tree is Ready and loaded\n\u2592\u2592\u2592 \u2514[info: low cpu and doesn't consider the extra fires called]")) } }, onContentIsLoaded = a => { var b = window.onload; window.onload = () => { b && b(); a(), console.log("\u2592\u2592\u2592 rora : content status colling >>> after all Content is Loaded \n\u2592\u2592\u2592 \u2514[info: all images, css, scripts, etc. are loaded, final page rendered]") } }, onWindowUnload = a => { var b = window.onunload; window.onunload = () => { b && b(); a(), console.log("\u2592\u2592\u2592 rora : content status colling >>> window start or exit \n\u2592\u2592\u2592\u2514 (info: perfect to intercept hystory frame etc.)\n\n") } }, onDomTreeReaded(() => { function a(l, m) { h.html = l, j.html = m } function b(l, m, n) { for (let p, o = 0; o < l.length; o++)switch (p = l[o], m) { case "get-css": result = window.getComputedStyle(p, null).getPropertyValue(n); break; case "get-attribute": result = p.getAttribute(n); break; case "set-attribute": result = p.setAttribute(n[0], n[1]); break; case "remove-attribute": result = p.removeAttribute(n); break; case "new-style": result = p.style.cssText = n; break; case "addClass": result = p.classList.add(n); break; case "removeClass": result = p.classList.remove(n); break; case "replaceClass": result = p.classList.replace(n[0], n[1]); break; case "toggleClass": result = p.classList.toggle(n); break; case "write": result = p.textContent = n; break; case "unWrap": result = p.outerHTML = p.innerHTML; case "code-override": result = p.innerHTML = n; break; case "code-prepend": result = p.insertAdjacentHTML("afterbegin", n); break; case "code-append": result = p.insertAdjacentHTML("beforeend", n); break; case "code-beforeElement": result = p.insertAdjacentHTML("beforebegin", n); break; case "code-afterElement": result = p.insertAdjacentHTML("afterend", n); break; default: document.do(alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -n .mods: type of modder not recognized or non-existent!\n\n")); }return result } function c(l, m) { for (var n = 0; n < l.length; n++)m.call(l[n])(back) } function d(l, m, n) { for (let s, r = 0; r < l.length; r++)switch (s = l[r], m) { case "click": s.addEventListener("click", E => { E.stopPropagation(), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }, !1); break; case "doubleclick": s.addEventListener("dblclick", E => { E.stopPropagation(), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }, !1); break; case "middleclick": s.addEventListener("auxclick", E => { E.stopPropagation(), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }, !1); break; case "short-tap": var o = 0; s.addEventListener("touchstart", function (E) { E.preventDefault(), o = setTimeout(function () { clearTimeout(o), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }, 700) }, !1), s.addEventListener("touchend", function (E) { E.preventDefault(), clearTimeout(o) }, !1); break; case "long-tap": var p = 0; s.addEventListener("touchstart", function (E) { E.preventDefault(), p = setTimeout(function () { clearTimeout(p), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }, 1300) }, !1), s.addEventListener("touchend", function (E) { E.preventDefault(), clearTimeout(p) }, !1); break; case "mouse-enter": s.addEventListener("mouseover", E => { E.preventDefault(), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }); break; case "mouse-exit": s.addEventListener("mouseout", E => { E.preventDefault(), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }); break; case "stop-drag": ["mouseout", "mouseup", "touchend"].forEach(function (E) { s.addEventListener(E, () => { h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }) }); break; case "mouse-move": s.addEventListener("mousemove", E => { E.preventDefault(), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker) }); break; case "scroll": window.addEventListener("scroll", () => { var G = { top: 0, left: 0, bottom: 0, right: 0 }, H = { top: 0, left: 0, bottom: 0, right: 0 }; G.top = window.pageYOffset, G.left = window.pageXOffset, G.bottom = window.pageYOffset + window.innerHeight, G.right = window.pageXOffset + window.innerWidth, H.top = l[r].offsetTop, H.left = l[r].offsetLeft, H.right = l[r].offsetRight, H.bottom = l[r].offsetBottom, ViewportDistance = G, ElementDistance = H, h.html = l[r], j.html = [l], clicker = l[r], n(h, j, ViewportDistance, ElementDistance) }); break; case "swipe": case "drag": case "drag-left": case "drag-right": case "drag-down": case "drag-up": let t, u, v, w, x, y, C, D, z = 150, A = 100, B = 300; var q = { axis: { x: 0, y: 0 }, direction: { up: 0, down: 0, left: 0, right: 0 } }; s.addEventListener("touchmove", function (E) { "drag" != m && E.preventDefault(), u = E.changedTouches[0], movementX = u.pageX, movementY = u.pageY, "drag" == m && (q.axis.x = movementX, q.axis.y = movementY), "drag-left" == m ? 0 <= v - movementX ? q.direction.left = v - movementX : q.direction.left = 0 : "drag-right" == m ? 0 >= v - movementX ? q.direction.right = -1 * (v - movementX) : q.direction.right = 0 : "drag-down" == m ? 0 >= w - movementY ? q.direction.up = -1 * (w - movementY) : q.direction.up = 0 : "drag-up" == m && (0 <= w - movementY ? q.direction.up = w - movementY : q.direction.up = 0), m.startsWith("drag") && (drag = q, h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker, drag)), E.preventDefault() }, !1), s.addEventListener("touchstart", function (E) { u = E.changedTouches[0], t = "none", dist = 0, v = u.pageX, w = u.pageY, D = new Date().getTime(), E.preventDefault() }, !1), s.addEventListener("touchend", function (E) { u = E.changedTouches[0], x = u.pageX - v, y = u.pageY - w, C = new Date().getTime() - D; let G = C <= B, H = m; "swipe" == H && G ? Math.abs(x) >= z && Math.abs(y) <= A ? t = 10 > x ? "left" : "right" : Math.abs(y) >= z && Math.abs(x) <= A && (t = 10 > y ? "up" : "down") : "swipe-x" == H && G ? Math.abs(x) >= z && Math.abs(y) <= A && (t = 10 > x ? "left" : "right") : "swipe-y" == H && G ? Math.abs(y) >= z && Math.abs(x) <= A && (t = 10 > y ? "up" : "down") : "swipe-up" == H && G ? Math.abs(y) >= z && Math.abs(x) <= A && 10 > y && (t = "up") : "swipe-down" == H && G ? C <= B && Math.abs(y) >= z && Math.abs(x) <= A && 10 < y && (t = "down") : "swipe-left" == m && G ? Math.abs(x) >= z && Math.abs(y) <= A && 10 > x && (t = "left") : "swipe-right" == m && G && Math.abs(x) >= z && Math.abs(y) <= A && 10 < x && (t = "right"), t && (swipedirection = t), h.html = l[r], j.html = [l], clicker = l[r], n(h, j, clicker, swipedirection), E.preventDefault() }, !1); break; default: document.do(alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error in ''.on'': type or target of event not recognized or non-existent.\n\n")); } } function f(l, m) { console.info("\u2592\u2592\u2592 rora : include Tecnique >>> The tecnique of include wait the server repons... for including action."); var n = m; for (let p, o = 0; o < l.length; o++)if (p = l[o], void 0 == m && (n = l[o].getAttribute("data-include")), n) { if (n.startsWith("/")) { alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -n include file path: do not use the ' / ' as initial.\n\nFollow the example below:\n<div include='myfolder/.../file.html'></div>\n\n"); p.innerHTML = "<p style=\"background:white !important; padding:20px !important; border: 1px solid red !important; color:red !important; font-weight:bold !important;\"> !! ERROR: WRONG PATH FOR INCLUDE</p>" } let q = new XMLHttpRequest; q.onload = function () { 200 == this.status ? (console.log("\u2592\u2592\u2592 rora : included file >>> " + n + " | request status: " + this.status + " | data printed:(for see active line 813)"), p.innerHTML = this.responseText, p.matches("[data-include]") && (p.outerHTML = p.innerHTML)) : 404 == this.status ? alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -n include file path or server:\n404 file not founded.\n\n") : 0 != this.status && alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -n include: undefined server error on include js.\n\n") }, q.open("GET", n, !1), q.send() } } console.log("\u2592\u2592\u2592 rora : starting..."), console.time("\u2592\u2592\u2592 rora : ready | loaded in:"), doc = window.document; var g = { list: "no elements or targets" }, h = { html: "no html element" }, j = { html: "no html collection" }; doc.find = l => { let m, n, o, p, q, r, s = /:first-child/, t = s.test(l), u = /:last-child/, v = u.test(l), w = /:nth/, x = w.test(l); return "window" === l ? alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -''window'' is not available target for find.\n\n") : "document" === l ? alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -''document'' is not available target for find.\n\n - Remember: the ''doc.'' is the document!\n - If you are looking for the general contentin your viewport, try with body.\n\n") : "body" === l ? r = Array.from(document.querySelectorAll("BODY")) : t ? (m = l.split(":")[0], n = document.querySelectorAll(m)[0], r = [], r.push(n)) : v ? (m = l.split(":")[0], n = document.querySelectorAll(m), o = n[n.length - 1], r = [], r.push(o)) : x ? (m = l.split(":")[0], p = l.split(":nth-child(")[1], q = p.split(")")[0], n = document.querySelectorAll(m)[q - 1], r = [], r.push(n)) : r = Array.from(document.querySelectorAll(l)), Array.isArray(r) || alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n -The type of find is not an array!\n\n"), (g.list = r, g) }, g.find = () => { alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - bad pratic on find.\nIs Not good create a follow of follow [...] of follow finded element\n\n") }, doc.loop = (l, m) => { let n = "[object Object]" == l ? Object.values(l)[0] : Array.isArray(l) ? g.list : [l]; for (let q = 0; q < n.length; q++) { var o = n[q], p = n; a(o, p), m(h, j) } return g }, g.loop = l => { let m = g.list; for (let p = 0; p < m.length; p++) { var n = m[p]; a(n, m), l(h, j) } return g }, h.loop = () => { let l = [h.html]; return a(l, elList), result }, j.loop = l => { let m = Object.values(j.html)[0]; for (let p = 0; p < m.length; p++) { var n = m[p]; a(n, m), l(h, j) } return g }, doc.mods = (l, m, n) => { let o; return o = "[object Object]" == l ? Object.values(l)[0] : Array.isArray(l) ? g.list : [l], b(o, m, n), (g, result) }, g.mods = (l, m) => { let n = g.list; return b(n, l, m), g, result }, h.mods = (l, m) => { let n = [h.html]; return b(n, l, m), result }, j.mods = l => { let m = Object.values(j.html)[0]; return b(m, l), result }, doc.actor = (l, m, n) => { let o; return o = "[object Object]" == l ? Object.values(l)[0] : Array.isArray(l) ? g.list : [l], c(o, m, n), g }, g.actor = (l, m) => { let n = g.list; return c(n, l, m), g }, h.actor = (l, m) => { let n = [h.html]; return c(n, l, m), g }, j.actor = l => { let m = Object.values(j.html)[0]; return c(m, fname, l), g }; doc.on = (l, m, n) => { let o; return o = "[object Object]" == l ? Object.values(l)[0] : Array.isArray(l) ? g.list : [l], d(o, m, n), g }, g.on = (l, m) => { let n = g.list; return d(n, l, m), g }, h.on = (l, m) => { let n = [h.html]; return d(n, l, m), g, result }, j.on = l => { let m = Object.values(j.html)[0]; return d(m, actiontype, l), g }; doc.include = (l, m) => { let n; return n = "[object Object]" == l ? Object.values(l)[0] : Array.isArray(l) ? g.list : [l], f(n, m), g }, g.include = l => { let m = g.list; return f(m, l), g }, h.include = l => { let m = [h.html]; return f(m, l), g }, j.include = l => { let m = Object.values(j.html)[0]; return f(m, l), g }; var k = document.querySelectorAll("div[data-include]"); for (i = 0; i < k.length; i++) { let l = [...k]; f(l) } onContentIsLoaded(() => { setTimeout(() => { console.info("\u2592\u2592\u2592 rora : injection Tecnique >>> The tecnique of inject wait 150ms extra (only once) for loading all including."); var l = doc.find("[data-injector]"); doc.loop(l, () => { var m = h.mods("get-attribute", "data-injector"), n = m.split(",")[0], o = m.split(",")[1], p = m.split(",")[2]; h.on(n, () => { doc.find("" + o).include("" + p), console.log("\u2592\u2592\u2592 rora : injection Tecnique >>> action: " + n + " > on target " + o + " > calling " + p) }) }) }, 150) }), doc.talk = (l, m, n, o, p) => { let q = { start: "falsestatus undefined", data: "data request undefined", success: "falsestatus undefined" }; if (o) { let r = new XMLHttpRequest; r.onload = function () { 4 == this.readyState ? (q.start = !0, 200 == this.status && ("output-xml" == n ? q.data = this.responseXML : "output-text" == n && (q.data = this.responseText), q.success = !0)) : 0 == this.readyState ? (q.status = "error", alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error // talking fail: Server not repond\n\n")) : 403 == this.status ? (q.status = "forbidden", alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error // talking fail: forbidden requests\n\n")) : 404 == this.status && (q.status = "404 not found", alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error // talking fail: server 404 not found.\n\n")) }, "mode-server" == m ? m = !1 : "mode-unlinear" == m ? m = !0 : alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error // talking fail: you can us mode-server or mode-unlinear.\n\n- server is syncronus server request, unlinear = unsync page request.\n\n"), "type-get" == l ? l = "Get" : "type-post" == l ? l = "Post" : alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error // talking fail: you can us type-get or type-post.\n\n- Get is for small data, Post is for complex data.\n\n"), r.open(l, o, m), r.send() } else alert("\u2592\u2592\u2592 ERROR \u2592\u2592\u2592\n\n - Error // talking fail: page, server or path not recognized.\n\n"); p(q) }, console.timeEnd("\u2592\u2592\u2592 rora : ready | loaded in:") });