Category Archives: Miscelaneous

Open API, HTML5 Widgets, Improved Search, Session Caching and Favorites Bar for ElevenRack.net

During the last couple of days I worked hard on some new features for elevenrack.net, which I hope will improve the user experience of the website and will drive more visitors and users. I am happy to share the latest additions today.

Improved Search

The search functionality now supports search by letter, artist and preset title. Search by author is also on my list.

search

The visibility of the search bar could be toggled by clicking the loupe icon in the navigation bar:

search-toggle-cursor

Embeddable HTML5 Widget

If you like elevenrack.net and want to support it (I’d really appreciate that) and a really cool way, you are now able to embed preset widgets on your website just by registering widget’s HTML5 Web Component runtime and adding a simple tag to your website.

widget-1

widget-2

Favorites Bar

Found a preset you love? Click the star icon next to the page title to store it in your very own favorites bar.

fav-2

To manage your favorites, click the star icon in the navigation bar.

fav-5

To remove a favorite – either click the “x” icon in the favorites popup or the yellow star icon to the right of the page title.

fav-3

fav-4

Session Caching

Visited pages are now cached client-side during the session and loading them from the cache is at lightning speed.

Presets API

The JSON(P) data for all presets currently on the website is accessible via the REST API.

Have a great week, and thanks for stopping by!

 

Syntax Highlighter HTML5 Web Component Based on Lea Verou’s Prism.JS

AcidJs.XHilite is a syntax highlighter HTML5 Web Component, based on Lea Verou‘s Prism.JS and wrapped as a custom tag with support for multiple languages and both declarative and async loading of the code to be highlighted.

Usage:

<acidjs-xhilite language="javascript" height="200" width="400">
function sayHi() {
    return "Hello, World!";
}
sayHi();
</acidjs-xhilite>

Recently I my HTML5, CSS3 and JavaScript Experiments website received a major facelift and as a next step and I am planning to replace the syntax highlighter I am currently using with AcidJs.XHilite.

HTML Attributes of the Tag

Any native HTML attribute (id, class, data-*, style, etc.) is supported, plus the component-specific:

  • language – The language to highlight, for example language="javascript". Default: "markup" (usable with HTML, SVG, XML, etc.). Check prismjs.com for a complete list of supported languages.
  • width – Optional width in pixels of the code block, for example: width="600".
  • height – Optional height in pixels of the code block, for example: height="200".
  • src – Instead of adding the code to highlight in the tag, you can specify path to the file which content needs to be highlighted, for example: src="example.js"

JavaScript Methods of the Tag

Native JavaScript methods (document.getElementById, document.querySelector, etc. as well as their jQuery or other libraries aliases).

Check the screenshots below or go straight to the demo and download:

x-hilite-markup

x-hilite-javascript

x-hilite-svg

x-hilite-css

x-hilite-php

x-hilite-svg

x-hilite-java

x-hilite-csharp

Check the demo on this page. You will also find a download link there. If you share the same interest towards HTML5 Web Components as I do these days, make sure you read my relevant blog posts and further endeavors on my HTML5, CSS3 and JavaScript Experiments and Insight website.

Hiding Emails from Spam Bots: The CSS3 Way

Hiding emails from spam bots can be really painful, but fortunately there are a lot of cool solutions out there. Here’s how you can do this with the CSS3 generated content and reversed text direction.

Let’s say that email you want to obfuscate is info@company.com. The first thing you need to do it to reverse it, so it looks like this: moc.ynapmoc@ofni. For instance, you can do this online here. The rest is CSS:

  • In your style sheets, create a new .contact rule.
  • Add the reversed string as value of the content property of your .contact rule.
  • Set the direction of the text as right to left via direction and unicode-bidi.
  • Use the .contact element in your markup.

The CSS

.contact::before
{
    content: "moc.ynapmoc@ofni";
    direction: rtl;
    unicode-bidi: bidi-override;
    text-decoration: underline;
    color: #00f;
}

The Markup

<p>To contact us, send an email
to <span class="contact"></span>.</p>

… And everything will look just right when you view it in the browser:

email

The drawback of this approach is that CSS3 generated content cannot be selected and copied, which is a usability issue, but this is just an idea and there are many other solutions worth trying.

One small consideration, regarding the syntax of generated content. Older browsers do not recognize the ::before or ::after double column syntax, so you may want to consider using :before / :after. Since this is just syntactical enhancement to distinguish pseudo elements (hover, active, etc) from generated content (before, after), introduced in CSS3, newer browsers understand both syntaxes, so  you can use the “old” syntax without concern.

Related Posts and Links

Checking if String is a Palindrome with JavaScript

A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction. It is not uncommon to be asked to write a JavaScript function that checks if a string is a palindrome on front-end developer position interview.

Here’s one possible solution, utilizing a few JavaScript array methods (split(), reverse() and join()). Of course, if you don’t want to get that sophisticated, a simple one-line solution can be easily extracted from the class.

Merry Christmas! Find more front-end experiments and insight here.

Related Posts and Links