This file contains hidden or 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
| //assume variables currentIndex, nextIndex, arrayLength exist | |
| //moving "forward", positive incrementing | |
| nextIndex = (currentIndex + 1) % arrayLength; | |
| //moving "backward", negative incrementing | |
| if(currentIndex == 0){ | |
| nextIndex = arrayLength - 1; | |
| } else { | |
| nextIndex = (currentIndex - 1) % arrayLength; |
This file contains hidden or 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
| var alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; | |
| var rot13 = function(letter){ | |
| var l = letter.toLowerCase(); | |
| var index = alphabet.indexOf(l); | |
| var newIndex = (index + 13) % alphabet.length; | |
| return alphabet[newIndex]; |
This file contains hidden or 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
| var screenWidth = window.innerWidth; | |
| var visibleElements = jQuery(":visible"); | |
| visibleElements.each(function(){ | |
| var $this = jQuery(this); | |
| if($this.width() > screenWidth){ | |
| $this.css("border", "1px solid green"); | |
| console.log("Screen width is " + screenWidth + " and the following element is " + $this.width(), $this); | |
| } | |
| }); |
This file contains hidden or 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
| /** | |
| * Logs JavaScript errors via an AJAX request. | |
| * Written in pure JavaScript so it does not have any dependencies. | |
| */ | |
| window.onerror = function(errorMessage, url, lineNumber){ | |
| var ajaxUrl = "/log-js-errors?t=" + (new Date()).getTime(); | |
| var data = { | |
| errorMessage: errorMessage, |
This file contains hidden or 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
| javascript:(function(){window.location=window.location.href.replace(window.location.host,(window.location.host+'.libproxy.lib.unc.edu'));})() |
This file contains hidden or 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
| function checkCompatibilityMode(){ | |
| var userAgentRegex = /MSIE ([0-9.]+)/; | |
| var userAgentData = userAgentRegex.exec(navigator.userAgent); | |
| if(userAgentData != null && typeof userAgentData[1] == "string"){ | |
| //userAgentData[1] will hold the version number, e.g. "10.0" | |
| if(parseInt(userAgentData[1], 10) != document.documentMode){ | |
| $('body').append('<div class="warning">Your browser appears to be in Compatibility Mode. This may cause problems when printing. <a href="http://www.howtogeek.com/128289/how-to-disable-compatibility-mode-in-internet-explorer/" target="_blank">Read how to turn off Compatibility Mode</a>.</div>'); | |
| } |
This file contains hidden or 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
| (function(){ | |
| //remove the "Edit" button | |
| var editLink = document.getElementsByClassName('ss-edit-link'); | |
| if(editLink.length){ | |
| editLink[0].remove(); | |
| } | |
| //remove the "Google" copyright footer | |
| var copyright = document.getElementsByClassName('ss-footer'); | |
| if(copyright.length){ |
This file contains hidden or 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
| var iframeObjects=$('iframe[title="Recent Announcements "], iframe[title="Announcements "]').contents().find('object');iframeObjects.each(function(){var flashVarsArray=$(this).find('param[name="FlashVars"]').val().split('=');var url=flashVarsArray[1];var url=url.split('&')[0];$(this).after('<div><a href="'+url+'">Link to Download Video</a></div>');}); |
This file contains hidden or 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
| /** | |
| * A class for turning timestamps into more user-friendly relative dates. | |
| * | |
| $date = new Relative_Date(); | |
| echo $date->relative_formatted_date; //"Today" | |
| */ | |
| class Relative_Date { | |
| const DAY = 86400; |
This file contains hidden or 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
| def prevent_widows(text) | |
| if text.kind_of? String | |
| trimmed_text = text.rstrip | |
| last_space_index = trimmed_text.rindex(" ") | |
| if !last_space_index.nil? | |
| text[last_space_index] = " " | |
| end | |
| end |
OlderNewer