/    Sign up×
Community /Pin to ProfileBookmark

Replacing Characters in a web page

Okay new problem now, i fixed the old one. In the results, it displays two links. One with the title that i give the link. Then the link name with a link to the file. How would I go about removing that? Also, it doesn’t link to a sub directory. It writes the link to the file without first going through a sub directory, therefore the link is not gonna work. Thanks!

Here is the script for the seach engine:

// ———- script properties ———-

var results_location = “results.html”;
var return_results = 10;
var include_num = 0;
var bold_query = 0;
var include_url = 1;

// ———- end of script properties ———-

var cookies = document.cookie;
var p = cookies.indexOf(‘d=’);
var pn = cookies.indexOf(‘n=’);

if (p != -1) {
var st = p + 2;
var en = cookies.indexOf(‘;’, st);
if (en == -1) {
en = cookies.length;
}
var d = cookies.substring(st, en);
d = unescape(d);
}
if (pn != -1) {
var st = pn + 2;
var en = cookies.indexOf(‘;’, st);
if (en == -1) {
en = cookies.length;
}
var n = cookies.substring(st, en);
}

var od = d;
var nr = return_results;
n = parseInt(n);
var nb = n + nr;
var nc = 0;
var nd = 0;
var r = new Array();
var rt = new Array();
var co = 0;
var m = 0;

if (d.charAt(0) == ‘”‘ && d.charAt(d.length – 1) == ‘”‘) {
m = 1;
}
var rn = d.search(/ or /i);
if (rn >= 0) {
m = 2;
}
rn = d.search(/-/i);
if (rn >= 0) {
rn = d.search(/ /i);
if (rn != 0) {
d = d.replace(/-/gi, ‘ -‘);
}
}
rn = d.search(/ not /i);
if (rn >= 0) {
d = d.replace(/ not /gi, ‘ -‘);
}
rn = d.search(/+/i);
if (rn >= 0) {
rn = d.search(/ /i);
if (rn != 0) {
d = d.replace(/+/gi, ‘ +’);
}
}
if (m == 0) {
var woin = new Array();
d = d.replace(/ and /gi, ‘ ‘);
var w = d.split(‘ ‘);
for (var a = 0; a < w.length; a++) {
woin[a] = 0;
if (w[a].charAt(0) == ‘-‘) {
woin[a] = 1;
}
}
for (var a = 0; a < w.length; a++) {
w[a] = w[a].replace(/^|^+/gi, ”);
}
a = 0;
for (var c = 0; c < s.length; c++) {
var es = s[c].split(‘^‘);
var rk = 100;
if (es[5] == null) {
es[5] = ‘0’;
}
if (parseInt(es[5]) > 10) {
es[5] = ’10’;
}
var pa = 0;
var nh = 0;
for (var i = 0; i < woin.length; i++) {
if (woin[i] == 0) {
nh++;
var nt = 0;
var pat = new RegExp(w[i], ‘i’);
var rn = es[0].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
nt = 1;
}
var rn = es[2].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
nt = 1;
}
var rn = es[3].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
nt = 1;
}
if (nt == 1) {
pa++;
}
}
if (woin[i] == 1) {
var pat = new RegExp(w[i], ‘i’);
var rn = es[0].search(pat);
if (rn >= 0) {
pa = 0;
}
var rn = es[2].search(pat);
if (rn >= 0) {
pa = 0;
}
var rn = es[3].search(pat);
if (rn >= 0) {
pa = 0;
}
}
}
if (pa == nh) {
r[a] = rk + ‘^ + s[c];
a++;
}
}
r.sort();
co = a;
}

if (m == 1) {
d = d.replace(/”/gi, ”);
var a = 0;
var pat = new RegExp(d, ‘i’);
for (var c = 0; c < s.length; c++) {
var es = s[c].split(‘^‘);
var rk = 100;
if (es[5] == null) {
es[5] = ‘0’;
}
if (parseInt(es[5]) > 10) {
es[5] = ’10’;
}
var rn = es[0].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
}
rn = es[2].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
}
rn = es[3].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
}
if (rk < 100) {
r[a] = rk + ‘^ + s[c];
a++;
}
}
r.sort();
co = a;
}

