placehold.it print non-English words - javascript

The link below will print "hello world" on a place holder image provided by http://placehold.it
http://placehold.it/200&text=hello+world
Is it possible to print non-English words on it, say Chinese or Japanese? If it cannot, are there any service available to do so?

You can create images printed non-English words. See here.
Here is such a sample.

The place holder images can be easily emulated by a div with the same size (set in .css). I then can add any text on it.

Related

How to render emoji by entring symbol through text input in div block

I am developing social networking application using angular technology
I used CKEditor for creating posts and created a separate emoji function
Image to create new post
Render page
I couldn't find the way to convert symbols ;) :( :) to emojis in HTML div tag
If anyone knows please let me guide on it
Thanks
If I understand your question clearly, you want to display emoticons on the webpage when users enter their symbol in the textarea.
This can be done using an inbuilt text editor plugin like TinyMCE.
But if you want to try the native way, the simple funda here is:
These emoticon characters are available as Unicode decimal or hexadecimal codepoints when used with UTF-8, a default charset used on webpages.
To get a list of smileys hexadecimal code points, refer to this:
https://www.unicode.org/charts/PDF/U1F600.pdf
To display any special character on the webpage, we use '&#x<hexa_code_point>' or '&#<dec_code_point>'.
For eg,
πŸ™‚ = πŸ™‚
&#x1F612 = πŸ˜’
&#x1F634 = 😴
so you will need a map between a string entered in your textarea and this code.
For eg,
{
':|': "1F610"
}
and then corresponding to that code point, we can display smiley.
For reference,
https://codesandbox.io/s/vibrant-lehmann-ibvncy?file=/index.html
The new ckeditor emoji plugin allows you to add emoji. It also auto detectsband filter the relevant emoji based on keywords. e.g.
:thumbs_up
Add the following line to your congiurations:
config.emoji_emojiListUrl
And the following link contains demo
https://ckeditor.com/docs/ckeditor4/latest/examples/mentions.html

Replace Emoji with image while preserving it as an Emoji

I'd like to replace Emojis on my website with custom images. That itself would not be a problem in PHP:
$string = "This is a laughing emoji πŸ˜‚";
echo str_replace($string, "πŸ˜‚", ":'D"); //or replace with an image
However, how do I manage that if someone copies the text, they will be able to copy the text with the emoji and not the replaced image? Like keeping the char πŸ˜‚ πŸ˜‚ but only changing the outcome so they will look the same for every user. Is that even possible at all?
One way to do this would be to replace the emoji with an <img> image tag, but set the alt attribute of the image to the original emoji. Then, if the result is copied somewhere that only accepts text, the alt text will be used.
"Run" this snippet to see an example:
Hello <img alt="πŸ˜€" src="data:image/png;base64,R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMlWLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7"> world!
<br/>
<textarea cols="25" rows="3">Paste here</textarea>
The emoji between the two words will look like a Gmail emoji, until you copy the entire line of text somewhere.
Of course, you can use a normal URL instead of a data: URL.
No, each system has its own sets of fonts ( including emojis ) which is why they appear different on android vs iOS. The only way you would be able to add something would be outside of the system typeface, i.e. icon sets. You could either include images or links to images.
<img src="imageLocation" alt="altTextorImage">

Javascript, lines too long in text editor

50 years old, don't have time to spend 6 months learning JavaScript just to do one thing. Comments indicate question too verbose. 1 Found code for blocking JavaScript auto refreshing on a forum. 2 Did web search. 3 Don't know anything about JavaScript. 4 Found conflicting/confusing information. 5 Needed further explanation. The following is the code :
user_pref("capability.policy.policynames", "reload");
user_pref("capability.policy.reload.Location.reload", "noAccess");
user_pref("capability.policy.reload.sites", "http://www.drudgereport.com http://news.yahoo.com");
To add more sites, you simply placed the new site URL into the "" quoted text, making sure to have a space between the URLS. 1. That string could stretch to 100's/1000's of characters. 2. Would look ugly/require scrolling text editor window for days to check for spaces.
Just wanting the code to look good and be able to see everything in the text editor on the code itself (without breaking script execution). Do I just hit enter around the 80 character mark (say after one of the URLS) or do I want to use the \n for a line break?
Thanks for that answer Blender. Not trying to be contentious, didn't know stackoverflow was at a premium for words, edited for brevity. 4 short paragraphs + short code snippet. Hope that is brief enough, can't think of much way to shorten. Out.
You can put them into an array:
var websites = [
'http://www.drudgereport.com',
'http://news.yahoo.com',
...
];
And then join them together to form your string:
user_pref("capability.policy.reload.sites", websites.join(' '));
Or all at once:
user_pref("capability.policy.reload.sites", [
'http://www.drudgereport.com',
'http://news.yahoo.com',
...
].join(' '));
user_pref("capability.policy.policynames", "reload");
user_pref("capability.policy.reload.Location.reload", "noAccess");
user_pref("capability.policy.reload.sites", "http://www.drudgereport.com http://news.yahoo.com");
why not just use word wrap if using Notepad++?
Select β€œView” from menu bar.
From the dropdown menu that appears click on β€œWord wrap” option.
The same procedure is used to swap between Word wrap On & Off.

Multiple character replacements in JS - how to stop replacements on previous results within the same function

I have a ( probably very unclean) script that I intend to convert letters put into a text field into html image tags with corresponding pathways. I know there are probably easier ways of doing this, PHP for example however I am using it as a bit of an experiment to familiarise myself further with JS/Jquery. I have overcome a few obsticles to get where I am now as most of this is new ground for me.
In some cases the letters will have multiple images associated with them that will be selected at random so there are a couple of lines included which do this. These are fine however, the issue comes with the section of code that replaces the letters from the text field with the text and variables that make up the image tag. Whilst they work fine individually, when I want to convert multiple letters the replace overwrites instances of that letter in the previously generated image tag. Any ideas can I stop this? I've tried shifting the points at which the script occurs around but it seems the whole thing is somewhat fragile and haven't been able to create a workable solution.
Code in question:
// replace all instances within variable to generate thumbs
final_result = result.replace(/a/g, str_start+chosen_folder+"a"+random_variation+str_end)
.replace(/e/g, str_start+chosen_folder+"e"+random_variation+str_end);
JS Fiddle here: http://jsfiddle.net/N77wZ/
Many thanks in advance !
Do only a single replace:
final_result = result.replace(/a|e/g, str_start+chosen_folder+"$&"+random_variation+str_end);

How to find the index of a praticular word in the whole sentence

i want to find a text named "footer= XXX" in a text document and replace the XXX with my own value. The problem here is that this footer value repeats in lot of areas in the document with different values assigned to it. Any idea of how to do it?
str.replace(/footer=(.*?)\s/g, 'footer=whatever');
See it on jsFiddle.
You didn't mention what the end delimiter is, so I used white space. You may want to use a word boundary (\b).

Categories