0% found this document useful (0 votes)
43 views2 pages

F

The document contains JavaScript code for customizing the appearance and behavior of a search box on a website. It sets styles, handles events, and adds hidden form fields when the search box is used. The code enhances the search box functionality but does so in an unobtrusive way without disrupting the core search features.

Uploaded by

Maarcelo Torres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

F

The document contains JavaScript code for customizing the appearance and behavior of a search box on a website. It sets styles, handles events, and adds hidden form fields when the search box is used. The code enhances the search box functionality but does so in an unobtrusive way without disrupting the core search features.

Uploaded by

Maarcelo Torres
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

(function() {

var f = document.getElementById('cse-search-box');
if (!f) {
f = document.getElementById('searchbox_demo');
}
if (f && f['q']) {
var q = f['q'];
var n = navigator;
var l = location;
var du = function(n, v) {
var u = document.createElement('input');
u.name = n;
u.value = v;
u.type = 'hidden';
f.appendChild(u);
return u;
};
var su = function (n, t, v, l) {
if (!encodeURIComponent || !decodeURIComponent) {
return;
}
var regexp = new RegExp('(?:[?&]' + n + '=)([^&#]*)');
var existing = regexp.exec(t);
if (existing) {
v = decodeURIComponent(existing[1]);
}
var delimIndex = v.indexOf('://');
if (delimIndex >= 0) {
v = v.substring(delimIndex + '://'.length, v.length);
}
var v_sub = v.substring(0, l);
while (encodeURIComponent(v_sub).length > l) {
v_sub = v_sub.substring(0, v_sub.length - 1);
}
du(n, v_sub);
};
var pl = function(he) {
var ti = 0, tsi = 0, tk = 0, pt;
return function() {
var ct = (new Date).getTime();
if (pt) {
var i = ct - pt;
ti += i;
tsi += i*i;
}
tk++;
pt = ct;
he.value = [ti, tsi, tk].join('j');
};
};
var append = false;
if (n.appName == 'Microsoft Internet Explorer') {
var s = f.parentNode.childNodes;
for (var i = 0; i < s.length; i++) {
if (s[i].nodeName == 'SCRIPT' &&
s[i].attributes['src'] &&
s[i].attributes['src'].nodeValue ==
unescape('\x2F\x2Fcse.google.com\x2Fcoop\x2Fcse\x2Fbrand?form=cse-search-
box\x26lang=es')) {
append = true;
break;
}
}
} else {
append = true;
}
if (append) {

var loc = document.location.toString(); var ref = document.referrer;


su('siteurl', loc, loc, 250);
su('ref', loc, ref, 750);

if (q.addEventListener) {
q.addEventListener('keyup', pl(du('ss', '')), false);
} else if (q.attachEvent) {
q.attachEvent('onkeyup', pl(du('ss', '')));
}
}

if (n.platform == 'Win32') {
q.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;';
}

if (window.history.navigationMode) {
window.history.navigationMode = 'compatible';
}

var b = function() {
if (q.value == '') {
q.style.background = '#FFFFFF
url(https:\x2F\x2Fwww.google.com\x2Fcse\x2Fstatic\x2Fimages\x2F1x\x2Fgooglelogo_lig
htgrey_46x16dp.png) left no-repeat';
q.style.textIndent = '48px';
q.placeholder = 'Búsqueda personalizada';
}
};

var f = function() {
q.style.background = '#ffffff';
q.style.textIndent = '0';
q.placeholder = '';
};

q.onfocus = f;
q.onblur = b;

if (!/[&?]q=[^&]/.test(l.search)) {
b();
}
}
})();

You might also like