trace('initializing static'); if(typeof(quad_conf)=="undefined" || quad_conf==undefined) quad_conf = {}; ///*********************************************** CONFIG **************************************************************** quad_conf.whiteChars_str="!@#$$.%^&*()_+-=[]{};':\",./?\\|<>\n\t\r "; quad_conf.enders=[/ami$$./,/zie$$./,/ego$$./,/cie$$./,/em$$./,/ie$$./,/ym$$./,/sc$$./,/ow$$./]; quad_conf.enders_no=[/owy$$./,/owa$$./,/owe$$./,/owym$$./]; quad_conf.enders_ne=[/e$$./,/y$$./,/i$$./,/a$$./,/u$$./,/o$$./]; ///*********************************************** COMMON **************************************************************** var quad_static = new Object(); quad_static.extraContent = ''; quad_static.ignoreContent = false; if (typeof(extra_content) != 'undefined') quad_static.extraContent = extra_content; //TODO move QuadUtils to another file QuadUtils = function() { this.timeArr = {}; this.lastTime = 0; this.currTask = null; this.lineNo = 0; this.trash = []; this.start = function(taskName) { if (taskName && taskName != 'other') syso(taskName); var now = (new Date()).getTime(); if (this.currTask) { this.timeArr[this.currTask] += now - this.lastTime; } taskName = (taskName+'#').split('#')[0]; this.lastTime = now; this.currTask = taskName; if (this.timeArr[taskName] === undefined) { this.timeArr[taskName] = 0; } } this.printTimes = function() { syso('\n******** profile results: ********'); for (var i in this.timeArr) { syso(i + ': ' + this.timeArr[i] + ' ms'); } } this.ifnull = function(x, onnull) { if ((x == undefined) || (x == null)) return onnull; return x; } this.report = function(typ, params) { //TODO syso("Reporting: " + typ + " " + params); } this.ns_try = function(str, f) { if (typeof(console) === 'undefined') return f();//TODO try { f(); } catch(e) { this.last_e = e; this.report('ERROR: ' + str, e.message); syso('line no: ' + (e.lineNumber - this.lineNo)); console.error(e); } } this._dbg_ = {} } if (typeof(quad_utils) === 'undefined') quad_utils = new QuadUtils(); try {x.x} catch(e) {quad_utils.lineNo = e.lineNumber - 71}; function ns_uniParser(conf, syso, trace, raport) { this.minSpanLength = 12; this.minWordLength = 3; this.input_boost = 1; this.desc_boost = 1; this.kw_boost = 1; this.title_boost = 1; this.tag_boost = {}; this.important_word_bust = 2; this.allowOnlyMeta = 1;//0 or 1 this.ix_boost = 1; this.minTitleLength = 3; this.timeout = 10000; this.trim_chars = ''; this.whiteChars_str = ''; this.enders = []; this.enders_no = []; this.enders_ne = []; this.eplc_dict = null; this.max_url = 1900; this.adc_skip_tags = null; that = this; this.eplc_dict = {}; this.eplc_dict[unescape('%u00f8')]='71y'; //ø this.eplc_dict[unescape('%u00c6')]='71E'; //Æ this.eplc_dict[unescape('%u00e6')]='71e'; //æ this.eplc_dict[unescape('%u00c5')]='71A'; //Å this.eplc_dict[unescape('%u00e5')]='71a'; //å this.eplc_dict[unescape('%u00d8')]='71Y'; //Ø this.word_sort_val = function(a) { return a.so = a.bust*a.count*a.count*(1+a.count)*(8+a.word.length); } this.nonImportantWordArr = ''; this.importantWordsArr = ''; this.makeArray = function(str) { var ret = {}; for (var i=0; i 0) {//XXX performance! if (this.trimArr[word.charAt(0)]) { word = word.substring(1); o.begin++; } else if (this.trimArr[word.charAt(word.length - 1)]) { word = word.substring(0, word.length - 1); } else break; } var ok = true; for (var ch in this.trimArr) if (word.indexOf(ch) >= 0) ok = false; if (!ok) { trace('skipping word: ' + word); word = ''; continue; } if(ch=="<" && noTags !== true) tag = true; o.orgin=word; o.content=this.ecapeNationalLowerCase(word); o.set=0; if (word.length > 1) array.push(o); word = ""; } } else { if(ch==">" && !quotes && !apostrof) { tag=false; } else if(ch=="\"" && !apostrof) { quotes=!quotes; } else if(ch=="'" && !quotes) { apostrof=!apostrof; } } } return array; } this.copy = function(obj) { var ret = {}; for (var i in obj) ret[i] = obj[i]; return ret; } this.printObj = function(obj) { var ret = ''; for (var i in obj) ret += ', ' + i + '=' + obj[i]; return ret.substring(2); } this.ns_walk = function(node, state, onTextNode, onEnter, onExit, onLeaf) { if ((node.nodeType == 3) && (node.nodeValue) && (node.nodeValue.length > 3) && (node.nodeValue[0] != '<')) { trace('processing text node with state: ' + this.printObj(state)); return onTextNode(node, state); } var ch = node.childNodes; var tag = 'unknown tag'; if (node.tagName != undefined) tag = node.tagName.toLowerCase(); if ((ch.length == 0) && onLeaf) return onLeaf(tag, node, state); if (onEnter) { try { state = onEnter(tag, node, state); trace('Entering ['+tag+'] id= ' + node.id + ' with state ' + this.printObj(state)); } catch(e) { trace('Skipping ['+tag+'] with message ' + e); return; } } for (var i=0; i 1) color = ['#00a', '#22f']; that.mark(node, color[0], color[1], 'text node'); that.ns_spans.push(s); }, function(tag, node, state) { if ((new Date()).getTime() > that.timeEnd) throw that.mark(node, '#000', '#222', 'timeout'); for (var t=0; tthis.max_url) break; content += escape(ns_array_tmp[p].word); content += "+"; ns_array_tmp[p].normal_val = c_val; if (cookie_params('markIxTags')) trace(c_val + ' ---> ' + ns_array_tmp[p].word); if (ns_array_tmp[p].val= this.minWordLength) this.addWord(hashArr, arr[i].content, bust, only, arr.length); } this.getInputContent = function(hashArr) { var m=document.getElementsByTagName('input'); for (var i=0;i=0) this.addWords(hashArr, m[i].content, this.desc_boost, this.allowOnlyMeta); if (d.indexOf('keywords')>=0) this.addWords(hashArr, m[i].content, this.kw_boost, this.allowOnlyMeta); } var t = document.getElementsByTagName('title'); for (var i=0; i= 0) this.getMetaContent(this.content); if (co.indexOf('I') >= 0) this.getInputContent(this.content); if (co.indexOf('X') >= 0) this.getIxContent(this.content); if (co.indexOf('C') >= 0) this.getSpansAndTexts(this.content, params); var ret = this.getReturnStr(this.content); var exceeded = (new Date()).getTime() - this.timeEnd; trace('parsing time='+(exceeded+this.timeout)); if (exceeded >= 0) raport('timeout exceeded by: ' + exceeded + ' ms'); syso('parsing completed'); return ret; } } // uniParser quad_static.raportsLimit = 10; quad_static.raport = function(msg, exc) { if (document.readyState && (document.readyState != 'complete')) { setTimeout(function() {quad_static.raport(msg, exc)}, 400); return; } var errmsg = ''; if (exc) { errmsg = exc.lineNumber + ':_' + exc.message .split('backtrace')[0] .substring(0, 100) .replace(/ /g, '_'); } var logImage = document.getElementById('quad_log_img'); if (logImage == null) { logImage = new Image(1,1); logImage.id = 'quad_log_img'; document.body.appendChild(logImage); } else if (!logImage.complete) { setTimeout(function() {quad_static.raport(msg, exc)}, 100); return; } if (quad_static.raportsLimit-- <= 0) return; syso('raporting: ' + msg + ' ' + errmsg, 'red'); logImage.src = quad_conf.raportUrl + '?m='+msg+'&e='+errmsg; } quad_static.extraForm = function() { if (quad_static.lock) return setTimeout(quad_static.extraForm, 500); if (quad_spliter.boxes === undefined) return setTimeout(quad_static.extraForm, 500); adp_forms = null; quad_static.lock = true; try { syso('Stray ad form detected.'); adp_forms = null; var b = quad_spliter.boxes; for (var i=0; i<10; i++) { var a = Math.floor(Math.random()*b.length); var c = Math.floor(Math.random()*b.length); var tmp = b[a]; b[a] = b[c]; b[c] = tmp; } quad_spliter.boxes = b; quad_spliter.boxes_count=0; quad_static.parseScripts(); quad_static.adWriter.writeAll( quad_static.forms, quad_spliter.boxes, quad_spliter.totalforms, false, function() { quad_static.raport('W10'); syso('ok.'); }); } catch(e) { quad_static.raport('E09', e); } quad_static.lock = false; syso('ok.'); } //depricated quad_static.convert_field = function(form) {//TODO rm form.paleta = new Object(); form.nazwa='quad_ad_'+quad_static.forms.length; form.paleta.kolor_tytul='#'+form.colors.title; form.paleta.kolor_tlo='#'+form.colors.bg; form.paleta.kolor_opis='#'+form.colors.desc; form.paleta.kolor_url='#'+form.colors.url; form.paleta.kolor_naglowek='#'+form.colors.header; form.paleta.kolor_tlo_naglowka='#'+form.colors.headerBg; form.paleta.kolor_ramki_naglowka='#'+form.colors.headerFrame; form.naroznik_lewy_gorny=form.corner_lt; form.naroznik_prawy_gorny=form.corner_rt; form.naroznik_lewy_dolny=form.corner_lb; form.naroznik_prawy_dolny=form.corner_rb; form.czy_url=form.withUrl; form.id_koloru_metki=form.labelId; form.typ=201; form.metka=['text', 'right', 'bottom'][form.labelType]; form.scalenie=form.merging; } quad_static.parse1 = function(node, params) { try { if (!node.parentNode) syso('N00') var form = new Object(); form.line = params; form.node = node; var par = params.split(','); if (par.length < 21) return false; for (var j=0; j= par.length) break; par[j] = par[j] == '' ? null : par[j] == 't' ? true : par[j] == 'f' ? false : (isNaN(par[j]*1) || par[j].length > 2 ? par[j] : par[j]*1); var attr = quad_conf.paramOrder[j].split('.'); if (attr.length > 1) { if (form[attr[0]] == undefined) form[attr[0]] = new Object(); form[attr[0]][attr[1]] = par[j]; } else { form[attr[0]] = par[j]; } } quad_static.convert_field(form); node.id = 'quad_ad_'+quad_static.forms.length; if (form.noContent === false) quad_static.ignoreContent = true; quad_static.forms.push(form); return form; } catch(e) { return null; } } quad_static.parseScripts = function() {//depricated quad_static.lock = true; adp_forms = null; quad_static.forms = quad_utils.ifnull(quad_static.forms, []); var scarr = document.getElementsByTagName('script'); trace('script count: ' + scarr.length); for (var i=0; i 0) { for (var ei=0; ei=580 && pola.y>=100) return 'e'; if (pola.x>=540 && pola.y>=170 || pola.x>=380 && pola.y>=190 || pola.x>=240 && pola.y>=250 ) return 'E'; if (pola.x>=160 && pola.y>=400 ) return 'W'; return ''; } quad_static.adc_go1 = function() { if (typeof(wfa) != "undefined" && wfa != quad_static.adc_go1) { wfa = quad_static.adc_go1; return; } try { for (var i=0; i 0) adc_c = '_32+'+quad_static.extraContent + adc_c; adc_c = quad_spliter.run_param('alterContent', adc_c, adc_c); adc_c = escape(adc_c); adc_c = adc_c.replace(/\n/g,'+'); adc_c = adc_c.replace(/%20/g,'+'); if (adc_c.length>600) adc_c = adc_c.substring(0,600).replace(/\+[^+]*$/g,''); for (var a=adc_c.length-7;a/g, '>') .replace(/\./g,". ") .replace(/\\/g,"\\ "); } quad_static.removeOldAds = function() { var divs = document.getElementsByTagName('div'); for (var d=0; d h_out[obj.type]) h_out[obj.type] = obj.realSize.y; return obj.realSize.y; } obj.getFinalDOM = function(doc, par, x, y) { var rs = obj.realSize; if ((rs.x <= 0) || (rs.y <= 0)) return; if (!obj.bc && !obj.img) return; obj.dom = doc.createElement('div'); if (ns_dbg) obj.dom = getDiv(doc, obj); //dbg var ods = obj.dom.style; for (var i in obj.css) ods[i] = obj.css[i]; if (obj.bc) ods.backgroundColor = obj.bc; ods.width = rs.x + 'px'; ods.height = rs.y + 'px'; ods.left = x + 'px'; ods.top = y + 'px'; par.appendChild(obj.dom); } return obj; } this.textDiv = function(fc, bc, tc, txt, sfs, type) { var obj = this.emptyDiv(0, 0, fc, bc); obj.tc = tc; obj.txt = txt; obj.sfs = sfs; obj.type = type; obj.go1 = function(doc, checkNodes, textNodes, smallDOM) { obj.checkSize = true; if (obj.type) checkNodes.push(obj); if (!obj.fixed) textNodes.push(obj); obj.dom = getDiv(doc, obj); var ds = obj.dom.style; try{ for (var i in obj.css) ds[i] = obj.css[i]; }catch(e){ syso('unsupported css value', i + '=' + obj.css[i]); } if (obj.tc) ds.color = obj.tc; if (obj.bc) ds.backgroundColor = obj.bc; ds.width = ''; ds.height = ''; obj.span = doc.createElement('span'); obj.span.innerHTML = obj.txt; obj.dom.appendChild(obj.span); smallDOM.appendChild(obj.dom); return obj.minSize; } obj.setFullSize = function(dim, size) { if (size <= 0) prErr('dupa ' + dim); obj.realSize[dim] = size; obj.dom.style.width = obj.realSize[dim] + 'px'; } obj.setFontSize = function(fs) { obj.dom.style.fontSize = obj.sfs(fs) + 'px'; } obj.getRealSize = function() { obj.realSize.y = obj.dom.offsetHeight; obj.exceedsWidth = obj.span.offsetWidth > obj.realSize.x + 3; if ((obj.txt != '') && (obj.realSize.y < 5)) { obj.realSize.y = (parseInt(obj.dom.style.fontSize) + 4) * Math.floor(obj.txt.length * 10 / obj.realSize.x + 1); syso('no height info available: ' + obj.realSize.y + ', ' + obj.dom.style.fontSize); that_nst.need_rewrite = true; } } obj.getFinalDOM = function(doc, par, x, y) { if (obj.oncomplete) { obj.oncomplete(); obj.span.innerHTML = obj.txt; } var ds = obj.dom.style; ds.width = obj.realSize.x + 'px'; ds.height = obj.realSize.y + 'px'; ds.left = x + 'px'; ds.top = y + 'px'; if (obj.a) adda(obj.dom, obj.a); par.appendChild(obj.dom); } return obj; } this.table = function(c, r, wx, wy, sx, sy) { var obj = {}; obj.colc = c; obj.rowc = r; obj.cellc = {x: c, y: r}; if (wx === undefined) wx = []; if (wy === undefined) wy = []; if (sx === undefined) sx = []; if (sy === undefined) sy = []; obj.weights = {x: wx, y: wy}; obj.minSizes = {x: sx, y: sy}; obj.cells = []; for (var x=0; x 0) { totalW += wg[i]; heavy.push(i); } else { size -= obj.realSizes[dim][i]; } } var w0 = size % totalW; var w1 = (size - w0) / totalW; var hn = heavy.length; for (var i=0; i s1) s1 = h_in[ch.type]; if (s1 > obj.realSizes.y[ch.y]) obj.realSizes.y[ch.y] = s1; if (ch.exceedsWidth) obj.exceedsWidth = true; } var size = 0; for (var y=0; y"; this.getIframe = function(div, x, y, font) { var cd = null; var ifr = null; try { ifr = document.createElement('IFRAME'); ifr.marginWidth='0'; ifr.marginHeight='0'; ifr.scrolling='no'; ifr.style.display='block'; ifr.frameBorder='0'; ifr.style.width = x+"px"; ifr.style.height = y+"px"; try { ifr.allowTransparency="true"; } catch(e){} div.appendChild(ifr); if (ifr.contentDocument) { cd = ifr.contentDocument; } else if (ifr.contentWindow) { cd = ifr.contentWindow.document; } cd.open(); cd.write(this.inn.replace(/_FONT_/g, font)); cd.close(); div = cd.body; } catch (e) { syso('WARNING: IFRAME creation failed: ' + e.lineNumber); try { div.removeChild(ifr); } catch(e){} cd = document; } return {cd: cd, div: div}; } this.checkForm = function(form) { var checkInt = function(str, minv, maxv) { var i = parseInt(form[str]); if (isNaN(i) || (i < minv) || (i > maxv)) { prErr('invalid value: ' + str + ' = ' + form[str]); } form[str] = i; } var fixColor = function(c) { var cc = '#white|fff#aqua|0ff#magneta|f0f#yellow|ff0#red|f00#green|0f0#blue|00f#black|000#gray|777#silver|ddd#'; var ci = cc.indexOf('#'+c+'|'); if (ci >= 0) c = cc.substring(ci).split('|')[1].split('#')[0]; if (c.length === 3) c = c.charAt(0) + c.charAt(0) + c.charAt(1) + c.charAt(1) + c.charAt(2) + c.charAt(2); return c; } var checkCol = function(str) { form.colors[str] = fixColor(form.colors[str]); var str = form.colors[str]; if (str.length != 6) return prErr('invalid color: ' + str); for (var i=0; i<6; i++) { if ('0123456789abcdefABCDEF'.indexOf(str.charAt(i)) < 0) { return prErr('invalid color: ' + str); } } } if (form.labelType === 0) form.labelType = 3; if (form.labelType === 3) form.labelType = (form.x * form.r / (form.y * form.c) < utils.ifnull(conf.labelXY, 6)) ? 3 : 4; checkInt('merging', 1, 3); checkInt('spacing', 0, 20); checkInt('labelType', 1, 4); checkInt('corner_lt', 0, 4); checkInt('corner_rt', 0, 4); checkInt('corner_lb', 0, 4); checkInt('corner_rb', 0, 4); checkCol('title'); checkCol('bg'); checkCol('desc'); checkCol('url'); checkCol('header'); checkCol('headerBg'); checkCol('headerFrame'); if ((form.labelType < 1) || (form.labelType > 4)) form.labelType = 3; form.colors.frame = form.colors.header; form.spacing = [form.spacing, 0, 0][form.scalenie - 1]; form.x = form.x - 0; form.y = form.y - 0; form.corners = { tl: form.corner_lt, tr: form.corner_rt, bl: form.corner_lb, br: form.corner_rb } } this.fsf = { title : function(n) {return n+2}, desc : function(n) {return n+1}, url : function(n) {return n}, label : function(n) {return 12}, small_title : function(n) {return n+2}, small_desc : function(n) {return n}, small_label : function(n) {return 10}, ex_title : function(n) {return n+14}, ex_desc : function(n) {return n+3}, ex_url : function(n) {return n}, ex_label : function(n) {return 12} } this.writeAll = function(forms, boxes, totalforms, redraw, oncomplete) { utils.start('creating iframes'); for (var i=0; i= 3) { node.cells[x][y] = nst.textDiv(null, null, '0000FF', conf.labelText, this.fsf.ex_label); node.cells[x][y].css = {textAlign: 'right', textDecoration: 'underline'}; node.cells[x][y].a = {href: conf.adc_akon_href, url: conf.adc_akon_url, pri: 1}; } } this.exForm = function(tab) { tab.type = 'A'; tab.bc = 'FFFFFF'; tab.fc = '777777'; } this.writeBillboard = function(form, box1) { var ret = nst.table(5, 4, [0, 0, 0, 1, 0], [1, 0, 1, 0], [10, 0, 30, 0, 10], [10, 0, 0, 10]); this.exForm(ret); var tImg = ret.cells[1][1] = nst.table(1, 3, [1], [0, 0, 1], [200], [50, 10, 0]); tImg.cells[0][0] = nst.getImgDiv(conf.h_imager_url.replace(/_ID_/g, box1.id), 200, 50); tImg.cells[0][2] = nst.textDiv(null, null, '5368B8', box1.durl, this.fsf.ex_url); tImg.cells[0][2].css.textAlign = 'center'; var tDesc = ret.cells[3][1] = nst.table(1, 3, [1], [0, 0, 1], [0], [0, 10, 10]); tDesc.cells[0][0] = nst.textDiv(null, null, '000000', box1.title, this.fsf.ex_title); tDesc.cells[0][0].css = {fontWeight: 'bold', textDecoration: 'underline'}; tDesc.cells[0][2] = nst.textDiv(null, null, '000000', box1.opis1, this.fsf.ex_desc); tDesc.cells[0][2].css = {fontWeight: 'bold'}; this.exTextLabel(ret, 3, 3, form); ret.a = {href: box1.aa, url: box1.durl, pri: 0}; ret = this.addCorners(ret, form.corners); return ret; } this.writeRectForm = function(form, box1, rect) { var ret = nst.table(1, 11, [1], [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0], [10, 50, 10, 0, 20, 0, 10, 0, 10, 0, 10]); this.exForm(ret); ret.cells[0][1] = nst.getImgDiv(conf.h_imager_url.replace(/_ID_/g, box1.id), 200, 50); ret.cells[0][3] = nst.textDiv(null, null, '5368B8', box1.url, this.fsf.ex_url); ret.cells[0][3].css.textAlign = 'center'; ret.cells[0][5] = nst.textDiv(null, null, '000000', box1.title, this.fsf.ex_title); ret.cells[0][5].css = {textAlign: 'center', fontWeight: 'bold', textDecoration: 'underline'}; ret.cells[0][7] = nst.textDiv(null, null, '000000', box1.opis1, this.fsf.ex_desc); ret.cells[0][7].css = {textAlign: 'center', fontWeight: 'bold'}; this.exTextLabel(ret, 0, 9, form); ret.a = {href: box1.aa, url: box1.durl, pri: 0}; ret = this.addCorners(ret, form.corners); return ret; } this.writeSkyscraper = function(form, box1, rect) { var ret = nst.table(1, 11, [1], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0], [10, 50, 10, 0, 20, 0, 10, 0, 10, 0, 10]); this.exForm(ret); ret.cells[0][1] = nst.getImgDiv(conf.v_imager_url.replace(/_ID_/g, box1.id), 140, 120); ret.cells[0][3] = nst.textDiv(null, null, '000000', box1.title, this.fsf.ex_title); ret.cells[0][3].css.textAlign = 'center'; ret.cells[0][5] = nst.textDiv(null, null, '000000', box1.opis1, this.fsf.ex_desc); ret.cells[0][5].css.textAlign = 'center'; ret.cells[0][7] = nst.textDiv(null, null, '5368B8', box1.url, this.fsf.ex_url); ret.cells[0][7].css.textAlign = 'center'; this.exTextLabel(ret, 0, 9, form); ret.a = {href: box1.aa, url: box1.durl, pri: 0}; ret = this.addCorners(ret, form.corners); return ret; } this.addLabel = function(labelType, labelId, dom) { if (labelType === 1) { var ret = nst.table(2, 1, [1, 0], [1]); ret.cells[0][0] = dom; var labT = nst.table(1, 3, [1], [1, 0, 0]); ret.cells[1][0] = labT; labT.cells[0][0] = nst.emptyDiv(0, 0); labT.cells[0][2] = nst.emptyDiv(0, 15); labT.cells[0][1] = nst.getImgDiv(conf.vimgurl.replace('**', labelId), 15, 60);//FIXME ret.a = {href: conf.adc_akon_href, url: conf.adc_akon_url, pri: 1}; return ret; } else if (labelType === 2) { var ret = nst.table(1, 2, [1], [1, 0]); ret.cells[0][0] = dom; var labT = nst.table(3, 1, [1, 0, 0], [0]); ret.cells[0][1] = labT; labT.cells[0][0] = nst.emptyDiv(0, 0); labT.cells[2][0] = nst.emptyDiv(15, 0); labT.cells[1][0] = nst.getImgDiv(conf.himgurl.replace('**', labelId), 120, 15);//FIXME labT.cells[1][0].css.backgroundPosition = 'right'; ret.a = {href: conf.adc_akon_href, url: conf.adc_akon_url, pri: 1}; return ret; } return dom; } this.getFontSizes = function(dom, form) { var mins = this.initFS; var maxs = this.maxFS; var ok = null; var maxiter = 100; while (mins < maxs) { if (maxiter--<0) break; var check = Math.floor((mins + maxs + 1) / 2); ok = dom.getHeight(check) <= form.y && !dom.exceedsWidth; if (ok) { mins = check; } else { maxs = check - 1; } } if (!ok) dom.getHeight(mins); syso('font size: ' + mins); return mins; } this.getBorder = function(tab) { var gb = function(tab, top, bottom, left, right, fc, bc) { if (tab.fc) fc = tab.fc; if (tab.bc) bc = tab.bc; if (tab.leaf || tab.fc) { if (top) top.push({fg: fc, bg: bc, node: tab}); if (bottom) bottom.push({fg: fc, bg: bc, node: tab}); if (left) left.push({fg: fc, bg: bc, node: tab}); if (right) right.push({fg: fc, bg: bc, node: tab}); } else { if (top) for (var x=0; x=0; j--) { var sub = Math.min(arr[j].size, t.end); arr[j].size -= sub; t.end -= sub; } } root.tab.dom.style.display = 'none'; for (var i=0; i 1) || (y+1/n > 1) ? 0 : 1; }, function(x, y, n) { var s = 0.4/n; return n*(1-(x+s)*(x+s)-(y+s)*(y+s))/1.8; }, function(x, y, n) { return (x<1/n) || (y<1/n) ? 0 : n*(1-x-y)/1.4; } ]; this.mergeColors = function(c1, c2, w) { var ret = ''; if (w < 0) w = 0; if (w > 1) w = 1; var digits = '0123456789abcdef'; var getc = function(c) { return digits.indexOf(c.toLowerCase()) } for (var i=0; i<3; i++) { var val1 = 16 * getc(c1.charAt(2*i)) + getc(c1.charAt(2*i+1)); var val2 = 16 * getc(c2.charAt(2*i)) + getc(c2.charAt(2*i+1)); var val = val1 * (1-w) + val2 * w; ret += digits.charAt(Math.floor(val / 16)); ret += digits.charAt(val % 16); } return ret; } this.setColor = function(ch, val, colors) { ch.bc = val >= 0.999 ? colors.bg : (val >= -1.001 ? colors.fg : null); if (val < 0) { var op = Math.min(1, val+1); if (op <= 0) { ch.bc = null; } else if (val < -0.01) { try {ch.css.filter='alpha(opacity='+(op*100)+')'} catch(e) {}; try {ch.css.MozOpacity = op} catch(e) {}; } } else { ch.bc = this.mergeColors(colors.fg, colors.bg, val); } } this.drawCorner = function(corner, colors, hswap, vswap) { var cs1 = this.cornerSize; var bs = this.borderSize; if (!this.corners[corner]) { var c = []; for (var x=0; x 0.999) v = 0.999; if (v != last) { if (posy >= 0) cx.push({v: last, r: y - posy}); posy = y; last = v; } } cx.push({v: last, r: cs1 - posy}); } var cc = this.corners[corner] = []; var last1 = []; var posx = -1; for (var x=0; x= 0) cc.push({v: last1, r: x - posx}); posx = x; last1 = v; } } cc.push({v: last1, r: c.length - posx}); } var csa = this.corners[corner]; var tx = nst.table(csa.length, 1); tx.minSizes.y[0] = cs1; for (var x=0; x