PageSourceSearch

https://www.literalsystems.org/abooks/pub/skins/triad2/fontsizer.js

js literalsystems.org collected 2026-10-02 07:48:03 UTC 4,216 bytes, 94 lines download raw bytes

1// part of code by Chris Kaminski www.setmajer.com/demo/fontsizewidget.html
2// heavily adapted for php integration by Hans Bracker.
3// The sizer buttons are loaded via markup (:fontsizer:)
4// variables 'increment' and 'fontSizeDefault' are set in fontsizer.php
5
6function Fontsize(increment,def) {
7    this.w3c = (document.getElementById);
8    this.ms = (document.all);
9    this.userAgent = navigator.userAgent.toLowerCase();
10    this.isOldOp = ((this.userAgent.indexOf('opera') != -1)&&(parseFloat(this.userAgent.substr(this.userAgent.indexOf('opera')+5)) <= 7));
11    // this.isMacIE = ((this.userAgent.indexOf('msie') != -1) && (this.userAgent.indexOf('mac') != -1) && (this.userAgent.indexOf('opera') == -1));
12    if ((this.w3c || this.ms) && !this.isOldOp && !this.isMacIE) {
13        this.name = "fontSize";
14  //     this.cookiePrefix = cookiePrefix;
15  //     this.cookieName = cookiePrefix+'setfontsize';
16        this.cookieName = cookieName;
17        this.cookieExpires = '30';
18        this.cookiePath = '/';
19        this.increment = increment;
20        this.def = def;
21        this.defPx = Math.round(16*(def/100))
22        this.base = 1;
23        this.pref = this.getPref();
24        this.testHTML = '<div id="fontSizeTest" style="position:absolute;visibility:hidden;line-height:1em;">&nbsp;</div>';
25    } else {
26        this.fontSizeInit = new Function('return true;');
27    }
28        this.allLinks = this.getLinkHtml();
29}
30
31// check the user's current base text size and adjust as necessary
32Fontsize.prototype.fontSizeInit = function() {
33        document.writeln(this.testHTML);
34        this.body = (this.w3c)?document.getElementsByTagName('body')[0].style:document.all.tags('body')[0].style;
35        this.fontSizeTest = (this.w3c)?document.getElementById('fontSizeTest'):document.all['fontSizeTest'];
36        var h = (this.fontSizeTest.clientHeight)?parseInt(this.fontSizeTest.clientHeight):(this.fontSizeTest.offsetHeight)?parseInt(this.fontSizeTest.offsetHeight):999;
37        if (h < this.defPx) this.base = this.defPx/h;
38        this.body.fontSize = Math.round(this.pref*this.base) + '%';
39        fsinit = 1;
40}
41
42Fontsize.prototype.getLinkHtml = function() {
43        var html ='<span id="fsbox" class="fsbox"><span class="fslinklabel">'+fsLabel+'</span>';
44        html +='<a href="#" onclick="fontSize.setSize(-1); return false;" return false;" ';
45        html +=' title="'+fsSmaller+'" class="fontsizer" >&ndash;</a>';
46        html +='<a href="#" onclick="fontSize.setSize(0); return false;" return false;" ';
47        html +=' title="'+fsNormal+'" class="fontsizer" >0</a>';
48        html +='<a href="#" onclick="fontSize.setSize(1); return false;" return false;" ';
49        return html +=' title="'+fsBigger+'" class="fontsizer" >+</a></span>';    
50}
51
52Fontsize.prototype.getPref = function() {
53    var pref = this.getCookie(this.cookieName);
54    if (pref) return parseInt(pref);
55    else return this.def;
56}
57
58Fontsize.prototype.setSize = function(direction) {
59    this.pref = (direction)?this.pref+(direction*this.increment):this.def;
60    setCookies = setcookie(this.cookieName,this.pref,this.cookieExpires,this.cookiePath);
61    this.body.fontSize = Math.round(this.pref*this.base) + '%';
62}
63Fontsize.prototype.getCookie = function(cookieName) {
64    var cookie = getcookie(cookieName);   
65    return (cookie)?cookie:false;
66}
67
68var  fontSize = new Fontsize(increment,fontSizeDefault);
69var  fsinit = 0;
70
71function getexpirydate( nodays){
72    var UTCstring;
73    Today = new Date();
74    nomilli=Date.parse(Today);
75    Today.setTime(nomilli+nodays*24*60*60*1000);
76    UTCstring = Today.toUTCString();
77    return UTCstring;
78}
79
80function getcookie(cookiename) {
81    var cookiestring=""+document.cookie;
82    var index1=cookiestring.indexOf(cookiename);
83    if (index1==-1 || cookiename=="") return ""; 
84    var index2=cookiestring.indexOf(';',index1);
85    if (index2==-1) index2=cookiestring.length; 
86    return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
87}
88
89function setcookie(name,value,duration,path){
90    cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration)+";PATH="+path;
91    document.cookie=cookiestring;
92    if(!getcookie(name)){ return false; }
93    else{ return true; }
94}

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.