Skip to content

Commit 9a727e0

Browse files
committed
a lot of progress
1 parent 1a43658 commit 9a727e0

File tree

5 files changed

+137
-110
lines changed

5 files changed

+137
-110
lines changed

assets/dbm/options/info.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
info = {
2+
"messages": {
3+
"errJSON": "Invalid JSON. Please enter valid Raw Data.",
4+
"errType": "The value provided is not an object. Please enter valid Raw Data.",
5+
"errRD": "The JSON provided doesn't seem to be valid DBM Raw Data."
6+
},
7+
"command": {
8+
"_id": {
9+
"label": "ID"
10+
},
11+
"permissions": {
12+
"label": "Required Permissions"
13+
},
14+
"permissions2": {
15+
"label": "Secondary Required Permissions"
16+
},
17+
"restriction": {
18+
"label": "Command Restriction",
19+
"values": ["Server only"]
20+
}
21+
},
22+
"event": {
23+
"_id": {
24+
"label": "ID"
25+
},
26+
"event-type": {
27+
"label": "Event Trigger",
28+
"values": []
29+
},
30+
"temp": {
31+
"label": "Temp Variable Name"
32+
},
33+
"temp2": {
34+
"label": "Second Temp Variable Name"
35+
}
36+
},
37+
"actions": { // this does not and will (probably) never support mods
38+
"common": {
39+
"varName": {"label": "Variable Name", "value": "string"},
40+
"storage": {"label": "Store In", "value": "choice", "values": ["Nothing", "Temp Variable", "Server Variable", "Global Variable"]},
41+
"inputs": {
42+
"send-reply-target-input": ["Same Channel", "Command User", "Mentioned User", "Interacted User", "Mentioned Channel", "Command Message", "Slash Command Parameter", "Default Channel", "Public Updates Channel", "Rules Channel", "Join/Boost Notify Channel", "Temp Variable", "Server Variable", "Global Variable", "User (Name)", "User (ID)", "Channel (Name)", "Channel (ID)"]
43+
}
44+
},
45+
"Send Message": {
46+
"channel": {"label": "Send To", "value": "send-reply-target-input"},
47+
}
48+
}
49+
}

assets/dbm/options/info.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

dbm.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<head>
22
<meta charset="UTF-8">
3-
<title>DBM Rawdata Viewer</title>
3+
<title>DBM Raw Data Viewer</title>
44
<link rel="icon" type="image/x-icon" href="./assets/favicon.ico">
55

66
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
@@ -11,7 +11,7 @@
1111
</head>
1212
<body style="background-image: radial-gradient(#3d3d3d 10%, transparent 10%); background-position: 0 0, 50px 50px; background-size: 20px 20px;">
1313
<!--<div class="grid no-select" style="background-image: url(assets/bg/grid-dbm.png);"></div>-->
14-
<div class="no-select" style="display:flex;"><p style="font-size:30px; margin-left: 3%;">Rawdata Viewer</p></div>
14+
<div class="no-select" style="display:flex;"><p style="font-size:30px; margin-left: 3%;">Raw Data Viewer</p></div>
1515

1616
<noscript class="no-select">
1717
<form id="main-modal" class="container error" style="padding:1%">
@@ -25,10 +25,10 @@
2525
<p style="text-align: center; transform:translateY(-250%);font-size: 300%; padding-left: 20px;">tcmine64</p>
2626
</div>
2727
</body>-->
28-
29-
3028
<form id="main-modal" class="container" style="display:grid">
31-
<p class="no-select" style="padding-top: 5%; font-size:110%">Paste your Rawdata here to continue.</p>
29+
30+
31+
<p class="no-select" style="font-size:110%">Paste your Raw Data here to continue.</p>
3232
<textarea oninput="joe()" spellcheck="false" id="rawdata-input" class="rd-textarea" id="w3review" rows="2" placeholder="Must be valid JSON."></textarea>
3333
<p class="comment no-select" style="margin-bottom: -8px;" ><i class="fa fa-info-circle" style="font-size:110%;padding-right:5px;color:rgba(255, 255, 255, 0.281)"></i>Note: This is <b>not</b> an editor. You cannot add, edit or delete any actions.</p>
3434
</form>
@@ -88,15 +88,15 @@
8888
</div>
8989
<div class="vl" style="margin-inline:10px;border-left: 1px solid rgb(180, 180, 180);"></div>
9090
<div class="action-info fixed" id="jo">
91-
<p class="action-info-title">Comment</p>
9291
</div>
9392
<div class="action-info" id="jo2" >
93+
<p class="action-info-title">Comment</p>
9494
</div>
9595
</form>
9696
-->
9797

