-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
108 lines (103 loc) · 4.21 KB
/
index.html
File metadata and controls
108 lines (103 loc) · 4.21 KB
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
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@3.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<div id="app">
<v-app>
<v-content>
<v-container>
<v-layout colum wrap>
<v-flex xs12 mb-4>
<span class="title">Base64 code tool</span>
</v-flex>
<v-flex xs12 mt-4>
<v-textarea outlined label="Base64 data" v-model="base64">
</v-textarea>
</v-flex>
<v-flex xs12 mb-4>
<v-btn color="info" @click="convert('base64','hex')">base64 --> HEX</v-btn>
<v-btn color="info" @click="convert('hex','base64')">HEX --> base64</v-btn>
</v-flex>
<v-flex xs12 mt-4>
<v-textarea outlined label="HEX data" v-model="hex">
</v-textarea>
</v-flex>
<v-flex xs12 mb-4>
<v-btn color="info" @click="convert('base64','string')">base64 --> string</v-btn>
<v-btn color="info" @click="convert('string','base64')">string --> base64</v-btn>
</v-flex>
<v-flex xs12 mt-4>
<v-textarea outlined label="String data" v-model="string">
</v-textarea>
</v-flex>
<v-snackbar color='error' left v-model="snackbar" :timeout="2000">
{{ message }}
<v-btn text flat @click="snackbar = false">
Close
</v-btn>
</v-snackbar>
</v-layout>
</v-container>
</v-content>
</v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: {
snackbar: false,
message: '',
base64: '',
hex: '',
string: ''
},
methods: {
convert: function (from, to) {
fetch(`/convert?to=${to}&from=${from}`, {
body: JSON.stringify({data: this[from]}),
headers: {
'content-type': 'application/json'
},
method: 'POST',
}).then(this.handleResponse)
.then(data => {
this[to] = data.result
})
.catch(err => {
this.message = err.data.message
this.snackbar = true
})
},
handleResponse: function (response) {
return response.json()
.then(json => {
if (response.ok) {
return json
} else {
const err = {
data: json,
status: response.status,
response: response
}
return Promise.reject(err)
}
})
},
}
})
</script>
</body>
<style>
* {
text-transform: none !important;
}
</style>
</html>