PageSourceSearch

https://belairpartners.com/scripts/plugins/tx3TagCloud/jquery.tx3-tag-cloud.js

js belairpartners.com collected 2026-10-07 19:25:25 UTC 1,989 bytes, 70 lines download raw bytes

1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * Tuxes3 wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return Tuxes3
7 * ----------------------------------------------------------------------------
8 */
9(function($)
10{
11	var settings;
12    $.fn.tx3TagCloud = function(options)
13    {
14
15    	//
16    	// DEFAULT SETTINGS
17    	//
18    	settings = $.extend({
19    		multiplier		: 1
20    	}, options);
21    	main(this);
22
23    }
24
25    function main(element)
26    {
27    	// adding style attr
28    	element.addClass("tx3-tag-cloud");
29    	addListElementFontSize(element);
30    }
31
32    /**
33     * calculates the font size on each li element 
34     * according to their data-weight attribut
35     */
36    function addListElementFontSize(element)
37    {
38    	var hDataWeight = -9007199254740992;
39    	var lDataWeight = 9007199254740992;
40    	$.each(element.find("li"), function(){
41    		cDataWeight = getDataWeight(this);
42    		if (cDataWeight == undefined)
43    		{
44    			logWarning("No \"data-weight\" attribut defined on <li> element");
45    		}
46    		else
47    		{
48    			hDataWeight = cDataWeight > hDataWeight ? cDataWeight : hDataWeight;
49    			lDataWeight = cDataWeight < lDataWeight ? cDataWeight : lDataWeight;
50    		}
51    	});
52    	$.each(element.find("li"), function(){
53    		var dataWeight = getDataWeight(this);
54    		var percent = Math.abs((dataWeight - lDataWeight)/(lDataWeight - hDataWeight));
55    		$(this).css('font-size', (1 + (percent * settings['multiplier'])) + "em");
56    	});
57
58    }
59
60    function getDataWeight(element)
61    {
62    	return parseInt($(element).attr("data-weight"));
63    }
64
65    function logWarning(message)
66    {
67    	console.log("[WARNING] " + Date.now() + " : " + message);
68    }
69
70}(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.