-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
156 lines (125 loc) · 4.67 KB
/
index.html
File metadata and controls
156 lines (125 loc) · 4.67 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Trello JSON Reader</title>
<link rel="shortcut icon" href="img/favicon.png" type="image/png" />
<link rel="apple-touch-icon" href="img/favicon.png"/>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="js/jquery.ns-autogrow.min.js"></script>
<script src="https://unpkg.com/showdown@1.9.1/dist/showdown.min.js" crossorigin="anonymous"></script>
<script>
var converter = new showdown.Converter();
var jsDato;
$(document).ready(function () {
$('#txtJSON').autogrow({ horizontal: false });
$('#txtJSON').focus();
});
function readJSON() {
$('#frmJSON').fadeOut(function() {
$('#btnShowForm').fadeIn();
});
var $datos = $('#divDatos');
jsDato = JSON.parse($('#txtJSON').val());
// Title
$datos.html('<h2>' + jsDato.name + '</h2>');
// Date
if (jsDato.due != null) {
let fechVenc = new Date(jsDato.due);
$datos.append('<div class=""><strong>Expire:</strong> ' + fechVenc + '</div>');
}
// URL
if (jsDato.shortUrl != '') {
$datos.append('<a href="' + jsDato.shortUrl + '">Link</a>');
}
// Description
if (jsDato.desc != '') {
$datos.append('<h4 class="mt-4">Description</h4>');
$datos.append(converter.makeHtml(jsDato.desc));
}
// Checklists
if (jsDato.checklists.length > 0) {
$datos.append('<h4 class="mt-4">Checklists</h4>');
// Order the array by position
jsDato.checklists.sort(function(a, b) {
return a.pos - b.pos;
});
$(jsDato.checklists).each(function (index, chkList) {
$datos.append('<div class="mt-4">');
$datos.append('<strong>' + chkList.name + '</strong>');
// Items
// Add completed date
chkList.checkItems.forEach(cItem => {
jsDato.actions.forEach(item => {
if (item.type == "updateCheckItemStateOnCard" && item.data.checkItem.id == cItem.id) {
cItem.fechComp = new Date(item.date);
}
});
});
// Order the items by position
chkList.checkItems.sort(function(a, b) {
// return a.pos - b.pos;
// return (a.state > b.state ? -1 : (a.state < b.state ? 1 : 0)) || (a.pos - b.pos);
return (a.state > b.state ? -1 : (a.state < b.state ? 1 : 0)) || (a.fechComp - b.fechComp) || (a.pos - b.pos);
});
$(chkList.checkItems).each(function (index, item) {
$datos.append('<div>');
if (item.state == 'complete') {
// $datos.append('<i class="far fa-fw fa-check-square text-primary"></i> ' + item.name);
if ($('#chkShowDate').prop('checked')) {
$datos.append('✅ ' + item.name + ' - ' + item.fechComp.toLocaleString());
}
else {
$datos.append('✅ ' + item.name);
}
}
else {
// $datos.append('<i class="far fa-fw fa-square text-primary"></i> ' + item.name);
$datos.append('❌ ' + item.name);
}
$datos.append('</div>');
});
$datos.append('</div>');
});
}
// Activity
// jsDato.actions;
return false;
}
function showForm() {
$('#btnShowForm').fadeOut(function() {
$('#txtJSON').val('');
$('#frmJSON').fadeIn(func => {
$('#txtJSON').focus()
});
});
}
</script>
</head>
<body>
<div class="container">
<div class="p-2 bg-light">
<h1>Trello JSON Reader</h1>
</div>
<form id="frmJSON" onsubmit="return readJSON()">
<div class="form-group">
<label for="txtJSON">JSON Code</label>
<textarea class="form-control form-control-sm" id="txtJSON" style="max-height: 20vh;" required></textarea>
</div>
<div class="form-group">
<label for="chkShowDate"><input type="checkbox" id="chkShowDate" checked> Show Completed Date?</label>
</div>
<div class="form-group mt-1 text-end">
<button class="btn btn-sm btn-primary">Read</button>
</div>
</form>
<button id="btnShowForm" type="button" class="btn btn-sm btn-primary"onclick="showForm()" style="display: none;">Reset</button>
<hr>
<div id="divDatos" class="pb-4"></div>
</div>
</body>
</html>