I am trying to figure out how the search tool in a web browser is being able to parse through the entire web page(assuming huge content on a page) and highlight the result as we type. Does it pre-cache the page while loading in a map or use regex to get a quick result on the fly?
The document is already parsed, by the browser. Searching that document could walk the DOM tree, decide what nodes that could be searched, and inject document nodes to alter the display(such as making the text bold etc).
A standard string matching algorithms can parse through a really huge chunk of text in a second.(think about it, you can run a 3D multiplayer game with collition detection,scene culling, AI,, sound, flashy effects, integrated voice chat, at 60fps on a standard computer, searching a few megabytes of text is nothing..)
Finding a substring in a bigger text isn't such of a hard work for a computer to do. Actually, I believe it is much harder to render a html page (though not too hard) than to find a substring. As mentioned, there is fast algorithms for this.
Keep in mind, your machine is almost fully dedicated to this at this moment, so there's lots of processing capacity dedicated to this (rather simple) job...
I don't know the details, but I would imagine it is something like this.
The Boyer-Moore algorithm is a very fast and efficient way of searching for text substrings.
I expect it would involve traversing the dom for plain text. I may only be speculating but I would take the dom and search for elements that could contain plaintext, inside which I would do a search of that elements contents and child elements.
If you do a search in firefox and look via firefbug you'll notice that firefox modifies the dom of the document so that search items are children of elements themselves, to which styling such as the highlighting is applied.
For example, here is what happens to the phrase 'eleme' on this page if I start a search using firefox and highlight all:
<span style="padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;" class="__mozilla-findbar-search">eleme</span>
php/ smarty
by using url encode you can do it ?pls serach on urlencode file?="c-content"
prefix
sample code ::::
print_r($file);
if(isset($file)){
$var=explode("-",$file);
print_r($var);
$prefix=$var[0];
$script=$var[1];
}
else
{
$file="c-home1";
$prefix="c";
$script="home";
$modid = 0;
}
if($script=="")
$script="prod_list";
------------------------------------------------------------------------------------------
//following code finds out the modules from sufiix and find out the script name
switch ($prefix)
{
case "c":
$module = "content";
break;
case "m":
$module = "myaccount";
break;
default:
$module = "content";
break;
}
$smarty->assign("module",$module);
//following code finds out the modules from suffix and find out the script name
$include_script .= $module."/".$script.".php";
if(file_exists($include_script))
include_once($include_script);
else
include_once("content/error.php");
if($script!='home')
{
if($script == 'termsandcondition'){
$smarty->display("content/termsandcondition.tpl");
}else{
$smarty->display("template.tpl");
}
}
else
{
$smarty->display("template_home.tpl");
$smarty->assign("msg",$msg);
$smarty->assign("msglogin",$msglogin);
}
?>
Related
I am currently using the following css to display a list of items with a flexbox
section ol li div ul {
display:flex;
flex-direction:row;
flex-wrap: wrap;
gap:7px;
row-gap:0;
list-style-type: none;
}
This satisfies me on all but one problem:
when I have a big item that will not fit entirely on the rest of the line, it will be set at the beginning of a new line, thus possibly making a huge part of the line before unused. I do not wish that (note that for small items, this is exactly what I want).
Initial goal (probably not achievable): I have been thinking on what kind of rule I would like and it would be something like "if more than x% of the line is wasted, then display the item inline instead". This would enable to continue filling the line.
I have currently abandoned on doing that with only html and css and I might consider trying to write such a rule in js later, but not for now (unless somebody has a very nice solution).
Current goal: I have thus decided to manually specify some items (that are "big") that should be inlined (sometimes using media queries, but we can ignore them for now). The idea is to add the following class to those objects.
.inlineitem {
display:inline;
}
Problem: display:inline; within a flex container does not work and I do not wish to change the whole flex container for the other items... Is there a way to achieve what I want ?
This character doesn't exist in Unicode since I created it myself. Now, it is in an esp file format. After some searches, and my understanding, I can't just put it into Unicode.
My goal is to display it, let my viewers to see if they like it, but not in any picture format since it also serves other purposes for the website, where displaying it as an image is just not considered.
How can we display a self-created character where it could ONLY be displayed as a regular letter?
Yes we can, but we should be really careful doing so.
As Remy Lebau suggested, if you really insist on using custom glyph as "regular letter" inside text flow, you should
create a real font file to be placed on web (WOFF/OTF), or installed on each user device (OTF/TTF),
ensure that custom glyph in your font file is assigned to some code point from the "private-use" area,
use the code point in unicode-range value of #font-face,
and add newly created font-family to the font stack.
Example:
#font-face {
font-family: f;
src: local(Impact), local(Haettenschweiler), local(Helvetica Inserat);
unicode-range: U+65;
}
#font-face {
font-family: f;
src: local(Courier new), local(Menlo), local(Liberation Mono);
unicode-range: U+6f;
}
body { font-family: f, sans-serif; }
<p>Some text where letters "o" and "e" are from a different ("custom") font-faces.</p>
Font-face with only private-use characters should work even as a last (fallback) in the stack, but it does not matter here. In your case those "local()" declarations would be replaced with url() path or dataURI. If your target audience is in controlled environment (intranet) and you can reliably distribute the to all consuming devices, you can use even the local([name of locally installed ustom font])
The unicode-range value would be something like U+F8FF.
But, use this in and only if you are sure your users will
Why you probably should not do that this way
If there is chance (some of) your users have not installed, does not support, can not download or are blocking given font, or is using assistive technology to consume your content and given glyph conveys some meaningful information, you probably should refrain from using the approach described above.
If you don't have such controlled audience and want to support screen readers, and still don't want to use simple <img alt="[glyph meaning in the context]">, you should at least wrap their occurrences as suggested in Léonie Watson's article Accessible emoji:
Some text <span role="img" aria-label="[glyph meaning in the context]"></span>
This question regards website programming. My primary languages are c++/c# and I don't know much about web development, except that say I understand html and css. That's why I'm looking for a relatively simple solution, preferably something out of the box. I don't have any experience with JavaScript, but for the sake of this project I'm willing to learn it if necessary.
Let's say I have a database, where each entry is about a book. It contains the fields: title, author(s) and publication date.
I would like to create a simple website with a search box that has this dynamic result feature, so that you get suggestions after you type in a few letters. All those suggestions, as well as search results, need to be based purely on the database.
This could be a static website or based on any Content Management System, I'm familiar with Joomla, but was unable to find an out-of-the box component that would do just that. All those search modules search the entire website and I only need to search the database.
Probably I can help you with how to implement this feature. We used to call this feature as autocomplete menu.
First you decide minimum characters to populate autocomplete menu. For example 2
By using javascript you write keyup event. Once the characters count reaches to the minimum character count. You send AJAX request to the server.
The server should process this request and do the database search and form a json or xml response or plain text to the client.
The client parses that response into javascript object and construct a dynamic html for autocomplete menu with the data and render it into the DOM hence display's just below the search text box.
Now if you want to display the first result inside the textbox as you type. Here is the method I can suggest as similar as google search box
Place one label or span just below the input text box. By using css make its position exactly match with the position of the text box. Make sure the starting of text of both input text and label matches. Make the text color of the label less brighter than the font color of text. The font size and font family of the label should match the input text field's style. Now by using Javascript display the first or most matched text inside the label. Please find the sample code below
<!DOCTYPE html>
<head>
<style>
label {
position:relative;
}
body, input {
font-family: 'verdana';
font-size: 12px;
}
</style>
</head>
<html>
<body>
<form action="demo_form.asp">
<input type="text" name="fname" placeholder="Matched Text" /><br>
<label> Matched Text</label><br>
</form>
</body>
</html>
I am running an experiment in which we are trying to train people to be synaesthetes (they have additional experience of colour associated with numbers or letters).
I wondered if anyone has some advise about the easiest way to modify a web browser, such as firefox, so that just 10 letters A-J would always be displayed in a specific colour on any page they visited on the web?
Much appreciated
There are many ways to do this (cross-browser):
For example you could define a -element in a stylesheet to have a different color.
When loading the document, you check via JavaScript/jQuery the whole document (but only the contents of tags like ) for your specified letters and add the -tag f.e. around them.
Not the best solution, but a way.
Take a look at Greasemonkey, a FireFox plug-in designed to do this kind of thing. There are lots of pre-made scripts available at http://userscripts.org/, and several of them look like they'd help you figure out how to write your own to re-color single letters.
Here is just an abstract rough draft of a blueprinted preliminary form of a beta version of a potential solution: using the javascript: prefix of links in a bookmark as follow.
Create a new entry in your bookmarks toolbar
In the URL input, copy/paste the following line: javascript:var html = document.body.innerHTML; html = html.replace(/([a-j])/ig, '<span style="color: red;">$1</span>'); while(html.match(/(<[^>]*)<[^>]+>([^<]+)<\/[^>]+>([^>]*>)/g) != null) {html = html.replace(/(<[^>]*)<[^>]+>([^<]+)<\/[^>]+>([^>]*>)/g, '$1$2$3');} document.body.innerHTML = html;
Give your bookmark a name (e.g. "A-J to red") and save
You can now visit any website and click on that bookmark, which will put all letters between a and j in red
In a more digest way:
// get the content of the body
var html = document.body.innerHTML;
// surround any letter between a and j by a <span></span>
html = html.replace(/([a-j])/ig, '<span style="color: red;">$1</span>');
// but it also replaces a-j letters within html tags
while(html.match(/(<[^>]*)<[^>]+>([^<]+)<\/[^>]+>([^>]*>)/g) != null) {
// so if there are html tags within other html tags, delete the created <span></span>
html = html.replace(/(<[^>]*)<[^>]+>([^<]+)<\/[^>]+>([^>]*>)/g, '$1$2$3');
}
// and replace the innerHTML of the body
document.body.innerHTML = html;
That's really not a final solution, but yeah, maybe you could work on it to improve the results.
PS: don't try with IE...
In my WordPress blog, I have "Posted ? days ago" on every post. I have 10 posts on my homepage. So according to most keyword analysis tools, "days ago" is a top keyword on my blog, but I don't want it to be. How can I hide those words from search engines?
I don't want to use Javascript. I can easily use PHP and the $_SERVER variable, but I'm afraid I might get penalized for cloaking. Is there a HTML tag or an attribute like rel="nofollow" that I can use?
From Is there any way to have search engines not index a certain section of a page?
Supposedly you can add the class
robots-nocontent to elements on your
page, like this:
<div class="robots-nocontent">
<p>Ignore this stuff.</p>
</div>
Yahoo respects this, though I
don't know if other search engines
respect this. It appears Google is
not supporting this at this time.
I suspect if you load your content via
ajax you would get the same effect of
it not being present on the page.
and
There's no general way to do that and
personally I wouldn't bother with it.
Search engines are pretty good at
recognizing relevant content on a
page, and even though that content
might show up in the keywords that
search engines have found, it doesn't
mean that it would make the page
relevant for those keywords.
If you have a page about "Fish" and a
page about "Dogs" (that has the link
to the page about "Fish" somewhere in
the sidebar), search engines will
generally be able to recognize that
the page about "Fish" is much more
relevant for "Fish" than the page
about "Dogs" that mentions "Fish" in
the sidebar. It's possible that both
pages might be found at some point,
but generally given that mostly one
page from the site is shown in the
search results, that's not something
worth worrying about.
There's no need to be fancy with that,
and search engines are likely to just
get more confused if you try (eg if
you use JavaScript to hide the
content, you never know when search
engines will start to find that
content regardless). Similarly, using
iframes with robots.txt disallows or
AJAX will frequently degrade the
quality of your pages to users (slow
it down or make it less usable on a
variety of devices), so unless there
is a very, very strong & proven reason
that you need to do this, I would
strongly recommend not bothering with
it.
What I have found on wiki:
For Yandex:
<!--noindex-->Don't index this text.<!--/noindex-->
For Yahoo:
<div class="robots-nocontent">Don't index this text.</div>
For Google:
<!--googleoff: index--> Don't index this text.<!--googleon: index-->
Linksku, I'm fairly sure you shouldn't be worried about that particular piece of text. Our algorithms do a relatively good job detecting boilerplate text. As far as I can tell from your question, this text is boilerplate and we likely already know that.
As for detecting Googlebot and don't serving this text for it, you're right, that would be cloaking and you should never do it. In this case if you hide that text from us, we will also have a hard time detecting it's boilerplate and you would end up doing exactly what you're trying to avoid :)
I worked this out and posted it up at: http://www.scivillage.com/thread-2580.html
This should work, however more testing of it and feedback would be appreciated.
.x:before{
content:attr(title);
display:inline;
}
<ul>
<li><span class="x" title="Homepage"></span></li>
<li><span class="x" title="Contact" /></li>
</ul>
(I kept the class name short to reduce mark-up creep)
The search engines should ignore HTML tags with empty values when comes to looking for keywords, this should mean that it ignores what is written in the title attribute. (It assumes that the value is what's important, if it's empty then there is no point checking the attributes)
It was suggested that it's possible to negate having the closing tag in HTML5 due reduced strictness, however there is counter suggestions that end tags are still required.
I'd suggest not using it directly on a (anchor) tags since they can be used for sitemaps (using #), so it's means they would like have the Title spidered.
Although it is possible that it might assume any title content is there to inflate keywords through hidden elements, however I can not confirm this.
To exclude specific text from Google search results you can add data-nosnippet attribute.
https://developers.google.com/search/reference/robots_meta_tag#data-nosnippet-attr
From google documentation
You can also prevent certain parts of the page text content from being shown in a snippet by using data-nosnippet.
HTML:
<div class="hasHiddenText">_</div>
It is important that you leave a non-whitespace character between the element with a hidden text.
External CSS:
.hasHiddenText{
content: "Your hidden text here...";
/*This ovewrites the default content of the div but it isn't supported by all browsers.*/
}
.hasHiddenText::before{
content: " Your hidden text here...";
/*Places a hidden text above the div.*/
}
The "hidden text" pertains to content hidden to all search engines but visible to visitors.
You can also use nextline and all sorts of Unicode characters by escaping them with \uXXXX. To display linebreak characters correctly, be sure to add the
white-space:pre-line;
property.