aboutsummaryrefslogtreecommitdiff
path: root/html/settings.html
blob: 1aca97df75c0d1e42abb2fe7ff590b01486e8d81 (plain)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<!DOCTYPE html>
<!--for embeds-->
<meta property="og:type" content="website">
<meta property="og:title" content="sns-chan settings">
<meta property="og:description" content="verify with a key for details">
<meta property="og:image" content="https://i.pinimg.com/originals/8f/52/1b/8f521bf9a52f7f9d3da912e4abf07979.png">
<!--not ugly mobile view:p -->
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<html>

<head>
  <title>sns-chan</title>
  
</head>
  <style>
    body{
        padding: 0;
        margin: 0;
        overflow: scroll;
    }

    a {
        color:initial;
        text-decoration: none;
    }

    #side-bar {
        color:aliceblue;
        overflow: scroll;
        padding: 0;
        background-color: #2c3142;
        position: fixed;
        top:0;
        left:0;
        min-width: 300px;
        height: 100%;
    }
    #rest {
        overflow:scroll;
        margin-left: 300px;
    }

    .side-bar-dir{
        background-color: rgba(0, 0, 10, 0.25);
        padding: 5px;
        margin: 5px;
        border-radius: 2px;
    }
    .side-bar-dir:hover{
        background-color: rgba(0, 0, 10, 0.20);
    }

    .side-bar-head{
        font-size: 30px;
        padding-left: 10px;
    }
    
    .side-bar-item{
        color:aliceblue;
        background-color: rgba(0, 0, 10, 0.15);
        font-size: 21px;
        padding-left: 20px;
    }
    .side-bar-item:hover{
        background-color: rgba(0, 0, 10, 0.08);
    }
  </style>
  <script>
    //cookie code taken from https://github.com/squiresgrant/kanna-site/blob/main/html/index.html
    //which i probably stole from stackoverflow
    function setCookie(name, value, days) {
      var expires = "";
      if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toUTCString();
      }
      document.cookie = name + "=" + (value || "") + expires + "; path=/";
    }
    function getCookie(name) {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
      }
      return null;
    }
    function eraseCookie(name) {
      document.cookie = name + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
    }
    function send(location, content) {
      return new Promise((res, rej) => {
        var xhr = new XMLHttpRequest();
        let st = 'http://' + window.location.host + window.location.pathname + "/" + location
        xhr.open("POST", st, true);
        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.onreadystatechange = function () {
          if (xhr.readyState == XMLHttpRequest.DONE) {
            console.log('['+xhr.status+']'+' '+st)
            res(xhr.responseText);
          }
        }
        let out = {}
        Object.assign(out, { json: true, enc: false }, content)
        xhr.send(JSON.stringify(out))
      })
    }

    let settings;
    function fetch() {
      return new Promise(async (res, rej) => {
        if (getCookie('main_key') == null) {
          setCookie('main_key', window.prompt('you do not have a valid key, contact ans-chan (@nekomusu) for it'), 90)
        }

        let data = await send('data', { key: getCookie('main_key') })
        if (data == 'failed') {
          alert('invalid key, clearing cookies')
          eraseCookie('main_key')
          fetch()
          return
        }
        settings = JSON.parse(data)
        res()
      })
    }

    async function init() {
      await fetch();

      let push = "" 
      for(let key in settings.data){
        push += "<div class = 'side-bar-dir'>"
              + "<div class = 'side-bar-head'>" + key + "</div>"
        for(let i of settings.data[key]){
            push += "<a href='/settings/"+key+"/"+i+"'><div class = 'side-bar-item'>" + i + "</div></a>"
        }
        push += "</div>"
      }
      
      document.getElementById("side-bar").innerHTML = push

      if(settings.sel != "null"){
        console.log(settings.sel)
        let sell = JSON.parse(settings.sel);
        push = ""
        function rec_awa(sel, key_app = ""){
            push = ""
            for(let key in sel){
                if(typeof sel[key] !== 'object')
                    push += key_app + key + ": <input type='text' value='"+sel[key]+"'></br>"
                else if (sel[key].value != null) {
                    if(sel[key].options == null) {
                        if(typeof sel[key].value !== 'object')
                            push += key_app + key + ": <input type='text' value='"+sel[key].value+"'></br>"
                        else{
                            push += rec_awa(sel[key].value, key_app + key + ".")
                        }
                    } else {
                        push += key_app + key + ": <select>"
                        for(let op of sel[key].options){
                            push += "<option value='"+op+"'>"+op+"</option>"
                        }
                        push += "</select></br>"
                    }
                        
                } else push += rec_awa(sel[key], key_app + key + ".")
            }
            return push
        }
        push = rec_awa(sell)
        if(push == "") push = "nothing is here:c"
        document.getElementById("rest").innerHTML = push
      }

      document.getElementById("rest").style.display = "block"

    }
  </script>
  
