-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
344d71d
commit f078689
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<script total> | ||
|
||
exports.name = 'String Operation'; | ||
exports.icon = 'ti ti-code'; | ||
exports.author = 'Total.js'; | ||
exports.version = '1'; | ||
exports.group = 'Common'; | ||
exports.config = { operation: 'lowercase' }; | ||
exports.inputs = [{ id: 'input', name: 'Input' }]; | ||
exports.outputs = [{ id: 'output', name: 'Output' }]; | ||
|
||
exports.make = function(instance, config) { | ||
|
||
instance.message = function($) { | ||
var data = $.data; | ||
var output; | ||
switch(config.operation) { | ||
case 'lowercase': | ||
output = data.toLowerCase(); | ||
$.send('output', output); | ||
break; | ||
case 'uppercase': | ||
output = data.toUpperCase(); | ||
$.send('output', output); | ||
break; | ||
case 'capitalize': | ||
output = data.capitalize(); | ||
$.send('output', output); | ||
break; | ||
case 'slug': | ||
output = data.slug(); | ||
$.send('output', output); | ||
break; | ||
case 'deburr': | ||
output = data.toASCII(); | ||
$.send('output', output); | ||
break; | ||
case 'reverse': | ||
output = data.split('').reverse().join(''); | ||
$.send('output', output); | ||
break; | ||
case 'spaces': | ||
output = data.replace(/|s/g, ''); | ||
$.send('output', output); | ||
break; | ||
case 'trim': | ||
output = data.trim(); | ||
$.send('output', output); | ||
break; | ||
} | ||
}; | ||
|
||
instance.configure = function() { | ||
if (!config.operation) | ||
config.operation = 'lowercase'; | ||
}; | ||
|
||
instance.configure(); | ||
|
||
}; | ||
|
||
</script> | ||
|
||
<readme> | ||
This components can apply string operation to your components. | ||
## input | ||
- String | ||
|
||
## output | ||
- String | ||
|
||
## Available operations are: | ||
- Lower case. | ||
- Upper case. | ||
- Capitalize. | ||
- Slug Remove diacritic | ||
- Reverse | ||
- Remove spaces | ||
- Trim | ||
|
||
</readme> | ||
|
||
<settings> | ||
<div class="padding"> | ||
<div class="grid-2"> | ||
<div> | ||
<ui-component name="input" path="?.operation" config="type:select;dirsource:capitalize|Capitalize,lowercase|Lower Case,uppercase|Upper Case,slug|Slug,deburr|Remove diacritic,reverse|Reverse,spaces|Remove spaces" >Select operation</ui-component> | ||
</div> | ||
</div> | ||
</div> | ||
</settings> | ||
|
||
<style> | ||
.CLASS footer { font-size: 12px; padding: 10px; font-weight: bold;} | ||
.CLASS footer span { float: right } | ||
.CLASS footer span i { font-size: 12px } | ||
</style> | ||
<body> | ||
<header> | ||
<i class="ICON"></i>NAME | ||
</header> | ||
<footer> | ||
<ui-bind path="CONFIG.operation" config="show"> | ||
Operation: <span class="blue" > <ui-bind path="CONFIG.operation" config="text:value.charAt(0).toUpperCase() + value.slice(1)"></ui-bind> </span> | ||
</ui-bind> | ||
</footer> | ||
</body> |