9898
<form id="invalid" class="container error" style="padding:1%; display:none; opacity:0; visibility: hidden;">
99-
<p>Invalid JSON. Please enter valid rawdata.</p>
99+
<p id="invalidText">Error</p>
100100
<code style="opacity: 0.7;"></code>
101101
</form>
102102

@@ -106,4 +106,5 @@
106106
</body>
107107
<img src="./assets/egg_gear.png" class="no-select" style="opacity:0.5 ;filter: grayscale(100%) ;width:20%; position: fixed; bottom: 0; right: 0; margin: -9%;">
108108
<div class="no-select" style="position:fixed; bottom:0; margin:20px; margin-top:20%; color:rgba(255, 255, 255, 0.445)"><center>Made by tcmine | v0.1</center></div>
109+
<script src="./assets/dbm/options/info.js"></script>
109110
<script src="./src/dbm.js"></script>

src/dbm.js

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
const DBMInfo = info
2+
3+
const urlParams = new URLSearchParams(queryString);
4+
const data = urlParams.get('data')
5+
console.log(data);
6+
17
var rd_actionlist;
28
var rd_info;
39
var scroll = true;
4-
var RDInput = document.getElementById("rawdata-input")
10+
var RDInput = document.getElementById("rawdata-input");
511

612
var container;
713
var element;
814
var element2;
915

