As the industry evolves to develop purpose-built solutions for growing data storage requirements, IT managers continue to rely on lower capacity drives that are economical to acquire, yet deliver quick and reliable data access for traditional data center applications. Designed to handle workloads up to 550TB per year, Ultrastar DC HC320 is an 8TB HDD that helps address economic and access requirements of many traditional IT workloads. Lower capacity drives also help address architecture limitations. The Ultrastar DC HC320 is designed for traditional storage and server applications as well as distributed and scalable computing, including block and file storage architectures, providing fast 7200 RPM performance and lower acquisition cost to help ease budget constraints.
`;
}
// Update the unread count if it exists in the response
updateUnreadCount(count || 0, allCount || 0);
// Append the generated notifications HTML to the list
notificationList.append(noti);
markNotificationsAsSeen();
},
error: function() {
console.log('Failed to load notifications.');
}
});
}
// Function to update the unread message count
function updateUnreadCount(count, allCount) {
if (allCount == 0) {
$('.unread-text').addClass('d-none');
}
if (count > 0) {
$('#notificationCount').text(count);
$('#notificationCountIn').text(count); // Update the unread count display
} else {
$('#notificationCount').addClass('d-none');
$('#notificationCountIn').text(count);
}
}
// Function to format date from the notification object
function formatDate(date) {
const options = {
year: 'numeric',
month: 'short',
day: 'numeric'
};
return new Date(date).toLocaleDateString('en-US', options);
}
$(document).on('click', '#read_all_btn', function(e) {
markNotificationsAsClear();
});
// Function to mark notifications as seen
function markNotificationsAsClear() {
$.ajax({
url: '/notifications/mark-as-clear',
method: 'POST',
data: {
_token: $('meta[name="csrf-token"]').attr('content')
},
success: function(response) {
// Clear the notification list
$('#notificationListNew').empty().append(`
No New Notification
`);
updateUnreadCount(0, 0); // Set unread count to 0
// console.log(response.message);
},
error: function() {
console.log('Failed to mark notifications as read. Please try again.');
}
});
}
$(document).on('click', '#notificationBell', function(e) {
loadNotifications();
});
$(document).on('click', '#notificationBellNew', function(e) {
loadNotifications();
});
function markNotificationsAsSeen() {
$.ajax({
url: '/notifications/mark-as-seen',
method: 'POST',
data: {
_token: $('meta[name="csrf-token"]').attr('content')
},
success: function(response) {
$('#notificationCount').addClass('d-none');
},
error: function() {
console.log('Failed to mark notifications as read. Please try again.');
}
});
}
$(document).on('click', '#remove_single_notification', function(e) {
markNotificationsAsClear();
});
function getNotificationCount() {
if(session !== null){
$.ajax({
url: '/notifications/get-count',
method: 'GET',
success: function(response) {
if (response.status && response.count > 0) {
$('#notificationCount').removeClass('d-none');
$('#notificationCount').text(response.count);
}
},
error: function() {
console.log('Failed to mark notifications as read. Please try again.');
}
});
}
}
$(document).on('click', '#close-single-notification', function() {
// Get the notification div
const notificationDiv = $(this).closest('.notification_list');
const notificationId = notificationDiv.data('id');
$.ajax({
url: '/notification/delete-notification',
method: 'POST',
data: {
id: notificationId,
_token: $('meta[name="csrf-token"]').attr('content')
},
success: function(response) {
if (response.success) {
notificationDiv.animate({
marginLeft: '100%',
opacity: 0
}, 500, function() {
$(this).remove();
});
} else {
// console.log('Could not delete the notification.');
}
},
error: function() {
// console.log('An error occurred while deleting the notification.');
}
});
});
let debounceTimer; // Declare a variable to store the timer
function debounceSearch(isUpdateValue = 1) {
clearTimeout(debounceTimer); // Clear the previous timer if still running
if (isUpdateValue) {
const searchValue = document.getElementById('headerSearchInput').value;
// const inputField = document.getElementById('headerSearchInput');
// if (searchValue !== inputField.value) {
// inputField.value = searchValue;
// }
}
// Set a new timer to wait for 300 milliseconds (or any other desired delay)
debounceTimer = setTimeout(function() {
getUniversalSearchData(); // Call the actual search function after delay
}, 800); // Delay in milliseconds
}
function checkEnter(event) {
// Check if the "Enter" key was pressed
const inputField = document.getElementById('headerSearchInput');
const searchValue = document.getElementById('headerSearchInput').value;
const baseUrl = "https://www.fuse.systems/search";
let url = new URL(window.location.href);
let params = new URLSearchParams(url.search);
// Set or update the "value" parameter
params.set('value', searchValue);
if (searchValue.length <= 0 && event.key === "Enter") {
window.location.href = "https://www.fuse.systems/all-products";
}
// Check if we are already on the product search page
var isProductSearchPage = "false";
if (isProductSearchPage === "true") {
// Update the URL without reloading the page
window.history.replaceState({}, '', `${url.pathname}?${params.toString()}`);
applyFilters(); // Call the filter function
} else {
// Redirect to search page with the updated query
window.location.href = baseUrl + '?' + params.toString();
inputField.value = searchValue;
}
}
// Ensure search input retains value after page reload
document.addEventListener("DOMContentLoaded", function() {
const inputField = document.getElementById('headerSearchInput');
let params = new URLSearchParams(window.location.search);
let searchValue = params.get('value');
if (searchValue) {
inputField.value = searchValue;
}
});
// Show loader function
function showLoader() {
$('#searchLoader').removeClass('d-none');
$('#universalSearchInput').attr('disabled');
}
// Hide loader function
function hideLoader() {
$('#searchLoader').addClass('d-none');
$('#universalSearchInput').removeAttr('disabled');
}
let isRequestInProgress = false;
let currentController = null; // Variable to hold the current AbortController
// Declare the main function as async to use await inside it
async function getUniversalSearchData() {
// Cancel the previous request if it's in progress
if (isRequestInProgress) {
currentController.abort(); // Abort the previous request
}
// Create a new AbortController for the new request
currentController = new AbortController();
const signal = currentController.signal;
isRequestInProgress = true;
const searchValue = $('#universalSearchInput').val();
if (searchValue === "" || searchValue.length < 3) {
$('#searchResultList').addClass('d-none');
isRequestInProgress = false; // Reset the request status
return;
}
showLoader();
saveRecentSearch(searchValue);
// Remove 'd-none' to show the search results
$('#searchResultList').removeClass('d-none');
try {
let response = await $.ajax({
url: '/get-search-data',
type: 'GET',
data: {
search: searchValue,
},
signal: signal // Attach the abort signal to the request
});
// Proceed with processing the response if the request was not aborted
if (isRequestInProgress) {
hideLoader();
isRequestInProgress = false;
const products = response.searchResult.products;
const accessories = response.searchResult.accessories;
const license = response.searchResult.license;
const orders = response.orders;
const invoices = response.invoices;
const quotes = response.quotes;
const subscription = response.subscription;
if (response.searchCount > 10) {
$('#viewMoreSearchBtn').removeClass('d-none');
const viewMore = document.getElementById('viewMoreSearchUrl');
// Generate the URL with the search input value as a query parameter
const baseUrl = "https://www.fuse.systems/search";
const searchParam = searchValue ? `?value=${encodeURIComponent(searchValue)}` : '';
// Update the href attribute of the View More button
viewMore.href = baseUrl + searchParam;
} else {
$('#viewMoreSearchBtn').addClass('d-none');
}
// Clear previous search results
$('#product_search_list').empty();
$('#accessories_search_list').empty();
$('#license_search_list').empty();
$('#order_search_list').empty();
$('#invoice_search_list').empty();
$('#subscription_search_list').empty();
$('#quote_search_list').empty();
$('#category_list').empty();
$('#searhNoData').empty();
$('#product_list_searched').addClass('d-none');
$('#order_list_searched').addClass('d-none');
$('#invoice_list_searched').addClass('d-none');
$('#subscription_list_searched').addClass('d-none');
$('#quote_list_searched').addClass('d-none');
$('#category_listing').addClass('d-none');
// Check if products are available
if (products && Object.keys(products).length > 0) {
$('#product_list_searched').removeClass('d-none');
// const SKU = "2000211";
// const Picture = "2000222";
// const Title = "2000213";
// const Description = "1002991";
// const productDetailBaseUrl = "https://www.fuse.systems/product/detail/:sku?id=%3Aid";
// const Status = "1002681";
// const Category = "2000215";
const SKU = "sku";
const Picture = "picture";
const Title = "title";
const Description = "description";
const productDetailBaseUrl = "https://www.fuse.systems/product/detail/:sku";
const Status = "status";
const Category = "category";
for (const [key, element] of Object.entries(products)) {
if (element[Status] == 0 && element[Status] != "") {
hideLoader();
isRequestInProgress = false;
continue;
}
const productDetailUrl = productDetailBaseUrl
.replace(':id', element.objectID)
.replace(':sku', element[SKU].replace('/', ''));
let imgurl = null;
if (Array.isArray(element[Picture])) {
// Filter out empty values
const filteredImages = element[Picture].filter(image => image.trim() !== '');
var img = filteredImages.length > 0 ? filteredImages[0] : null;
imgurl = img ? encodeURIComponent(img) : null;
} else {
const img = element[Picture];
imgurl = img ? encodeURIComponent(img) : null;
}
// Set a default image
let productImg = ``;
if (imgurl) {
// Construct local and fallback image URLs
const imageUrl = `https://www.fuse.systems/uploads/products/${imgurl}`;
const fallbackUrl = `https://db.yotltd.com/sims/file.jsp?a=default&f=${imgurl}`;
// Attempt to load the local image without blocking the main thread
const imgElement = new Image();
imgElement.src = imageUrl;
imgElement.onload = function() {
// If the local image loads successfully, update the image
productImg = ``;
// Update the DOM element dynamically
document.querySelector(`#search-${element.objectID} .search_list_image img`).src = imageUrl;
};
imgElement.onerror = function() {
// If the local image fails to load, use the fallback URL
productImg = ``;
// Update the DOM element dynamically
document.querySelector(`#search-${element.objectID} .search_list_image img`).src = fallbackUrl;
};
}
// Construct the result item
const tableRow = `
// `;
// Append the product row to the search data
// $('#category_list').append(categoryList);
}
// Check if orders are available
if (orders && Object.keys(orders).length > 0) {
$('#order_list_searched').removeClass('d-none');
// const status1 = "";
const PINumber = "1001874";
const CreationTime = "1002788";
// Use Object.entries to iterate over the products object
for (const [key, element] of Object.entries(orders)) {
const orderDetailUrl = "https://www.fuse.systems/orders?id=" + encodeURIComponent(element[PINumber]);
// Construct the result item
const tableRow = `
// `;
// Append the product row to the search data
// $('#category_list').append(categoryList);
}
// Check if invoices are available
if (invoices && Object.keys(invoices).length > 0) {
$('#invoice_list_searched').removeClass('d-none');
const InvoiceNumber = "1001971";
const Total = "1001974";
const Date = "1001970";
// Use Object.entries to iterate over the products object
for (const [key, element] of Object.entries(invoices)) {
const invoiceDetailUrl = "https://www.fuse.systems/invoices?id=" + encodeURIComponent(element[InvoiceNumber]);
// Construct the result item
const tableRow = `
// `;
// Append the product row to the search data
// $('#category_list').append(categoryList);
}
// Check if invoices are available
if (quotes && Object.keys(quotes).length > 0) {
$('#quote_list_searched').removeClass('d-none');
const QuoteId = "2000226";
const QuoteDate = "2000228";
const GrandTotal = "2000245";
// Use Object.entries to iterate over the products object
for (const [key, element] of Object.entries(quotes)) {
const quoteDetailUrl = "https://www.fuse.systems/quotes?id=" + encodeURIComponent(element[QuoteId]);
// Construct the result item
const tableRow = `
`;
// Append the product row to the search data
$('#quote_search_list').append(tableRow);
}
// $('#category_listing').removeClass('d-none');
// const categoryList = `
//
// `;
// Append the product row to the search data
// $('#category_list').append(categoryList);
}
// Check if invoices are available
if (subscription && Object.keys(subscription).length > 0) {
$('#subscription_list_searched').removeClass('d-none');
const SubscriptionID = "1002696";
const NextRenewal = "1001909";
const Total = "1001923";
// Use Object.entries to iterate over the products object
for (const [key, element] of Object.entries(subscription)) {
const subscriptionDetailUrl = "https://www.fuse.systems/subscriptions?id=" + encodeURIComponent(element[SubscriptionID]);
// Construct the result item
const tableRow = `
`;
// Append the product row to the search data
$('#subscription_search_list').append(tableRow);
}
// $('#category_listing').removeClass('d-none');
// const categoryList = `
//
// `;
// Append the product row to the search data
// $('#category_list').append(categoryList);
}
if (products == "" && accessories == "" && license == "" && orders == "" && invoices == "" && quotes == "" && subscription == "") {
// No products found case
const tableRow = `
No Result Found!
`;
$('#searhNoData').append(tableRow);
$('#searchResultList').removeClass('d-none');
}
hideLoader();
}
} catch (err) {
// Handle request cancellation or other errors
if (err.name === 'AbortError') {
console.log('Previous request was aborted.');
} else {
console.error('Error fetching search data:', err);
}
hideLoader();
isRequestInProgress = false;
}
}
$(document).click(function(event) {
var targetDiv = $('#search-container');
var hideDiv = $('#searchResultList');
// Check if the clicked element is outside the div
if (!$(event.target).closest(targetDiv).length) {
hideDiv.addClass('d-none'); // Add class if clicked outside
}
});
function saveRecentSearch(searchTerm) {
// Get existing recent searches from localStorage or create an empty array
let recentSearches = JSON.parse(localStorage.getItem('recentSearches')) || [];
// Add the search term if it doesn't already exist
if (!recentSearches.includes(searchTerm)) {
recentSearches.unshift(searchTerm); // Add to the start of the array
// if (recentSearches.length > 5) {
// recentSearches.pop(); // Keep only the last 5 searches
// }
}
// Save back to localStorage
localStorage.setItem('recentSearches', JSON.stringify(recentSearches));
// Display the recent searches
displayRecentSearches();
}
// Flag to track if full search list is displayed or only first 3
let isShowingAll = false;
// Function to retrieve and display recent searches
function displayRecentSearches() {
let recentSearches = JSON.parse(localStorage.getItem('recentSearches')) || [];
let recentSearchList = document.getElementById('recentSearchList');
// Clear the existing recent searches
recentSearchList.innerHTML = '';
// If no recent searches are available, show a message
if (recentSearches.length === 0) {
recentSearchList.innerHTML = '
No recent searches
';
return;
}
// Show only 3 searches by default, or all if "See More" was clicked
const searchesToDisplay = isShowingAll ? recentSearches : recentSearches.slice(0, 3);
// Loop through and display the recent searches
searchesToDisplay.forEach(search => {
let searchItem = `
`;
recentSearchList.innerHTML += searchItem;
});
// Show/Hide the "See More" button if there are more than 3 searches
let toggleBtn = document.getElementById('toggleRecentSearches');
if (recentSearches.length > 3) {
toggleBtn.style.display = 'block';
toggleBtn.innerText = isShowingAll ? 'See Less' : 'See More';
} else {
toggleBtn.style.display = 'none';
}
}
// Toggle between showing only 3 searches or all
function toggleRecentSearches() {
isShowingAll = !isShowingAll; // Toggle the flag
displayRecentSearches(); // Re-render the search list
}
// Handle when a user clicks on a recent search
function handleSearchClick(searchTerm) {
document.getElementById('universalSearchInput').value = searchTerm;
getUniversalSearchData(); // Trigger search with the selected term
}
// Function to clear recent searches
document.getElementById('clearRecentSearches').addEventListener('click', function() {
localStorage.removeItem('recentSearches');
displayRecentSearches();
});
// Call this function whenever a new search is performed
function handleSearch(searchTerm) {
saveRecentSearch(searchTerm);
getUniversalSearchData();
}
// Global Variable to avoid multiple api calls
let isTrackingApiCallInProgress = false;
function trackShipment(trackNo = "") {
if (isTrackingApiCallInProgress) {
return;
}
let trackingNumber = document.getElementById('trackingUrlInput').value;
if (trackingNumber == "") {
trackingNumber = trackNo;
}
if (trackingNumber.length == 0) {
$('#activitySectionAll').empty().append('