1+ <!DOCTYPE html>
2+ < html lang ="en " class ="h-100 ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < link rel ="stylesheet " type ="text/css " href ="vdlcss-min.css ">
8+ < link rel ="icon " type ="image/png " sizes ="32x32 " href ="favicons/favicon-32x32.png ">
9+ < link rel ="icon " type ="image/png " sizes ="16x16 " href ="favicons/favicon-16x16.png ">
10+
11+ < style >
12+ : root {
13+ --yellow : # DEDE6C ;
14+ --black : # 121212 ;
15+ --primary : var (--yellow );
16+ --primary-dark : # bbbb5d ;
17+ --primary-light : # f3f39c ;
18+ }
19+
20+ h1 {
21+ font-size : 32px ;
22+ color : var (--white );
23+ }
24+
25+ h2 {
26+ color : var (--white );
27+ }
28+
29+ body {
30+ color : var (--white );
31+ min-height : 100% ;
32+ }
33+
34+ # script-wrapper {
35+ max-width : 960px ;
36+ }
37+ </ style >
38+
39+ < title > SCM - Script Manager</ title >
40+ </ head >
41+ < body class ="bg-yellow p-05 column between md:h-100 ">
42+ < div class ="h-100 w-100 bg-black column center ">
43+ < div class ="column center md:mb-5 w-100 ">
44+ < h1 class ="yellow "> Script Manager</ h1 >
45+ < p class ="m-0 "> Manage your ComputerCraft scripts with ease.</ p >
46+ < div class ="grid mt-2 px-1 ">
47+ < div class ="cell-12 md:cell-4 ">
48+ < div class ="bg-yellow p-1 rounded shadow ">
49+ < h2 class ="my-0 black "> Install</ h2 >
50+ < pre class ="mt-1 "> < code > pastebin run 1kKZ8zTS</ code > </ pre >
51+ </ div >
52+ </ div >
53+ < div class ="cell-12 md:cell-8 px-1 ">
54+ < h2 class ="mt-0 mb-05 "> Features</ h2 >
55+ < ul >
56+ < li class ="mb-05 "> Download scripts from Pastebin or GitHub.</ li >
57+ < li class ="mb-05 "> Update your scripts with a simple command.</ li >
58+ < li class ="mb-05 "> Auto-install missing libraries.</ li >
59+ < li >
60+ < a target ="_blank " href ="https://github.com/mc-cc-scripts/script-manager/wiki "> And more...</ a >
61+ </ li >
62+ </ ul >
63+ </ div >
64+ </ div >
65+ < div class ="row mt-1 ">
66+ < a target ="_blank " href ="https://github.com/mc-cc-scripts/script-manager " class ="black button mr-1 "> Source</ a >
67+ < a target ="_blank " href ="https://github.com/mc-cc-scripts/script-manager/wiki " class ="black button "> Documentation</ a >
68+ </ div >
69+ < div class ="mt-1 px-1 w-100 md:w-auto ">
70+ < h2 class ="my-0 "> Programs</ h2 >
71+ < p > Installing programs can be as easy as < code class ="yellow "> scm add testProgram</ code > .</ p >
72+ < p > Don't want to use our official GitHub repository? No Problem! You can change it to your own with a single command: < code class ="yellow "> scm config user <your-name></ code > .</ p >
73+ < p > Or, if you would rather install a program from pastebin, < code class ="yellow "> scm add testProgram@7ByR3NYn</ code > .</ p >
74+ < p class ="mt-2 "> < strong > Some of our scripts...</ strong > </ p >
75+ < div id ="script-wrapper " class ="scroll-x-snap row pt-05 pb-1 mb-1 ">
76+ </ div >
77+ </ div >
78+ </ div >
79+ </ div >
80+ < template id ="script-template ">
81+ < div
82+ class ="inline-flex bg-yellow black rounded shadow p-1 mr-05 column between h-100 "
83+ style ="min-width: 200px; max-width: 200px; width: 100%; min-height: 200px; height: 100%; white-space: normal; "
84+ >
85+ < div >
86+ < div class ="mb-05 link ">
87+ < a href ="# " class ="black " target ="_blank "> < strong class ="name "> </ strong > </ a >
88+ </ div >
89+ < div class ="mb-1 ">
90+ < em class ="type "> </ em >
91+ </ div >
92+ < div class ="description "> </ div >
93+ </ div >
94+ < div class ="code ">
95+ < code class ="black "> </ code >
96+ </ div >
97+ </ div >
98+ </ template >
99+ < script >
100+ let scriptWrapper = document . querySelector ( '#script-wrapper' )
101+ let template = document . querySelector ( '#script-template' )
102+
103+ function addCards ( data ) {
104+ let installScript = { }
105+ installScript [ 'Library' ] = 'require'
106+ installScript [ 'Program' ] = 'add'
107+
108+ for ( let i = 0 ; i < data . length ; ++ i ) {
109+ let tmpElement = template . content . cloneNode ( true )
110+ let tmpName = data [ i ] . name
111+ if ( ! tmpName . endsWith ( '-prog' ) && ! tmpName . endsWith ( '-lib' ) ) continue
112+ let tmpType = tmpName . endsWith ( '-prog' ) ? 'Program' : 'Library'
113+ tmpName = tmpName . substring ( 0 , tmpName . lastIndexOf ( '-' ) )
114+ tmpElement . querySelector ( '.name' ) . innerHTML = tmpName
115+ tmpElement . querySelector ( '.type' ) . innerHTML = tmpType
116+ tmpElement . querySelector ( '.description' ) . innerHTML = data [ i ] . description
117+ tmpElement . querySelector ( '.link a' ) . href = 'https://github.com/' + data [ i ] . full_name
118+ tmpElement . querySelector ( '.code code' ) . innerHTML = 'scm ' + installScript [ tmpType ] + ' ' + tmpName
119+
120+ scriptWrapper . appendChild ( tmpElement )
121+ }
122+ }
123+
124+ async function getData ( ) {
125+ // check localStorage first
126+ let localStorageData = localStorage . getItem ( 'data' )
127+ if ( localStorageData !== null && localStorageData !== 'null' ) return JSON . parse ( localStorageData )
128+
129+ // call github api to get info about our scripts
130+ let response = await fetch ( 'https://api.github.com/orgs/mc-cc-scripts/repos?type=all&per_page=100&page=1' )
131+ let data = await response . json ( )
132+
133+ // store data in localStorage to avoid too many api calls
134+ let cleanData = [ ]
135+ for ( let i = 0 ; i < data . length ; ++ i ) {
136+ cleanData [ i ] = { }
137+ cleanData [ i ] . name = data [ i ] . name
138+ cleanData [ i ] . description = data [ i ] . description
139+ cleanData [ i ] . full_name = data [ i ] . full_name
140+ }
141+ localStorage . setItem ( 'data' , JSON . stringify ( cleanData ) )
142+
143+ return cleanData
144+ }
145+
146+ getData ( ) . then ( data => addCards ( data ) )
147+ </ script >
148+ </ body >
149+ </ html >
0 commit comments