10-
if (RDInput.focus) {
11-
12-
13-
}
14-
1516
function isJsonString(str) {
1617
try {
1718
JSON.parse(str);
@@ -21,6 +22,8 @@ function isJsonString(str) {
2122
return true;
2223
}
2324

25+
RDInput.focus();
26+
2427
function joe() {
2528
document.getElementById("invalid").style.display="none";
2629
clear()
@@ -33,11 +36,30 @@ function joe() {
3336
if (isJsonString(RDInput.value)) {
3437
//document.getElementById("invalid").style.display = "none";
3538
document.getElementById("invalid").style.animation="hideInvalid 0.3s linear forwards";
36-
val = RDInput.value
39+
val = RDInput.value;
40+
41+
//check if object
42+
if (typeof JSON.parse(val) != "object" || Array.isArray(JSON.parse(val))) {
43+
document.getElementById("invalidText").innerHTML = info.messages.errType
44+
document.getElementById("invalid").style.display="grid";
45+
document.getElementById("invalid").style.animation="showInvalid 0.3s linear forwards";
46+
return
47+
}
48+
49+
50+
//check if rd
51+
if (JSON.parse(val).actions === undefined) {
52+
document.getElementById("invalidText").innerHTML = info.messages.errRD
53+
document.getElementById("invalid").style.display="grid";
54+
document.getElementById("invalid").style.animation="showInvalid 0.3s linear forwards";
55+
return
56+
}
3757

3858
loadData(val)
59+
dataInfoSetup(val)
3960

4061
} else {
62+
document.getElementById("invalidText").innerHTML = info.messages.errJSON
4163
document.getElementById("invalid").style.display="grid";
4264
document.getElementById("invalid").style.animation="showInvalid 0.3s linear forwards";
4365
}
@@ -50,17 +72,24 @@ function loadData(val) {
5072
clear(0)
5173

5274
let data = JSON.parse(val);
53-
let joe = document.createElement("form")
54-
let container = document.createElement("div")
55-
5675

76+
let dbmcont = document.createElement("div")
77+
dbmcont.id = "datainfo"
78+
dbmcont.className = "container flex-container"
79+
document.body.appendChild(dbmcont)
80+
rd_info = dbmcont
5781

82+
let container = document.createElement("div")
83+
container.id = "action-list"
5884
container.className = "action-list"
85+
86+
let joe = document.createElement("form")
5987
joe.className = "container flex-container"
6088
joe.id = "holder"
89+
6190
//console.log(data.actions)
6291
var actions = data.actions ?? [{name:"?"}]
63-
92+
6493
dataInfoSetup(data, joe)
6594
joe.appendChild(container);
6695

@@ -77,7 +106,7 @@ function loadData(val) {
77106
infoSetup(joe)
78107

79108

80-
if (scroll) setTimeout(()=>{document.activeElement.blur(); document.getElementById("holder").scrollIntoView({ behavior: 'smooth', block: 'start'})},50)
109+
if (scroll) setTimeout(()=>{document.activeElement.blur(); document.getElementById("datainfo").scrollIntoView({ behavior: 'smooth', block: 'start'})},50)
81110
scroll = false
82111
}
83112

@@ -86,44 +115,37 @@ function infoSetup(t) {
86115
info.className = "action-info"
87116
info.id = "jo"
88117

89-
let infoSpot = document.createElement("div")
90-
infoSpot.className = "action-info"
91-
infoSpot.id = "jo2"
92-
infoSpot.style.display = "none"
93-
infoSpot.style.visibility = "hidden"
94-
95118
let divider = document.createElement("div")
96119
divider.className = "divider"
120+
121+
let title = document.createElement("p")
122+
title.className = "action-info-title"
123+
title.innerHTML = "No action selected."
124+
125+
126+
//let joe = document.getElementById("holder")
97127

98128
if (t) {
129+
99130
t.appendChild(divider)
100131
t.appendChild(info);
101-
t.appendChild(infoSpot);
132+
info.appendChild(title)
102133
}
103-
container = $(".flex-container");
104-
element = $("#jo");
105-
element2 = document.getElementById("jo2")
106-
var containerTop = container.offset().top;
107-
var containerBottom = containerTop + container.outerHeight() - element.outerHeight();
108-
109-
$(window).scroll(function() {
110-
111-
112-
var windowTop = $(window).scrollTop();
113-
if (windowTop >= containerTop && windowTop <= containerBottom) {
114-
element.addClass("fixed");
115-
element2.style.display = "grid";
116-
element.css("top", "2px");
117-
//element.css("width", "50%");
134+
135+
//scroll with window
136+
const stickyElement = document.getElementById('jo');
137+
const ac = document.getElementById('action-list');
138+
const cont = document.getElementById('holder');
139+
140+
window.addEventListener('scroll', () => {
141+
let rect = ac.getBoundingClientRect();
142+
const distanceFromTop = cont.offsetTop - window.pageYOffset || document.documentElement.scrollTop;
143+
//console.log(parseInt(window.getComputedStyle(cont).getPropertyValue('padding-top')), (distanceFromTop-distanceFromTop*2)+window.getComputedStyle(cont).getPropertyValue('padding-top'))
144+
if (rect.top < 0) {
145+
stickyElement.style.marginTop = `${(distanceFromTop-distanceFromTop*2)-parseInt(window.getComputedStyle(cont).getPropertyValue('padding-top'))+10}px`;
118146
} else {
119-
element.removeClass("fixed");
120-
element2.style.display = "none";
121-
if (windowTop < containerTop) {
122-
element.css("top", "0");
123-
} else {
124-
element.css("top", containerBottom - containerTop);
125-
}
126-
}
147+
stickyElement.style.marginTop = 0
148+
}
127149
});
128150
}
129151

@@ -166,14 +188,7 @@ function dataInfoSetup(dat, jo) {
166188

167189
if (dat.event-type && dat.temp) type = "event"
168190

169-
let cont = document.createElement("div")
170-
cont.id = "datainfo"
171-
cont.className = "dbm-info-container"
172-
173-
//let joe = document.getElementById("holder")
174-
document.body.appendChild(cont)
175-
176-
191+
177192

178193
console.log(type)
179194

0 commit comments

Comments
 (0)