Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaulislam committed Apr 27, 2023
1 parent fe018e1 commit d5a558e
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 134 deletions.
9 changes: 7 additions & 2 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import tailwind from "@astrojs/tailwind";

// https://astro.build/config
export default defineConfig({
site: 'https://astro-modern-personal-website.netlify.app',
integrations: [mdx(), sitemap(), tailwind()]
site: 'https://jiaulislam.github.io/',
integrations: [mdx(), sitemap(), tailwind()],
"plugins": [
{
"name": "@astrojs/ts-plugin"
},
],
});
29 changes: 20 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Astro Modern Personal Website",
"name": "Jiaul Islam Modern Personal Website",
"description": "Astro Modern personal website template with Project Section, CV Section, Paginated Blog, Shop, RSS Feed, SEO Friendly, Visual themes and Responsive Desing.",
"type": "module",
"version": "2.2.0",
Expand All @@ -16,6 +16,7 @@
"@astrojs/rss": "^1.0.1",
"@astrojs/sitemap": "^1.0.0",
"@astrojs/tailwind": "^3.0.0",
"@astrojs/ts-plugin": "^0.4.4",
"astro": "^2.0.0",
"daisyui": "^2.27.0",
"dayjs": "^1.11.7",
Expand Down
124 changes: 120 additions & 4 deletions src/pages/bmc.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import BaseLayout from "../layouts/BaseLayout.astro";
---

<BaseLayout title = "BMC Remedy Tools">
Expand Down Expand Up @@ -34,9 +33,126 @@ import BaseLayout from "../layouts/BaseLayout.astro";
Copy
</button>
</div>
</div>
</div>

</BaseLayout>

<script type="module">
import "/src/services/bmc.ts";;
<script>
// COMMA SEPERATED SITE CODE GENERATOR SECTION
const sitecodes = document.getElementById('box1') as HTMLInputElement;
const genButton = document.getElementById("submit") as HTMLButtonElement;
const queryBox = document.getElementById("query-output") as HTMLTextAreaElement;
const impactBox = document.getElementById("format-output") as HTMLTextAreaElement;
const clrButton = document.getElementById("clear-btn") as HTMLButtonElement;
const commaSites = document.getElementById("comma-sites") as HTMLInputElement;
const box: HTMLCollectionOf<Element> = document.getElementsByClassName("container");
const copyBtn1 = document.querySelector("#copy-btn-1") as HTMLButtonElement;
const copyBtn2 = document.querySelector("#copy-btn-2") as HTMLButtonElement;


const REGEX = /([A-Z])\w+/gm;


function generateQueryString(siteArray: string[]): string {
let queryList: string[] = [];
for(let i = 0; i < siteArray.length; i++){
if(siteArray[i].length == 7){
queryList.push("'Name'LIKE\"%" + siteArray[i] + "\"");
}
}
return queryList.join("OR");
}

function generateCommaSeperatedString(siteArray: string[]) : string{
return siteArray.join(",");
}

function clear() {
sitecodes.value = "";
queryBox.value = "";
impactBox.value = "";

if (!isBlank()) {
clrButton.disabled = false;
}
}

function isBlank(): boolean {
if (sitecodes.value != "" || ( queryBox.value == "" || impactBox.value == "")) {
return true;
}
return false;
}

genButton.addEventListener("click", (event) => {
// wait for the click event from user to generate the string
if (sitecodes.value) {
let parseSites = sitecodes.value.match(REGEX)!;

// set the value with formattedstring in the output textarea
impactBox.value = generateCommaSeperatedString(parseSites);
// generate the relationship query string
queryBox.value = generateQueryString(parseSites);
if (isBlank()) {
clrButton.disabled = false;
}
}
event.preventDefault();
});

clrButton.addEventListener('click', function(){
// Clear the text box's
clear();
// set the clear button disabled
if (isBlank()){
clrButton.disabled = true;
genButton.disabled = true;
}
})


// Impact List Copy Event
copyBtn1.addEventListener("click", async (event) => {
try {
await navigator.clipboard.writeText(impactBox.value);
console.log("Text copied to clipboard");
} catch (err) {
console.error("Failed to copy text: ", err);
}
event.preventDefault();
});

// Query List Copy Event
copyBtn2.addEventListener("click", async (event) => {
try {
await navigator.clipboard.writeText(queryBox.value);
console.log("Text copied to clipboard");
} catch (err) {
console.error("Failed to copy text: ", err);
}
event.preventDefault();
});


document.addEventListener('DOMContentLoaded', () => {
sitecodes.focus();
sitecodes.select();
clrButton.disabled=true;
if (sitecodes.value) {
genButton.disabled = false;
}
else{
genButton.disabled = true;
}
})

sitecodes.addEventListener('input', () => {
if (sitecodes.value){
genButton.disabled = false;
clrButton.disabled=false;
}else{
clrButton.disabled = true;
genButton.disabled = true;
}
})
</script>
117 changes: 0 additions & 117 deletions src/services/bmc.ts

This file was deleted.

5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"extends": "astro/tsconfigs/base",
"compilerOptions": {
"strictNullChecks": true
}
},
"include": [
"src/**/*.ts"
]
}

0 comments on commit d5a558e

Please sign in to comment.