Created
July 21, 2014 13:47
-
-
Save ezrabrook/a262b71f678c1f22a362 to your computer and use it in GitHub Desktop.
Add icon to pdf, doc or any other file extension based on extension type.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add PDF/Doc icons to Documents. */ | |
String.prototype.endsWith = function (suffix) { | |
return this.indexOf(suffix, this.length - suffix.length) !== -1; | |
}; | |
$('.sub_content_area .sub_right a').each(function () { | |
if ($(this).attr("href")) { | |
var href = $(this).attr("href"); | |
if (href.endsWith("xlsx") || href.endsWith("xls")) { | |
$(this).append(' <img width="88" height="28" class="excel-icon" src="/sites/all/themes/hdfsresponsive/css/images/download_excel.png" />'); | |
} | |
if (href.endsWith("pptx") || href.endsWith("ppt")) { | |
$(this).append(' <img width="88" height="28" class="ppt-icon" src="/sites/all/themes/hdfsresponsive/css/images/download_ppt.png" />'); | |
} | |
if (href.endsWith("docx") || href.endsWith("doc")) { | |
$(this).append(' <img width="88" height="28" class="doc-icon" src="/sites/all/themes/hdfsresponsive/css/images/download_word.png" />'); | |
} | |
if (href.endsWith("pdf")) { | |
$(this).append(' <img width="88" height="28" class="pdf-icon" src="/sites/all/themes/hdfsresponsive/css/images/download_pdf.png" />'); | |
} | |
if (href.endsWith("txt")) { | |
$(this).addClass('txt'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment