PageSourceSearch

https://www.d2cinsider.com/userfiles/modules/microweber/api/fonts.js

js d2cinsider.com collected 2026-09-26 01:24:42 UTC 4,685 bytes, 172 lines download raw bytes

1
2/***********************
3
4
5    var myFont = new mw.font();
6
7
8    //create group of fonts
9
10    myFont.set({
11        family:{
12            Roboto:[300,400],
13            'Architects Daughter':[400, 700],
14        },
15        subset:["cyrillic","cyrillic-ext","korean","latin-ext"]
16    })
17
18    //add to group
19
20    myFont.add({
21        family:{
22            Roboto:[100]
23        }
24    })
25
26
27    myFont.remove('Roboto', 100) // removes weight 100
28
29    myFont.remove('Roboto')  // removes family
30
31
32
33*************************/
34
35
36
37
38mw.fonts = {
39    _create:function(){
40        var el = document.createElement('link');
41        el.rel = 'stylesheet';
42        document.documentElement.appendChild(el);
43        return el;
44    },
45    _unique:function(obj){
46        var data = {};
47        var n;
48        for(n in obj){
49            data.name = n;
50            data.weight = obj[n];
51        }
52        return data;
53    },
54    google:{
55        create:function(){
56            var root = 'https://fonts.googleapis.com/css?';
57            var el = mw.fonts._create();
58            el._rooturl = root;
59            el._config = {};
60
61            return el;
62        },
63        remove:function(el, family, weight){
64            if(!family){
65                mw.$(el).removeAttr('href');
66                el._config = {};
67            }
68            else if(!weight){
69                if(el._config.family && el._config.family[family]){
70                    delete el._config.family[family];
71                }
72                this.config(el._config, el)
73            }
74            else if(weight && family){
75                weight = parseInt(weight, 10)
76                if(el._config.family && el._config.family[family]){
77                    for(var i=0; i<el._config.family[family].length; i++){
78                        el._config.family[family][i] = parseInt(el._config.family[n][i], 10);
79                    }
80                }
81            }
82        },
83        setUrl:function(options, el){
84            var url = 'family=';
85            for( var i in options.family){
86                url += i + ':'+options.family[i].join(',') + '|';
87            }
88            url = url.substring(0, url.length - 1);
89
90            if(options.subset){
91                url += '&amp;subset=' + options.subset.join(',')
92            }
93            el._config = options;
94            el.href = el._rooturl + url.replace(/\s/g, '+');
95        },
96        config:function(options, el, mode){
97
98            /*
99            {
100                family:{
101                     'Roboto': [300,500] ,
102                    'Tajawal': [400,700]
103                },
104
105                subset:["cyrillic","cyrillic-ext","korean","latin-ext"]
106            }
107            */
108
109            for(var n in el._config.family){
110                for(var i=0; i<el._config.family[n].length; i++){
111                    el._config.family[n][i] = parseInt(el._config.family[n][i], 10);
112                }
113            }
114
115            if(mode == 'add'){
116                $.each(options.family, function(key,val){
117                    if(el._config.family && el._config.family[key]){
118                        options.family[key] = el._config.family[key].concat(options.family[key]);
119                        options.family[key] = options.family[key].filter( function (value, i, self) {
120                            return self.indexOf(value) == i;
121                        });
122                    }
123                });
124                $.each(el._config.family, function(key,val){
125                    if(options.family && !options.family[key]){
126                        options.family[key] = el._config.family[key]
127                    }
128                });
129            }
130
131            this.setUrl(options, el)
132
133        }
134    },
135    noop:{
136        fonts:[],
137        config:function(){
138
139        }
140    }
141}
142mw.font = function(){
143    this.data = {};
144    this.init = function(options){
145        options = options || {};
146        if(options.provider){
147            options.provider = options.provider.trim().toLowerCase();
148        }
149        else{
150            options.provider = 'google';
151        }
152        if(!this[options.provider]){
153            this[options.provider] = mw.fonts[options.provider].create();
154        }
155        this.options = options;
156    }
157    this.remove = function(family, weight){
158        mw.fonts[this.options.provider].remove(this[options.provider], family, weight);
159    }
160
161    this.add = function(options){
162        this.init(options)
163        mw.fonts[this.options.provider].config(this.options, this[options.provider], 'add');
164    };
165
166    this.set = function(options){
167        this.init(options);
168        mw.fonts[this.options.provider].config(this.options, this[options.provider]);
169    };
170
171
172}

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.