PageSourceSearch

https://ahepadistrict7.org/Site/javascript/pxgradient-1.0.1.jquery.js

js ahepadistrict7.org collected 2026-10-07 20:33:41 UTC 4,188 bytes, 117 lines download raw bytes

1/**
2 * @author Sergey Nikitin ([email protected])
3 * @link www.mrnix.ru
4 * @date 12.02.2011
5 * @requires jQuery
6 *
7 * Description:
8 * pxgradient is a jQuery plugin that paints text in gradient colors by pixel
9 * 
10 * Usage:
11 * $(selector).pxgradient(options);
12 * 
13 * options is an object contents configuraton paramenters:
14 * {Number} step - Step Color. The smaller the number, the greater the load. Default: 10
15 * {Array}  colors - array of hex colors. Default: ["#ffcc00", "#cc0000", "#000000"];
16 * {String} dir - gradient direction. "x" - horizontal,  "y" - vertical
17 */
18(function($){
19  jQuery.fn.pxgradient=function(options){
20    var options=jQuery.extend({
21      step:10,
22      colors:["#ffcc00","#cc0000","#000000"],
23      dir:"h"
24    },options);
25    options.RGBcolors=[];
26    for(var i=0;i<options.colors.length;i++){
27      options.RGBcolors[i]=hex2Rgb(options.colors[i]);
28    }  
29    return this.each(function(i,e){
30      pxg=jQuery(e);
31      if(!pxg.hasClass("sn-pxg")){    
32      pxg_source=pxg.html();
33       pxg.html('<span class="pxg-source">'+pxg_source+'</span>');
34      pxg.find(".pxg-source").css({
35          "visibility":"hidden"
36        });
37     pxg.append('<u class="pxg-set"></u>');
38        pxg_set=jQuery(".pxg-set",pxg);
39       
40        pxg_text = pxg.find(".pxg-source");
41        pxg_w=pxg_text.width() + new String(pxg_text).length * 4;
42        
43        pxg_h=pxg_text.height() + 10;   
44        pxg_text.hide();
45        pxg.addClass("sn-pxg");
46        if(options.dir=="x") {
47          blocksize=pxg_w;
48        }
49        else if(options.dir=="y") {
50          blocksize=pxg_h;
51        }
52        fullsteps=Math.floor(blocksize/options.step);
53        allsteps=fullsteps;
54        laststep=(blocksize-(fullsteps*options.step));
55        if(laststep>0){
56          allsteps++;
57        }
58        pxg_set.css({
59          width:pxg_w,
60          height:pxg_h
61        });
62        offleft=0;        
63        if(options.dir == "x"){
64          for(var i=0;i<allsteps;i++){
65            color=getColor(offleft,blocksize);
66            pxg_set.append('<s class="s" style="height:'+pxg_h+'px;width:'+options.step+'px;left:'+offleft+'px;color:'+color+'"><b class="b" style="left:-'+offleft+'px;width:'+pxg_w+'px;height:'+pxg_h+'px;">'+pxg_source+'</b></s>');
67            offleft=offleft+options.step;
68          }
69        }
70        else if(options.dir=="y"){
71          for(var i=0;i<allsteps;i++){
72            color=getColor(offleft,blocksize);
73            pxg_set.append('<s class="s" style="width:'+pxg_w+'px;height:'+options.step+'px;top:'+offleft+'px;color:'+color+'"><b class="b" style="top:-'+offleft+'px;height:'+pxg_w+'px;height:'+pxg_h+'px;">'+pxg_source+'</b></s>');
74            offleft=offleft+options.step;
75          }
76        }
77      }
78    });
79    function hex2Rgb(hex){
80      if('#'==hex.substr(0,1)){
81        hex=hex.substr(1);
82      }
83      if (3==hex.length){
84        hex=hex.substr(0,1)+hex.substr(0,1)+hex.substr(1,1)+hex.substr(1,1)+hex.substr(2,1)+hex.substr(2,1);
85      }
86      return [parseInt(hex.substr(0,2),16),parseInt(hex.substr(2,2),16),parseInt(hex.substr(4,2),16)];
87    }
88    function rgb2Hex(rgb){
89      var s = '0123456789abcdef';
90      return '#'+s.charAt(parseInt(rgb[0]/16))+s.charAt(rgb[0]%16)+s.charAt(parseInt(rgb[1]/16))+s.charAt(rgb[1]%16)+s.charAt(parseInt(rgb[2]/16))+s.charAt(rgb[2]%16);
91    }
92    function getColor(off,blocksize){
93      var fLeft=(off>0)?(off/blocksize):0;
94      for (var i=0;i<options.colors.length;i++){
95        fStopPosition=(i/(options.colors.length-1));
96        fLastPosition=(i>0)?((i-1)/(options.colors.length-1)):0;
97        
98        if(fLeft==fStopPosition){
99          return options.colors[i];
100        }
101        else if(fLeft<fStopPosition){
102          fCurrentStop=(fLeft-fLastPosition)/(fStopPosition-fLastPosition);
103          return getMidColor(options.RGBcolors[i-1],options.RGBcolors[i],fCurrentStop);
104        }
105      }
106      return options.colors[options.colors.length-1];
107    }
108    
109    function getMidColor(aStart,aEnd,fMidStop){
110      var aRGBColor=[];
111      for (var i=0;i<3;i++){
112        aRGBColor[i]=aStart[i]+Math.round((aEnd[i]-aStart[i])*fMidStop)
113      }
114      return rgb2Hex(aRGBColor)
115    }
116  }
117})(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.