From d66ed7f39b2a3e3439e6a12377c62795e940d216 Mon Sep 17 00:00:00 2001 From: Jinoytommanjaly Date: Mon, 8 Apr 2024 01:39:54 +0530 Subject: [PATCH] Update index.html added condition for ns --- index.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index f17834d..c7ebc4d 100644 --- a/index.html +++ b/index.html @@ -210,7 +210,7 @@

Global Wiki Contributions

// Function to fetch edit counts from XTools API async function fetchEditCounts(wikiUrl, username, namespace, startDate, endDate) { - const apiUrl = `https://xtools.wmcloud.org/api/user/simple_editcount/${wikiUrl}/${username}/${namespace}/${startDate}/${endDate}`; + const apiUrl = `https://xtools.wmcloud.org/api/user/simple_editcount/${wikiUrl}/${username}/${getNamespaceParam(namespace)}/${startDate}/${endDate}`; totalApiRequests++; try { const response = await fetch(apiUrl); @@ -253,10 +253,10 @@

Global Wiki Contributions

// Function to get namespace parameter function getNamespaceParam(namespace) { - if (namespace === '0') { - return ''; + if (namespace === 'all' || namespace === null) { + return 'all'; } else { - return `&namespace=${namespace}`; + return `${namespace}`; } } @@ -394,12 +394,17 @@

Global Wiki Contributions

const startDateFromURL = urlParams.get('startDate'); const endDateFromURL = urlParams.get('endDate'); - if (usernameFromURL && namespaceFromURL && startDateFromURL && endDateFromURL) { + if (usernameFromURL && startDateFromURL && endDateFromURL) { // Fill the form fields with values from the URL document.getElementById('username').value = usernameFromURL; - document.getElementById('namespace').value = namespaceFromURL; document.getElementById('startDate').value = startDateFromURL; document.getElementById('endDate').value = endDateFromURL; + + if (namespaceFromURL) { + document.getElementById('namespace').value = namespaceFromURL; + } else { + document.getElementById('namespace').value = 'all'; // Default to All + } // Trigger the function to fetch user contributions displayUserEditCounts(usernameFromURL, namespaceFromURL, startDateFromURL, endDateFromURL);