diff --git a/.ruby-version b/.ruby-version
index 50e47c8..6ebad14 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-3.1.1
\ No newline at end of file
+3.1.2
\ No newline at end of file
diff --git a/toktok/static/js/pr-table.js b/toktok/static/js/pr-table.js
index b30d751..10175d0 100644
--- a/toktok/static/js/pr-table.js
+++ b/toktok/static/js/pr-table.js
@@ -1,5 +1,6 @@
// Polyfill for replaceWith for IE, Firefox < v49, and Safari
-// from: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/replaceWith()/replaceWith().md
+// from:
+// https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/replaceWith()/replaceWith().md
(function (arr) {
arr.forEach(function (item) {
if (item.hasOwnProperty("replaceWith")) {
@@ -15,20 +16,22 @@
argArr.forEach(function (argItem) {
var isNode = argItem instanceof Node;
- docFrag.appendChild(isNode ? argItem : document.createTextNode(String(argItem)));
+ docFrag.appendChild(
+ isNode ? argItem : document.createTextNode(String(argItem)),
+ );
});
this.parentNode.replaceChild(docFrag, this);
- }
+ },
});
});
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
function escapeHTML(text) {
- return text
- .replace(/&/g, "&")
- .replace(//g, ">");
+ return text
+ .replace(/&/g, "&")
+ .replace(//g, ">");
}
function reloadPrTable() {
@@ -39,10 +42,12 @@ function reloadPrTable() {
reloadButton.className += " pr-reloading";
var requestHeaders = new Headers();
- var requestInit = { method: "GET",
- headers: requestHeaders,
- mode: "cors",
- cache: "default" };
+ var requestInit = {
+ method: "GET",
+ headers: requestHeaders,
+ mode: "cors",
+ cache: "default",
+ };
var stateIcon = {
clean: "✅",
@@ -54,76 +59,112 @@ function reloadPrTable() {
unstable: "🚧",
};
- fetch("https://git-critique.herokuapp.com/hello/pulls", requestInit)
- .then(function(response) { return response.json(); })
- .then(function(json) {
- var newRepoSection = document.createElement("div");
- newRepoSection.className = "tables-wrapper"
-
- for (var i = 0; i < json.length; i++) {
- if (json[i].length > 0) {
- var repoTitle = document.createElement("h2");
- repoTitle.innerHTML = json[i][0].prRepoName;
- newRepoSection.appendChild(repoTitle);
-
- var prTable = document.createElement("table");
- prTable.className = "pr-table"
- var prHeaders = document.createElement("tr");
- prHeaders.innerHTML =
- "
" + "#" + " | " +
- "" + "Branch" + " | " +
- "" + "Title" + " | " +
- "" + "State" + " | " +
- "" + "Reviewers" + " | ";
- prTable.appendChild(prHeaders);
-
- for (var j = 0; j < json[i].length; j++) {
- var listItem = document.createElement("tr");
- var reviewableBranch =
- "" +
- escapeHTML(json[i][j].prBranch).replace(/_/g, "_") +
- "";
-
- var githubNumber =
- " " +
- json[i][j].prNumber + "";
-
- // Insert tags after _ characters for neater word-wrapping.
- var titleWithTooltip =
- "" +
- escapeHTML(json[i][j].prTitle).replace(/_/g, "_") +
- "" + escapeHTML(json[i][j].prUser) + "" +
- "
";
-
- var dayInMs = 24*60*60*1000;
- var ageInDays = Math.round((Date.now() - Date.parse(json[i][j].prCreated)) / dayInMs);
- var stateWithTooltip =
- "" + stateIcon[json[i][j].prState] +
- "Created " + ageInDays +
- (ageInDays == 1 ? " day ago." : " days ago.") +
- "" + "
";
-
- listItem.innerHTML =
- "" + githubNumber + " | " +
- "" + reviewableBranch + " | " +
- "" + titleWithTooltip + " | " +
- "" + stateWithTooltip + " | " +
- "" + json[i][j].prReviewers.join(", ") + " | ";
-
- prTable.appendChild(listItem);
+ fetch("https://github-tools.onrender.com/hello/pulls", requestInit)
+ .then(function (response) {
+ return response.json();
+ })
+ .then(function (json) {
+ var newRepoSection = document.createElement("div");
+ newRepoSection.className = "tables-wrapper";
+
+ for (var i = 0; i < json.length; i++) {
+ if (json[i].length > 0) {
+ var repoTitle = document.createElement("h2");
+ repoTitle.innerHTML = json[i][0].prRepoName;
+ newRepoSection.appendChild(repoTitle);
+
+ var prTable = document.createElement("table");
+ prTable.className = "pr-table";
+ var prHeaders = document.createElement("tr");
+ prHeaders.innerHTML =
+ "" +
+ "#" +
+ " | " +
+ "" +
+ "Branch" +
+ " | " +
+ "" +
+ "Title" +
+ " | " +
+ "" +
+ "State" +
+ " | " +
+ "" +
+ "Reviewers" +
+ " | ";
+ prTable.appendChild(prHeaders);
+
+ for (var j = 0; j < json[i].length; j++) {
+ var listItem = document.createElement("tr");
+ var reviewableBranch =
+ "" +
+ escapeHTML(json[i][j].prBranch).replace(/_/g, "_") +
+ "";
+
+ var githubNumber =
+ " " +
+ json[i][j].prNumber +
+ "";
+
+ // Insert tags after _ characters for neater word-wrapping.
+ var titleWithTooltip =
+ "" +
+ escapeHTML(json[i][j].prTitle).replace(/_/g, "_") +
+ "" +
+ escapeHTML(json[i][j].prUser) +
+ "" +
+ "
";
+
+ var dayInMs = 24 * 60 * 60 * 1000;
+ var ageInDays = Math.round(
+ (Date.now() - Date.parse(json[i][j].prCreated)) / dayInMs,
+ );
+ var stateWithTooltip =
+ "" +
+ stateIcon[json[i][j].prState] +
+ "Created " +
+ ageInDays +
+ (ageInDays == 1 ? " day ago." : " days ago.") +
+ "" +
+ "
";
+
+ listItem.innerHTML =
+ "" +
+ githubNumber +
+ " | " +
+ "" +
+ reviewableBranch +
+ " | " +
+ "" +
+ titleWithTooltip +
+ " | " +
+ "" +
+ stateWithTooltip +
+ " | " +
+ "" +
+ json[i][j].prReviewers.join(", ") +
+ " | ";
+
+ prTable.appendChild(listItem);
+ }
+ newRepoSection.appendChild(prTable);
}
- newRepoSection.appendChild(prTable);
}
- }
- var repoSection = document.querySelector(".tables-wrapper");
- repoSection.replaceWith(newRepoSection);
- reloadButton.className = reloadButtonClass;
- var end = new Date();
- var deltaTime = end.getTime() - start.getTime();
- console.log("PR table took %s seconds to load.", (deltaTime)/1000.0);
- });
+ var repoSection = document.querySelector(".tables-wrapper");
+ repoSection.replaceWith(newRepoSection);
+ reloadButton.className = reloadButtonClass;
+ var end = new Date();
+ var deltaTime = end.getTime() - start.getTime();
+ console.log("PR table took %s seconds to load.", deltaTime / 1000.0);
+ });
}
reloadPrTable();