-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrello-ui.js
38 lines (35 loc) · 1.03 KB
/
trello-ui.js
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
export const trelloUi = {
getColumns() {
return document.querySelectorAll(".list.js-list-content");
},
getCardsInColumn(column) {
const cards = column.getElementsByClassName("list-cards");
if (cards.length > 0) return cards[0].childNodes;
return [];
},
getCardTitle(card) {
const titleNodes = card.getElementsByClassName("list-card-title");
if (titleNodes.length > 0) return titleNodes[0].innerText;
return "";
},
getAllCards() {
const cards = document.querySelectorAll(".list-card");
return cards;
}
};
export const trelloUrl = {
getBoardId(url) {
const regexMatch = /https:\/\/trello.com\/b\/([A-Za-z0-9]+)\/\S+/.exec(url);
if (regexMatch) return regexMatch[1];
return "";
},
getCardId(url) {
const regexMatch = /https:\/\/trello.com\/c\/([A-Za-z0-9]+)\/\S+/.exec(url);
if (regexMatch) return regexMatch[1];
return "";
},
getCardNumber(url) {
const lastUrlSegment = url.split("/").pop();
return lastUrlSegment.substr(0, lastUrlSegment.indexOf("-"));
}
};