mirror of
https://github.com/neosubhamoy/neosubhamoy-portfolio.git
synced 2025-12-20 01:09:35 +05:30
(refactor): made keybinding links fully dynamic
This commit is contained in:
@@ -3,6 +3,26 @@
|
|||||||
|
|
||||||
let pressedKeys = {};
|
let pressedKeys = {};
|
||||||
|
|
||||||
|
function getJsonDataset(element) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
$.getJSON('assets/dataset.json', function(datasetData) {
|
||||||
|
resolve(datasetData[element]);
|
||||||
|
}).fail(function(jqxhr, textStatus, error) {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function redirectToURL(item) {
|
||||||
|
try {
|
||||||
|
const url = await getJsonDataset(item);
|
||||||
|
window.open(url, '_blank');
|
||||||
|
location.reload();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('keydown', function(event) {
|
document.addEventListener('keydown', function(event) {
|
||||||
pressedKeys[event.key] = true;
|
pressedKeys[event.key] = true;
|
||||||
|
|
||||||
@@ -19,13 +39,13 @@ document.addEventListener('keydown', function(event) {
|
|||||||
window.location.href = basePath + "/contact";
|
window.location.href = basePath + "/contact";
|
||||||
}
|
}
|
||||||
else if (pressedKeys['q'] && pressedKeys['e']) {
|
else if (pressedKeys['q'] && pressedKeys['e']) {
|
||||||
window.location.href = "mailto:hey@neosubhamoy.com";
|
redirectToURL('email');
|
||||||
}
|
}
|
||||||
else if (pressedKeys['q'] && pressedKeys['m']) {
|
else if (pressedKeys['q'] && pressedKeys['m']) {
|
||||||
window.location.href = "#";
|
redirectToURL('chat');
|
||||||
}
|
}
|
||||||
else if (pressedKeys['q'] && pressedKeys['s']) {
|
else if (pressedKeys['q'] && pressedKeys['s']) {
|
||||||
window.location.href = "#";
|
redirectToURL('sources');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ function fetch_page_title($conn, $page_name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//function to fetch page title
|
//function to fetch quick actions link
|
||||||
function fetch_quick_action_link($conn, $action_name) {
|
function fetch_quick_action_link($conn, $action_name) {
|
||||||
$sql = "SELECT link FROM quick_actions WHERE name = '$action_name'";
|
$sql = "SELECT link FROM quick_actions WHERE name = '$action_name'";
|
||||||
$result = $conn -> query($sql);
|
$result = $conn -> query($sql);
|
||||||
|
|||||||
Reference in New Issue
Block a user