-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
119 lines (110 loc) · 5.44 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>In and Out JSON to sorted JSON</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<!-- Latest Sortable doesn't yet have the feature avoidImplicitDeselect -->
<!-- We need this feature, so we built Sortable locally to include that. -->
<!-- <script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"></script> -->
<script src="./Sortable.js"></script>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<!-- Sources of inspiration -->
<!-- https://aruljohn.com/jsonsort/ -->
<!-- https://shouts.dev/articles/generate-json-using-sortablejs-drag-and-drop -->
<style>
body {
padding: 20px;
}
.list-group-item {
cursor: move;
cursor: -webkit-grabbing;
}
.boxfull {
width: 100%;
}
.selected {
background-color: #f9c7c8;
border: solid red 1px !important;
z-index: 1 !important;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<h1 class="text-center">Welcome to in-n-out</h1>
</div>
</div>
<div class="row">
<!-- <div class="col-md-4"></div> -->
<div class="col-md-6">
<h5 class="text-center">This is a simple tool to deal with JSON array. You can ingest a JSON array and then sort it, drag and re-order items. Multi-select and multi-drag is supported.</h5>
<h5>SortableJS provides much of the functionality.</h5>
</div>
<div class="col-md-6">
<h5>Please note that all text elements are cropped to the first ten characters, because in-n-out doesn't want to make any assumptions on how large your arrays are and it wants to display things nicely.</h5>
</div>
<!-- <div class="col-md-4"></div> -->
</div>
<br>
<br>
<div class="row">
<div class="col-md-4">
<h5 class="text-center">Enter JSON Array</h5>
<div class="text-center">
<button type="button" id="ingestJSON" class="btn btn-info">Ingest JSON</button>
</div>
</div>
<div class="col-md-8">
<textarea rows="10" name="str" class="boxfull" id="str">[{"id":1,"location":"123 Road Dr","city_state":"MyCity ST","phone":"555-555-5555","distance":"1"},{"id":2,"location":"456 Avenue Crt","city_state":"MyTown AL","phone":"555-867-5309","distance":"0"}]</textarea>
</div>
</div>
<div class="row">
<div class="col-md-8">
<h4 class="text-center">JSON Items</h4>
<div class="text-center">
<div id="divsort"></div>
</div>
<div class="text-center">
<div id="divdelete">
→ Delete Selected items <button type="button" id="deleteElements" class="btn btn-danger">Delete</button>
</div>
</div>
<div class="text-center">
<button type="button" id="generateJSON" class="btn btn-info">Generate JSON</button>
</div>
<!-- product list -->
<div id="productList" class="list-group list-group-flush">
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><span id="id" class="font-weight-bold">1</span>. <span id="title">£50 PSN PlayStation Network Card UK</span></span>
<span class="badge badge-primary badge-pill">21</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><span id="id" class="font-weight-bold">2</span>. <span id="title">Microsoft Office 2019 Professional Plus</span></span>
<span class="badge badge-primary badge-pill">35</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><span id="id" class="font-weight-bold">3</span>. <span id="title">FIFA 20 Standard Edition Xbox One</span></span>
<span class="badge badge-primary badge-pill">45</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><span id="id" class="font-weight-bold">4</span>. <span id="title">Apex Legends 6700 Coins PS4</span></span>
<span class="badge badge-primary badge-pill">17</span>
</li>
</div>
</div>
<div class="col-md-4">
<h4 class="text-center">JSON</h4>
<pre id="printCode"></pre>
</div>
</div>
</div>
<script src="./script.js"></script>
</body>
</html>