Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$items.each((index, item) => {
const $item = $(item);
const name = $item.parent().contents().get(1).data;
const hasIcon = $item.find('.gfi').length > 0;
if (!hasIcon) {
let className;
if (isColor) {
className = fileIcons.getClassWithColor(name) || DEFAULT_ICON;
} else {
className = fileIcons.getClass(name) || DEFAULT_ICON;
}
const $icon = $(`<span class="gfi ${className}"></span>`);
$item.append($icon);
// Bind on click for downloading the file
$icon.on('click', () => {
$item.click();
});
}
});
});
getFileIconForURI(uri: URI): string {
const iconClass = fileIcons.getClass(uri.path.toString()) || 'fa fa-file';
return iconClass + " file-icon";
}
for (let i = 0; i < filenameDomsLength; i += 1) {
const filename =
isGitHub && isMobile
? getGitHubMobileFilename(filenameDoms[i])
: filenameDoms[i].innerText.trim();
const iconDom = isGitHub
? iconDoms[i].querySelector('.octicon')
: iconDoms[i];
const isDirectory =
iconDom.classList.contains('octicon-file-directory') ||
iconDom.classList.contains('fa-folder');
const className = colorsDisabled
? fileIcons.getClass(filename)
: fileIcons.getClassWithColor(filename);
const darkClassName = darkMode ? 'dark' : '';
if (className && !isDirectory) {
const icon = document.createElement('span');
if (isGitHub) {
icon.className = `icon octicon ${className} ${darkClassName}`;
icon.style.opacity = 1;
} else {
icon.className = `${className} ${darkClassName}`;
icon.style.marginRight = host === 'bitbucket' ? '10px' : '3px';
}
iconDom.parentNode.replaceChild(icon, iconDom);
$items.each((index, item) => {
const $item = $(item);
const isFile = $item.find('.octicon-file').length > 0
const isSvg = $item.find('.octicon-file-text').length > 0;
const name = $item.find('.js-navigation-open').text();
const $icon = $item.find('.icon');
if (isFile || isSvg) {
let className;
if (isColor) {
className = fileIcons.getClassWithColor(name) || DEFAULT_ICON;
} else {
className = fileIcons.getClass(name) || DEFAULT_ICON;
}
$icon.addClass(`gfi ${className}`);
if (isSvg) {
$item.find('svg').remove()
}
}
});
});