1
+ const DBMInfo = info
2
+
3
+ const urlParams = new URLSearchParams ( queryString ) ;
4
+ const data = urlParams . get ( 'data' )
5
+ console . log ( data ) ;
6
+
1
7
var rd_actionlist ;
2
8
var rd_info ;
3
9
var scroll = true ;
4
- var RDInput = document . getElementById ( "rawdata-input" )
10
+ var RDInput = document . getElementById ( "rawdata-input" ) ;
5
11
6
12
var container ;
7
13
var element ;
8
14
var element2 ;
9
15
10
- if ( RDInput . focus ) {
11
-
12
-
13
- }
14
-
15
16
function isJsonString ( str ) {
16
17
try {
17
18
JSON . parse ( str ) ;
@@ -21,6 +22,8 @@ function isJsonString(str) {
21
22
return true ;
22
23
}
23
24
25
+ RDInput . focus ( ) ;
26
+
24
27
function joe ( ) {
25
28
document . getElementById ( "invalid" ) . style . display = "none" ;
26
29
clear ( )
@@ -33,11 +36,30 @@ function joe() {
33
36
if ( isJsonString ( RDInput . value ) ) {
34
37
//document.getElementById("invalid").style.display = "none";
35
38
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
+ }
37
57
38
58
loadData ( val )
59
+ dataInfoSetup ( val )
39
60
40
61
} else {
62
+ document . getElementById ( "invalidText" ) . innerHTML = info . messages . errJSON
41
63
document . getElementById ( "invalid" ) . style . display = "grid" ;
42
64
document . getElementById ( "invalid" ) . style . animation = "showInvalid 0.3s linear forwards" ;
43
65
}
@@ -50,17 +72,24 @@ function loadData(val) {
50
72
clear ( 0 )
51
73
52
74
let data = JSON . parse ( val ) ;
53
- let joe = document . createElement ( "form" )
54
- let container = document . createElement ( "div" )
55
-
56
75
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
57
81
82
+ let container = document . createElement ( "div" )
83
+ container . id = "action-list"
58
84
container . className = "action-list"
85
+
86
+ let joe = document . createElement ( "form" )
59
87
joe . className = "container flex-container"
60
88
joe . id = "holder"
89
+
61
90
//console.log(data.actions)
62
91
var actions = data . actions ?? [ { name :"?" } ]
63
-
92
+
64
93
dataInfoSetup ( data , joe )
65
94
joe . appendChild ( container ) ;
66
95
@@ -77,7 +106,7 @@ function loadData(val) {
77
106
infoSetup ( joe )
78
107
79
108
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 )
81
110
scroll = false
82
111
}
83
112
@@ -86,44 +115,37 @@ function infoSetup(t) {
86
115
info . className = "action-info"
87
116
info . id = "jo"
88
117
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
-
95
118
let divider = document . createElement ( "div" )
96
119
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")
97
127
98
128
if ( t ) {
129
+
99
130
t . appendChild ( divider )
100
131
t . appendChild ( info ) ;
101
- t . appendChild ( infoSpot ) ;
132
+ info . appendChild ( title )
102
133
}
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` ;
118
146
} 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
+ }
127
149
} ) ;
128
150
}
129
151
@@ -166,14 +188,7 @@ function dataInfoSetup(dat, jo) {
166
188
167
189
if ( dat . event - type && dat . temp ) type = "event"
168
190
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
+
177
192
178
193
console . log ( type )
179
194
0 commit comments