-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcomment-editor.html
105 lines (100 loc) · 4.86 KB
/
comment-editor.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Editing comment</title>
<link href="./icon-transparent.png" rel="icon" type="image/x-png">
<link rel="stylesheet" href="https://a.trellocdn.com/css/63834d177435ef6ba76764be22c29ae4/core.css">
<link rel="stylesheet" href="https://trello.com/power-ups/power-up.css">
<link rel="stylesheet" href="./css/simplemde.min.css">
<link rel="stylesheet" href="./css/comment-editor.css">
</head>
<body class="window-overlay">
<div class="window">
<div class="window-buttons">
<a class="window-button icon-lg icon-external-link js-new-tab" href="#"></a>
<a class="window-button icon-lg icon-close js-close-window" href="#"></a>
</div>
<div class="phenom mod-comment-type is-editing">
<div class="window-module-title window-module-title-no-divider">
<span class="window-module-title-icon icon-lg icon-comment"></span>
<h3>Editing comment from card <a id="js-card-link" href="#" target="_blank"></a></h3>
<span class="editing-members js-editing-members hide"></span>
</div>
<div class="comment-frame">
<div class="comment-box markeddown">
<textarea class="comment-box-input js-new-comment-input" placeholder="Write a comment…" tabindex="1" dir="auto"></textarea>
<!--
<div class="comment-box-options">
<a class="comment-box-options-item js-comment-add-attachment" href="#" title="Add an attachment…"><span class="icon-sm icon-attachment"></span></a>
<a class="comment-box-options-item js-comment-mention-member" href="#" title="Mention a member…"><span class="icon-sm icon-mention"></span></a>
<a class="comment-box-options-item js-comment-add-emoji" href="#" title="Add emoji…"><span class="icon-sm icon-emoji"></span></a>
<a class="comment-box-options-item js-comment-add-card" href="#" title="Add card…"><span class="icon-sm icon-card"></span></a>
</div>
-->
</div>
</div>
<div class="edit-controls u-clearfix">
<div class="js-too-long-warning hide">
<p>Your comment is too long.</p>
</div>
<div class="js-is-empty-warning hide">
<p>You haven't typed anything!</p>
</div>
<input class="primary confirm js-save-edit" type="submit" value="Save" tabindex="2" disabled>
</div>
<p class="phenom-meta quiet">
<span class="save-failure">⚠️ Could not save! Please check your connectivity and try again.</span>
<span class="date js-hide-on-sending">Last saved at <span></span></span>
<span class="js-spinner hide">
<span class="spinner spinner--inline mod-left small"></span>
Sending…
</span>
</p>
</div>
</div>
<script src="https://trello.com/power-ups/power-up.min.js"></script>
<script src="https://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="./js/simplemde.min.js"></script>
<script src="./js/comment-editor.js"></script>
<script>
// extract parameters from url/path
const parts = window.location.href.split('?').pop().split('#')[0].split('/');
const
cardId = parts[0],
commentId = parts[1],
token = parts[2],
date = parts[3];
const key = '0b15414357140fe88faecea94f0a22b1';
const apiParams = {
key,
token,
filter: 'commentCard',
since: new Date(new Date(date).getTime() - 1).toISOString(),
before: new Date(new Date(date).getTime() + 1).toISOString(),
};
const trelloApi = 'https://api.trello.com/1';
$.get(`${trelloApi}/cards/${cardId}/actions`, apiParams)
.done(function(res){
const comment = res.filter(comment => comment.id == commentId)[0];
$('#js-card-link')
.attr('href', 'https://trello.com/c/' + comment.data.card.id)
.text(comment.data.card.name);
$('.js-new-comment-input').text(comment.data.text);
var editor = initEditor(token, comment.id, SimpleMDE);
editor.refreshLastSavedTime(date);
});
// TODO: don't keep token and IDs visible in URL,
// e.g. by opening popup using POST, cf https://stackoverflow.com/a/3951843/592254
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1858235-24', 'auto');
var path = document.location.pathname;
ga('send', 'pageview', path.split('/').slice(0, -2).join('/')); // remove token and date
</script>
</body>
</html>