if (m == 2) {
d = d.replace(/ or /gi, ‘ ‘);
var w = d.split(‘ ‘);
var a = 0;
for (var i = 0; i < w.length; i++) {
var pat = new RegExp(w[i], ‘i’);
for (var c = 0; c < s.length; c++) {
var es = s[c].split(‘^‘);
var rk = 100;
if (es[5] == null) {
es[5] = ‘0’;
}
if (parseInt(es[5]) > 10) {
es[5] = ’10’;
}
var pa = 0;
var rn = es[0].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
if (rn >= 0) {
for (var e = 0; e < rt.length; e++) {
if (s[c] == rt[e]) {
pa = 1;
}
}
}
}
rn = es[2].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
if (rn >= 0) {
for (var e = 0; e < rt.length; e++) {
if (s[c] == rt[e]) {
pa = 1;
}
}
}
}
var rn = es[3].search(pat);
if (rn >= 0) {
rk = rk – 11;
rk = rk – parseInt(es[5]);
if (rn >= 0) {
for (var e = 0; e < rt.length; e++) {
if (s[c] == rt[e]) {
pa = 1;
}
}
}
}
if (rk < 100 && pa == 0) {
rt[a] = s[c];
r[a] = rk + ‘^ + s[c];
a++;
co++;
}
}
}
r.sort();
}

function write_cookie(nw) {
document.cookie = ‘d=’ + escape(od) + ‘; path=/’;
document.cookie = ‘n=’ + nw + ‘; path=/’;
}

// ———- External references ———-

var tip_Num = co;

function tip_query() {
document.tip_Form.d.value = od;
}

function tip_num() {
document.write(co);
}

function tip_out() {
if (co == 0) {
document.write(‘Your search did not match any documents.<p>Make sure all keywords are spelled correctly.<br>Try different or more general keywords.’);
return;
}
if (n + nr > co) {
nd = co;
} else {
nd = n + nr;
}
for (var a = n; a < nd; a++) {
var os = r[a].split(‘^‘);
if (os[5] == null) {
os[5] = ‘0’;
}
if (bold_query == 1 && m == 0) {
for (var i = 0; i < w.length; i++) {
var lw = w[i].length;
var tw = new RegExp(w[i], ‘i’);
rn = os[3].search(tw);
if (rn >= 0) {
var o1 = os[3].slice(0, rn);
var o2 = os[3].slice(rn, rn + lw);
var o3 = os[3].slice(rn + lw);
os[3] = o1 + ‘<b>’ + o2 + ‘</b>’ + o3;
}
}
}
if (bold_query == 1 && m == 1) {
var lw = d.length;
var tw = new RegExp(d, ‘i’);
rn = os[3].search(tw);
if (rn >= 0) {
var o1 = os[3].slice(0, rn);
var o2 = os[3].slice(rn, rn + lw);
var o3 = os[3].slice(rn + lw);
os[3] = o1 + ‘<b>’ + o2 + ‘</b>’ + o3;
}
}
if (include_num == 1) {
document.write(a + 1, ‘. ‘);
}
if (os[5] == ‘0’) {
document.write(‘<a href=”‘, os[2], ‘”>’, os[1], ‘</a>’);

}

Comment from me (not in script) this part is where it writes the link, i understand that, but i don’t want it to display two links for the same thing. I just want the title.

if (os[5] == ‘1’) {
document.write(‘<a href=”‘, os[2], ‘” target=”_blank”>’, os[1], ‘</a>’);
}
if (os[5] != ‘0’ && os[5] != ‘1’) {
document.write(‘<a href=”‘, os[2], ‘” target=”‘, os[5], ‘”>’, os[1], ‘</a>’);
}
if (os[3].length > 1) {
document.write(‘<br>’, os[3]);
}
if (include_url == 1) {
if (os[5] == ‘0’) {
document.write(‘<br><a href=”‘, os[2], ‘”>’, os[2], ‘</a><p>’);
}
if (os[5] == ‘1’) {
document.write(‘<br><a href=”‘, os[2], ‘” target=”_blank”>’, os[2], ‘</a><p>’);
}
if (os[5] != ‘0’ && os[5] != ‘1’) {
document.write(‘<br><a href=”‘, os[2], ‘” target=”‘, os[5], ‘”>’, os[2], ‘</a><p>’);
}
} else {
document.write(‘<p>’);
}
}
if (co > nr) {
nc = co – nb;
if (nc > nr) {
nc = nr;
}
document.write(‘<p>’);
}
if (n > 1) {
document.write(‘<a href=”‘, results_location, ‘” onclick=”write_cookie(‘, n – nr, ‘)”>Previous ‘, nr, ‘</a> &nbsp;’);
}
if (nc > 0) {
document.write(‘<a href=”‘, results_location, ‘” onclick=”write_cookie(‘, n + nr, ‘)”>Next ‘, nc, ‘</a>’);
}

}

Thanks for the help guys! Unless you know of any other way I could make it searchable with java script for free easier. I don’t wanna use PHP or SQL. Thanks again!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @dpool2002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...