From 0ab6d690c24b12dcdbe0991d469b429695ef62f1 Mon Sep 17 00:00:00 2001 From: Nirmal Scaria <46727865+NirmalScaria@users.noreply.github.com> Date: Wed, 7 Aug 2024 04:46:22 +0530 Subject: [PATCH] [FIX] Firefox compatability --- js/fetchFilteredCommits.js | 3 ++- js/fetchFurther.js | 3 ++- js/loadBranchesButton.js | 20 +------------------- js/showCommits.js | 4 ++-- js/sortCommits.js | 4 ++-- manifest.json | 4 ++-- 6 files changed, 11 insertions(+), 27 deletions(-) diff --git a/js/fetchFilteredCommits.js b/js/fetchFilteredCommits.js index 119ffc9..62f0727 100644 --- a/js/fetchFilteredCommits.js +++ b/js/fetchFilteredCommits.js @@ -146,7 +146,8 @@ async function fetchFilteredCommits(selectedBranchNames, selectedBranches, allBr if (await fetchCommitsPageFiltered(repoOwner, repoName, "NONE")) { console.log("--FETCHED BRANCHES--"); console.log("--COST : '" + APIcost + "'--"); - branches = branches.map(branch => { + branches = branches.map(branchOriginal => { + var branch = JSON.parse(JSON.stringify(branchOriginal)); heads.push({ name: branch.name, oid: branch.history.edges[0].node.oid, diff --git a/js/fetchFurther.js b/js/fetchFurther.js index 78e6dca..6a811b8 100644 --- a/js/fetchFurther.js +++ b/js/fetchFurther.js @@ -85,7 +85,8 @@ async function fetchFurther(commits, allCommits, heads, pageNo, branchNames, all for (var newCommitId in newlyFetchedCommits) { var newCommit = newlyFetchedCommits[newCommitId]; var thisCommits = newCommit.history.edges; - for (var thisCommit of thisCommits) { + for (var thisCommitOriginal of thisCommits) { + var thisCommit = JSON.parse(JSON.stringify(thisCommitOriginal)); thisCommit = thisCommit.node; thisCommit.committedDate = parseDate(thisCommit.committedDate); allCommits.push(thisCommit); diff --git a/js/loadBranchesButton.js b/js/loadBranchesButton.js index 0a30763..7176528 100644 --- a/js/loadBranchesButton.js +++ b/js/loadBranchesButton.js @@ -7,25 +7,7 @@ async function loadBranchesButton() { var newContent = tempDiv.firstChild; contentView.innerHTML = ""; contentView.appendChild(newContent); - var token = getLocalToken(); - var userName = getLocalUserName(); - var url = "https://us-central1-github-tree-graph.cloudfunctions.net/prompt?userName=" + userName; - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, true); - xhr.onreadystatechange = function () { - if (xhr.readyState == 4) { - var resp = JSON.parse(xhr.responseText); - var showPrompt = resp.showPrompt; - console.log("showPrompt: " + showPrompt); - if (showPrompt) { - document.getElementById("promptImage").style.display = "inline-block"; - document.getElementById("promptImage").addEventListener("click", function () { - window.open("https://scaria.dev/redirection.html", "_blank"); - }); - } - } - } - xhr.send(); + }); return; } \ No newline at end of file diff --git a/js/showCommits.js b/js/showCommits.js index 20154fc..57f369d 100644 --- a/js/showCommits.js +++ b/js/showCommits.js @@ -242,7 +242,7 @@ async function showCommits(commits, branchNames, allCommits, heads, pageNo, allB // Like "1 day ago", "2 weeks ago", "3 months ago" function relativeTime(date) { var now = new Date().getTime(); - const difference = (now - date.getTime()) / 1000; + const difference = (now - (new Date(date)).getTime()) / 1000; let output = ``; if (difference < 10) { output = `just now`; @@ -255,7 +255,7 @@ function relativeTime(date) { } else if (difference < 2620800) { output = `${Math.floor(difference / 86400) > 1 ? (Math.floor(difference / 86400) + ' days ago') : 'yesterday'}`; } else { - output = 'on ' + date.toLocaleDateString(); + output = 'on ' + (new Date(date)).toLocaleDateString(); } return (output); } diff --git a/js/sortCommits.js b/js/sortCommits.js index 6f14854..82d318f 100644 --- a/js/sortCommits.js +++ b/js/sortCommits.js @@ -22,13 +22,13 @@ async function sortCommits(branches, heads, allBranches) { var branchname = branch.name; var thisCommits = branch.target.history.edges; for (var thisCommit in thisCommits) { - var commit = thisCommits[thisCommit].node; + var commit = JSON.parse(JSON.stringify(thisCommits[thisCommit].node)); if (commit.oid in commitsObject && commitsObject[commit.oid].branches != null) { commitsObject[commit.oid].branches.push(branchname); } else { commitsObject[commit.oid] = commit - commit.branches = [branchname]; + commit.branches = [branchname] commit.committedDate = parseDate(commit.committedDate); } } diff --git a/manifest.json b/manifest.json index 3c452c0..6498c6b 100644 --- a/manifest.json +++ b/manifest.json @@ -37,7 +37,7 @@ }, { "matches": [ - "*://*.scaria.dev/github-tree-graph/authorize/*" + "*://*.scaria.dev/github-tree-graph/authorize*" ], "js": [ "js/authProcess.js" @@ -67,7 +67,7 @@ "128": "/images/le_git_graph128.png" }, "background": { - "service_worker": "js/serviceWorker.js" + "scripts": ["js/serviceWorker.js"] }, "web_accessible_resources": [ {