How does Stack Overflow display tooltip for the questions? - tooltip

While we ask a question, SO shows related questions. If we hover on the questions the content is displayed as a tooltip which contains linebreaks, indentations etc. What technique SO uses for it? How to display tooltips wit the formatting?
Other than, jquery/javascript is there any simple way to achieve it?
Was just wondering, should i ask this on Meta?

It is just a title attribute on the hyperlink, plain and simple.
<a href="..." title="The value is approximately
3.14159265
but for simplicity you can always round it
to exactly 3.0">What is the value of Pi?</a>
In IE, Chrome & Safari, it honors the line breaks a bit more strictly than say Firefox or Opera.

I took this html actually from stackoverflow. Here is no magic here:
Here's a dumb question which I can't find an answer to:
I have a table which contains 20 fields, a few of which are date/time. I am interested in pulling all the fields. I would like to … ">Selecting fields in SQL Select statements (Dumbest SQL Question)</a>
As you see, title can have line breaks!

Related

Show just a sample of text in search results

I'm using ReactiveSearch (great Search UI library!) and am trying to figure out how I can just show a ample of a text article in the ReactiveList search results. Currently it shows the whole article but I just want the first 250 words or so to be displayed.
I just want say the first 250 words of that. Is that possible with ReactiveList? If so, how can I go about doing that or is there a feature o setting that I'm missing with ReactiveSearch?
This is the simple line that displays it currently:
<p className="card-text">{data.Text}</p>
It is possible to truncate the text after a few lines. But ReactiveSearch doesn't support this feature on the library level.
You can achieve this by using the package called react-truncate. You can read the documentation here.
Hope this helps!

Crystal Reports 11 - Remove HTML format on a Memo field

Using Crystal Reports 11, I want to report on the number of characters within a memo field. The problem is that it is feeding through HTML from the System.
I want to remove all text that is within "<" and ">" and am having some problems doing this.
I guessed that my best way of doing this was a Replace formula, but it only seems to allow specific characters or group of characters to be replaced. I tried the following:
Replace ({Field_Name},"","")
Basically I want to be able to remove all text within the "<>" symbols to then be able to view the remaining data.
I know that there is an option to format the field with HTML which will then display only the text, but when a count is done on the field, it still includes the HTML text in the character count.
Any help wouldbe great.
Thanks
Dave
After struggling for # a wk. to try to remove HTML from my emails, I decided to go into system restore and went back to a date when I thought this had happened (a wk) and voila - gone! Nada! No HTML! Problem solved so easily.

Sanitize pasted text from MS-Word

Here's my wild and whacky psuedo-code. Anyone know how to make this real?
Background:
This dynamic content comes from a ckeditor. And a lot of folks paste Microsoft Word content in it. No worries, if I just call the attribute untouched it loads pretty. But the catch is that I want it to be just 125 characters abbreviated. When I add truncation to it, then all of the Microsoft Word scripts start popping up. Then I added simple_format, and sanitize, and truncate, and even made my controller start spotting out specific variables that MS would make and gsub them out. But there's too many of them, and it seems like an awfully messy way to accomplish this. Thus so! Realizing that by itself, its clean. I thought, why not just slice it. However, the microsoft word text becomes blank but still holds its numbered position in the string. So I came up with this (probably awful) solution below.
It's in three steps.
When the text parses, it doesn't display any of the MSWord junk. But that text still holds a number position in a slice statement. So I want to use a regexp to find the first actual character.
Take that character and find out what its numbered position is in the total string.
Use a slice statement to cut it from.
def about_us_truncated
x = self.about_us.find.first(regExp representing first actual character)
x.charCount = y
self.about_us[y..125]
end
The only other idea i got, is a regex statement that allows it to explicitly slice only actual characters like so :
about_us([a-zA-Z][0..125]) , but that is definately not how it is written.
Here is some sample text of MS Word junk :
&Lt;! [If Gte Mso 9]>&Lt;Xml>&Lt;Br /> &Lt;O:Office Document Settings>&Lt;Br /> &Lt;O:Allow Png/>&Lt;Br /> &Lt;/O:Off...
You haven't provided much information to go off of, but don't be too leery of trying to build this regex on your own before you seek help...
Take your sample text and paste it in Rubular in the test string area and start building your regex. It has a great quick reference at the bottom.
Stumbled across this
http://gist.github.com/139987
it looks like it requires the sanitize gem.
This is technically not a straight answer, but it seems like the best possible one you can find.
In order to prevent MS Word, you should be using CK Editor's built-in MS word sanitizer. This is because writing regex for it can be very complicated and you can very easily break tags in half and destroy your site with it.
What I did as a workaround, is I did a force paste as plain text in the CK Editor.

Grails - How to format a value in a textfield into comma style such that it can be easily read?

I want to allow users enter numbers in textfield and once the textbox loses focus. The number is formatted with commas.
e.g. User enters 100000
textfield looses focus
value displayed: 100,000
How can I achieve this in Grails.
I have looked at
<g:formatNumber number="${myNumber}" format="\\$###,##0" />
But it doesnt solve my problem as the number is from a textfield.
thanks
Much appreciated.
Well, you have to understand the difference between code that is executed on the server-side vs. client-side scripting. Your requirement "once the textbox loses focus" just can't be met by Grails, because detecting focus loss of DOM elements and reacting to it happens entierely in the user's browser. You will have to do this in JavaScript (which isn't a big deal either). For example these two jQuery plugins should do the trick (but there are plenty of other solutions, also for other JS libraries).

How does one change the text on the clipboard without altering the format information?

Another clipboard question:
When text is put onto the clipboard, it frequently goes in multiple ways, usually with and without formatting information. What I want to know is this -- how do you change the text on the clipboard without altering the formatting. In other words, I want to change the text side of things, but keep the formatting exactly the same.
This is again for my "TextScrubber" application where I want to remove line breaks from the text on the clipboard, but I don't want to alter the format info about that text.
I'm hoping that I don't have to "brute force" it by iterating over all the formats present, storing each, and then reinserting them after the text has been scrubbed.
I think the "brute force" is precisely what you'll have to do - according to MSDN Win32 API there is no way to do otherwise.
Yep, Nick. I think in this case you're going to be stuck with the solution already suggested. The clipboard is one area that hasn't really gotten much attention in the enhancement department throughout the years. That is probably because it does need to be simple, ubiquitous, and functional.
Why not simply load from the clipboard, change the text, and write back to the clipboard?
Maybe something simple like Sergey Tkachenko's TBin Clipboard: http://delphi32.org/vcl/2889/
Eric Rosenberger's answer to "Can not round trip html format to clipboard" might also be of use.

Resources