1/* 2 * Copyright (c) 2014 Mike King (@micjamking) 3 * 4 * jQuery Succinct plugin 5 * Version 1.1.0 (October 2014) 6 * 7 * Licensed under the MIT License 8 */ 9 10 /*global jQuery*/ 11(function($) { 12 'use strict'; 13 14 $.fn.succinct = function(options) { 15 16 var settings = $.extend({ 17 size: 240, 18 omission: '...', 19 ignore: true 20 }, options); 21 22 return this.each(function() { 23 24 var textDefault, 25 textTruncated, 26 elements = $(this), 27 regex = /[!-\/:-@\[-`{-~]$/, 28 init = function() { 29 elements.each(function() { 30 textDefault = $(this).html(); 31 32 if (textDefault.length > settings.size) { 33 textTruncated = $.trim(textDefault) 34 .substring(0, settings.size) 35 .split(' ') 36 .slice(0, -1) 37 .join(' '); 38 39 if (settings.ignore) { 40 textTruncated = textTruncated.replace(regex, ''); 41 } 42 43 $(this).html(textTruncated + settings.omission); 44 } 45 }); 46 }; 47 init(); 48 }); 49 }; 50})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.