<body onload="init()">

    <div id="side-bar">
        <!--
        <div class="side-bar-dir">
            <div class="side-bar-head">tool</div>
            <div class="side-bar-item">test</div>
            <div class="side-bar-item">test2</div>
        </div>-->

    </div>

    <div id="rest" style="display:none;">
        <pre style="cursor: default;">
        ████████        ████████  ████                                          
        ██▓▓▒▒▓▓████  ██        ██    ██              ██████████                
        ██▒▒████▓▓▓▓██    ░░    ░░      ██  ██████████▒▒▒▒▓▓▒▒██                
        ██▓▓██░░████  ░░░░░░░░░░░░░░      ██▓▓▓▓▒▒▒▒▒▒▒▒████▒▒██                
          ████░░██  ░░████████████░░░░░░░░  ▓▓▓▓▓▓▓▓████░░██▓▓██                
            ████  ░░▓▓▓▓▓▓▓▓████▓▓▓▓██▓▓░░░░▒▒██▓▓██▒▒▒▒░░██▓▓▓▓                
              ██░░▓▓▒▒▓▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓░░░░░░██░░░░  ██▓▓▓▓                  
            ██  ██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓████░░░░██░░░░██▓▓██                  
            ██░░██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓██░░██░░██▓▓██                    
              ██▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓██░░██▓▓██                      
            ██▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓██░░██████                       well...
            ██▒▒▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓██▓▓▓▓██                      
            ██▒▒▒▒▒▒▓▓██▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒▓▓▒▒▒▒▒▒▓▓▓▓▓▓▓▓██                       select something first:p
            ██▒▒▒▒▒▒▓▓██▒▒▒▒▒▒▓▓▓▓▒▒▒▒▒▒▓▓▒▒▒▒▒▒▓▓▓▓▓▓▓▓██                      
            ██▒▒▒▒▓▓████▒▒▒▒▒▒▓▓██▒▒▒▒▓▓▓▓▒▒▒▒▒▒▓▓▓▓▓▓▓▓██                      
              ██████░░░░██▒▒▒▒▓▓██▒▒▒▒▓▓██▒▒▒▒▒▒▓▓▓▓▓▓▓▓██                      
            ██▓▓██▓▓▓▓▓▓░░██████░░██████▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓██                      
            ██▓▓██  ▒▒▒▒░░░░░░░░▓▓▓▓▓▓▒▒██▒▒▒▒▓▓▓▓▓▓▓▓▓▓██                      
            ██▓▓▓▓░░░░░░░░░░░░░░  ▒▒▒▒░░▓▓▒▒▒▒▓▓▓▓▓▓▓▓██                        
            ██▒▒██░░          ░░░░░░░░██▒▒▒▒▓▓▓▓▓▓▓▓▓▓██                        
            ██▒▒▓▓██    ▓▓░░        ░░██▒▒▒▒▓▓▓▓▓▓▓▓▓▓██                        
              ██▒▒██                ██▒▒▒▒▓▓▓▓▓▓▓▓▓▓██                          
              ██▒▒██░░    ▒▒▒▒      ░░████▓▓▓▓▓▓▓▓██                            
                ██▓▓██    ░░░░    ░░██░░██▒▒▓▓▓▓██                              
                ██▒▒▓▓▓▓▓▓      ░░▓▓▒▒▓▓▒▒▒▒████                                
              ██  ██▓▓██░░████████░░░░██████                                    
            ██  ░░░░████  ██░░██    ░░░░██                                      
          ██    ░░▓▓░░░░████░░░░██    ██░░▓▓██    ██████                        
          ██  ▒▒░░▓▓░░▓▓▓▓▓▓██▓▓██▓▓▓▓░░░░░░░░▓▓██░░░░░░██                      
        ██  ░░░░▓▓░░▓▓▓▓▓▓██▓▓██▓▓▓▓██░░░░░░░░░░██  ░░░░██                      
          ██  ░░██░░██████░░██▓▓▓▓████░░░░  ░░██    ░░░░░░██                    
        ██▓▓██░░██░░░░░░░░░░░░██▓▓██░░░░    ░░██  ░░░░████                      
      ██▒▒▓▓▓▓██    ░░░░░░░░░░░░████░░░░░░░░░░██  ░░██▓▓▓▓██                    
      ██▒▒▓▓██        ░░░░░░░░░░░░░░░░░░░░░░██    ██▓▓▓▓▓▓▓▓██                  
    ██▒▒▓▓██          ░░██░░██░░    ░░░░██░░██  ░░██▓▓▓▓▓▓▓▓██                  
  ██▒▒▓▓▓▓██          ░░░░██          ░░██░░██  ██▓▓▓▓▓▓▓▓▓▓▓▓██                
  ██▒▒▓▓██░░          ░░██            ░░░░██    ██▓▓▓▓▒▒▓▓▒▒▓▓██                
    ██▓▓████░░░░    ░░░░██            ░░░░██  ░░██▓▓▒▒▒▒▒▒▒▒▓▓██                
  ██████    ████░░░░░░██              ░░░░██  ░░██▓▓▓▓▒▒▒▒▒▒▓▓▓▓██              
██░░░░██    ░░░░██▓▓░░██░░          ░░░░░░▓▓  ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓██              
  ██░░██░░          ██████░░░░░░░░░░██▓▓██▓▓░░░░██▓▓▓▓▓▓▓▓▓▓▓▓██                
    ████░░░░        ░░░░  ▓▓▓▓██████░░  ▒▒██░░░░██▓▓▒▒▓▓▓▓▓▓▓▓████              
        ██░░░░░░░░░░░░░░                ░░░░██░░██▓▓▓▓▓▓▓▓▓▓██░░░░██            
        ██░░░░░░░░░░▒▒░░░░            ░░░░░░████▓▓▓▓▓▓██████░░░░████            
          ██░░░░░░░░████░░▒▒░░░░░░░░░░░░░░░░██▓▓██████░░░░░░░░██                
          ░░██████▓▓▓▓▓▓██░░░░░░░░░░░░░░░░██▓▓▓▓██▒▒░░  ▓▓████                  
            ██▓▓▓▓▓▓▓▓▓▓▓▓████░░░░░░░░████▓▓▓▓██      ██░░██                    
            ██▒▒▓▓▒▒▒▒▒▒▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓████████░░░░██                    
                                                                        
        </pre>
    </div>
  
</body>

</html>