This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
View Dictionary.scpl
113 lines (111 loc) · 3.03 KB
/
View Dictionary.scpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
@Icon tree
@Color blue
#@ShowInShareSheet true
#@Accepts [Anything]
SetVariable v:passthru_arg
Comment
|*View a dictionary into a colored, collapsible tree.
|
|* Based mostly from this article that uses renderjson with a bit of style adjustments.
|
|https://ourcodeworld.com/articles/read/753/creating-collapsible-tree-structures-from-json-into-html-in-javascript
|
|
Dictionary {
"Shortcut" : "View Dictionary",
"Author" : "@supermamon",
"Version" : "2.0",
"RoutineHub ID" : "307",
Changes: {
"v1.0": "Initial release",
"v2.0": "support for list of dictionaries"
},
CheckUpdates: 1
} -> mv:meta
GetVariable v:passthru_arg
SetVariable v:dict
Count Items -> mv:Count
If "Is Greater Than" 1
GetVariable v:dict
CombineText separator=Custom custom="," -> mv:"Combine Text"
Text "[\(mv:"Combine Text")]"
SetVariable dict
End -> mv:If
GetVariable v:dict
Text
|<!DOCTYPE html>
|<html>
| <head>
| <meta charset=\"utf-8\" />
| <meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />
| <script src=\"https://cdn.rawgit.com/caldwell/renderjson/master/renderjson.js\"></script>
| <style>
| body {
| background: #303030;
| }
| #con {
| text-shadow: none;
| background: #303030;
| padding: 1em;
| }
| .renderjson a {
| text-decoration: none;
| color: #fff;
| }
| .renderjson .disclosure {
| color: crimson;
| font-size: 125%;
| position: relative;
| top: 3px;
| }
| .renderjson .syntax {
| color: grey;
| }
| .renderjson .string {
| color: pink;
| }
| .renderjson .number {
| color: cyan;
| }
| .renderjson .boolean {
| color: plum;
| }
| .renderjson .key {
| color: lightblue;
| }
| .renderjson .keyword {
| color: lightgoldenrodyellow;
| }
| .renderjson .object.syntax {
| color: lightseagreen;
| }
| .renderjson .array.syntax {
| color: lightsalmon;
| }
| </style>
| </head>
| <body>
| <div id=\"con\"></div>
| <script>
| var data = \(v:dict)
| document.getElementById(\"con\").appendChild(renderjson(data))
| </script>
| </body>
|</html>
SetName name="json.html"
ShowWebpage
Comment "*** UpdateKit ***"
GetVariable mv:meta.CheckUpdates
If input=Equals value=1
GetMyShortcuts
If Contains "UpdateKit"
Dictionary {
"Shortcut Name" : mv:meta.Shortcut,
"Current Version" : mv:meta.Version,
"RoutineHub ID" : mv:meta."RoutineHub ID"
}
RunShortcut shortcut=UpdateKit showWhileRunning=false
End
End
Comment "* pass the original arguments out"
GetVariable v:passthru_arg