A custom tabs component with route ready for templates and controllers: no more manually routing - everything is done within the html tags!
Usage:
1). Just insert a "Routed-Tab" tag;
2). include "RoutedTab.js";
3). import "Coolshare" module.
Demo:
Try it here
4. ActionLink
Description: The directive can be used to control other DOM components. It can be used as a "html level controller". See how it "glues" ChatSpeak and YoutubeSearcher
Dependency:
- jquery.min.js
- angular.min.js
Usage:
Just add attribute "action-Link" to any DOM component and assign a control command to attribute "action-Link".
A command consists of a series fields divided by "|": [targetId]|[action]|[additionalValue]
Current following commands are supported:
- append - appends the text of this element to the target element's original text. For example, <p active-Link="InputA|append">Text to be appened</p>. This will insert text "Text to be appened" to the end of "InputA"'s content
- prepend - prepends the text of this element to the target element's original text. For example, <p active-Link="InputA|prepend">Text to be prepend</p>. This will insert text "Text to be prepend" to the beginning of "InputA"'s content
- replace - replaces the text of this element to the target element's original text. For example, <p active-Link="InputA|replace">Text to be replace</p>. This will place text "Text to be replace" to replace of "InputA"'s content
- selectValue - selects the text of this element as option value on the target element (a select tag). For example, <p active-Link="SelectA|selectValue">California</p>. This will select the option with value as "California". You can specify a third field for value to match instead of using the text of current element.
- selectLabel - selects the text of this element as option label on the target element (a select tag). For example, <p active-Link="SelectA|selectLabel">California</p>. This will select the option with label as "California". You can specify a third field for label to match instead of using the text of current element.
- addOption - add an option to a select element. For example, <p active-Link="SelectA|addOption|Florida">State of Florida</p>. This will add an option with "Florida" as value and "State of Florida" as label. You can also specify label as the forth field.
Multiple actions can be chained into a single action link. For example,
<span action-Link="inputA|replace,alertInput|click">Place me into the input field and alert</span>
will first replace the content in inputA with "Place me into the input field and alert" and then do a click at element "alertInout".
The third field is used the "specified source value" meaning the ActionLink will use the content in this field instead of the content in current element in case the third field is not empty.
For example, <div action-Link="input_chatSpeak0|replace|IM1vss7FXs8">Florida</div>
will use "IM1vss7FXs8" to replace content of element with id "input_chatSpeak0" instead of using "Florida"
The forth field is used the "specified source id" meaning the ActionLink will use the content as the id to find "the source value element". Then it will use the content of "the source value element" instead of the content in current element in case the forth field is not empty.
For example, <div action-Link="input_chatSpeak0|replace||vimg_YoutubeSearcher0">Florida</div>
will use the content of element with id as "vimg_YoutubeSearcher0" to replace content of element with id "input_chatSpeak0" instead of using "Florida"
Demo:
Try it here
5. YoutubeSearcher
Description: The directive allows users to search Youtube and play the results
Dependency:
- jquery.min.js
- angular.min.js
- Node.js Server - Server is basically for JSON-P and hiding Google API ID
Usage:
Just add a "youtube-Searcher" tag anywhere on your page. Supported attributes:
- play - the selected video will be played if set to true, otherwise nothing happen after selection. In some case, you may not want to set it to true. Here is one example in ChatSpeak
- autostart - The value of attribute "autostart" will be used as a starting criteria so that a search result is ready initially.
The directive also store selected title in to a hidden field with id vtitle_[DirectiveId] and selected thumbnail image url in vimg_[DirectiveId] to make integration with other directives easier.
Demo:
Try it here
6. TextSpeak
Description: The directive "speaks" the content of target DOM element as users mouse over those DOM elements with "text-Speak" attribute.
Dependency:
- jquery.min.js
- angular.min.js
- a Backend Node.js web server that fetches url of mp3 from google
Usage:
The restriction is AEC. Simply add an attribute into any HTML tag to speak the content in the tag. For example,
Demo:
Try it here
7. MediaDetailer
Description: The directive can be used to show more details and it can also "speaks" out the details too! The details it can display include text, audio and video. One very useful feature is that you can
use any DOM component as the "detail" by setting the id of the DOM component to "mediaDetailer_XXX", where "XXX" is the id of header/anchor component.
Dependency:
- jquery.min.js
- angular.min.js
- a Backend Node.js web server that fetches url of mp3 from google
Usage:
The restriction is AEC. For example, just add "media-Detailer" to a text container element such as p or div. Then inside the container element,
place a div with class as "mediaDetailDiv" containing the details you like to show. You can do something with the attribute "media-Detailer":
- Assign nothing to it - this setting will show a "Show Details" button and the details will be displayed as it is clicked.
- Assign "SpeechOn" to it - this setting will show a "Show Details" button and the details will be displayed and the content of details will be speaked out as it is clicked.
- Assign "SpeechOn|textOff" to it - this setting will show a "Listen to Details" button and nothing will be displayed but the content of details will be speaked out as it is clicked.
- Assign "SpeechOn|textOff" to it and point to a audio url - this setting will show a "Listen to Details" button and nothing will be displayed but assigned url will be played out as it is clicked.
- Assign "SpeechOn|textOff" to it and point to a video url - this setting will show a "Show to Video" button and nothing will be displayed but assigned video url will be played out as it is clicked.
The video attribute contains two parts: the first part is a video type (mp4 or youtube) and the other part is the url of video. "|" is used to separate those two parts.
- Assign "noButton" to remove the "Show Details" button
- Assign "hoverShow" to show detail as mouse hover the header
- Assign "underline" to set underline to the header
- Assign "moveDetail" to move the DOM as detail to popup instead of cloning it
You can also change the button label using attribute "detailLabel" like
<div media-Detailer="speechOn|textOff" detailLabel="Answer"> [Your header Text]
<div class="mediaDetailerDiv">[Your Detail Text]</div>
</div>
The directive also have two hidden fields, vtitle_[DirectiveId] and vimg_[DirectiveId]. The chat will use the content store in these two field as additional info (the title and thumbnail image) to be broadcasted. This is specially useful as you want to integrate ChatSpeak with other directives.
Demo:
Try it here
8. DomFun
Description: Animation sometimes is the best way to catch visitor's attention. This directive provides a variety of text animation.
Dependency:
- jquery.min.js
- angular.min.js
Usage:
Just add attribute "dom-Fun" to a div containing the text to be animated.
The content of "dom-Fun" can be a "json" like string: <div dom-Fun="{'action':'wave','trigger':'mousemove','parseTo':'char'}">
- action - this field could be one of following: float, wave
- trigger - events that trigger the animation. This field can container more than one events divided by comma. For example, 'trigger':'click,keydown'
- parseTo - parse level: char or word
Demo:
Try it here
The Problems:
- 1). Google TTS only support speach text with under 100 characters-length. Any text excess 100 will be ignored.
- 2). Google TTS API accepts only http GET meaning your text size can not excess the size limitation of GET (Most webservers have a limit of 8192 bytes)
- 3). You won't be able to invoke a http GET from your page since it is "Crossing Domain"
- 4). I used Node.js as my server to acheive a solution to all problems list above.
The Node.js is used in the server side to handle text process but Node.js is a single thread server. What if you send a huge size text over: will the huge size request mess up other requests in the single thread?
The Solutions:
- 1). Like many others, I divided any text longer than 100 characters into pieces with length less than 100. Then send these pieces to Google and archive the response from Google (mp3 streams) them into files in my server. A list of file urls is return to my client and client plays one url after another.
- 2) & 3). I used JSONP resolve both issue 2) and 3). With JSONP you can send a configurable size of "script"(your speach text) (see details at maxJsonLength property) and of course, crossing domain.
- 4). I used multi-threading to handle the huge text pieces. Since my node server knows how big is the text received so I chose to use Backgrounder instead of Cluster because in many case like chating, I don't even need multi-threading
Dig into
source