Comparing version
@@ -25,2 +25,3 @@ #!/usr/bin/env node | ||
var join = string.join; | ||
var isSubString = string.isSubString; | ||
@@ -125,23 +126,20 @@ | ||
if(_attr == "id"){ | ||
var oldId = $(element).attr().id; | ||
if(!oldId) oldId = ""; | ||
$(element).attr(_attr, attrValue + " " + oldId); | ||
if(!oldId) oldId = ""; | ||
else oldId = " " + oldId; | ||
if(!isSubString(oldId, attrValue)) $(element).attr(_attr, attrValue + oldId); | ||
else $(element).attr(_attr, attrValue); | ||
} else if(_attr == "class") { | ||
var oldClass = $(element).attr().class; | ||
if(!oldClass) oldClass = ""; | ||
$(element).attr(_attr, attrValue + " " + oldClass ); | ||
else oldClass = " " + oldClass; | ||
if(!isSubString(oldClass, attrValue)) $(element).attr(_attr, attrValue + oldClass ); | ||
else $(element).attr(_attr, attrValue); | ||
} else if(_attr == "style"){ | ||
var _, propertyName, propertyValue; | ||
attrValue.forEach(function(e){ | ||
_ = lSplit(e, ':'); | ||
propertyName = _[0]; | ||
propertyValue = lSplit(_[1], ';')[0]; | ||
$(element).css(propertyName, propertyValue); | ||
}) | ||
var oldstyle = $(element).attr().style; | ||
var newStyle = join(' ', attrValue); | ||
if(!oldstyle) oldstyle = ""; | ||
if(!isSubString(oldstyle, newStyle)) $(element).attr('style', oldstyle + " " + newStyle); | ||
else $(element).attr('style', oldstyle); | ||
} else{ | ||
@@ -148,0 +146,0 @@ $(element).attr( _attr, attrValue ); |
{ | ||
"name": "l-string", | ||
"version": "1.0.47", | ||
"version": "1.0.48", | ||
"description": "this is a module that you can use to manipulate strings ... ", | ||
"main": "./l-string.js", | ||
"directories": { | ||
"test": "tests", | ||
"bin": "bin" | ||
"test": "tests" | ||
}, | ||
@@ -25,10 +24,12 @@ "engines": { | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"lib/*", | ||
"README.md", | ||
"tests/", | ||
"l-string.js" | ||
"AUTHORS.md", | ||
"CONTRIBUTORS.md", | ||
"LICENSE", | ||
"tests/*", | ||
"./l-string.js" | ||
], | ||
"scripts": { | ||
"test-legacy": "node ./tests/test.js" | ||
"test": "node ./tests/test.js && node ./tests/read_html_file/index.js" | ||
}, | ||
@@ -41,2 +42,6 @@ "keywords": [ | ||
"S", | ||
"html", | ||
"css", | ||
"id", | ||
"html helper", | ||
"String", | ||
@@ -58,4 +63,4 @@ "ASCII", | ||
"dependencies": { | ||
"cheerio": "^0.20.0" | ||
"cheerio": "^0.22.0" | ||
} | ||
} |
206
README.md
**l-string** :thumbsup: :trollface: [](https://travis-ci.org/leoxnidas/l-string) [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BQKLKSBKH4DPE) | ||
============ | ||
**This library was specially created to extend the javascript's string object.** | ||
**This library was specially created to extend the javascript's string object. Both, server side and client side.** | ||
Install | ||
------- | ||
```npm install l-string or npm install --save l-string ``` | ||
```npm install l-string or npm install --save l-string ``` or ```yarn add l-string``` | ||
Usage, Server Side. | ||
------------------ | ||
Usage. | ||
------ | ||
```javascript | ||
@@ -33,3 +31,2 @@ require("l-string"); | ||
console.log("leo ".rReplace("eo", "1231")) | ||
@@ -46,193 +43,12 @@ console.log("leo ".join("-")) | ||
Usage, client Side. | ||
------------------ | ||
if you dont have browserify installed, and you are using linux, | ||
copy this at the command shell ==> ```./node_modules/l-string/bin/make-l-string.web```, | ||
otherwise, copy this ==> ```sudo npm install -g browserify``` | ||
then, write this ```browserify -r l-string:l-string.web > l-string.web.js``` | ||
then... | ||
```html | ||
<script src="./l-string.web.js"></script> // add this tag to the html file. | ||
``` | ||
Then, in your js file, write code... | ||
```javascript | ||
(function(){ | ||
require("l-string.web"); | ||
alert("leo".multiply(10)); | ||
})(); | ||
``` | ||
:trollface: :trollface: :trollface: | ||
functions that l-string.web does not support. | ||
--------------------------------------------- | ||
- [X] escape | ||
- [X] removeTag | ||
- [X] addAttr2Tag | ||
- [X] addStyle2Tag | ||
- [X] addClassName2Tag | ||
- [X] addIdName2Tag | ||
LICENSE. | ||
License. | ||
-------- | ||
[License MIT](./LICENSE) | ||
(The MIT License) | ||
Changelogs | ||
---------- | ||
[Changelogs](./CHANGELOGS.md) | ||
Copyright (C) 2015-2017 Leonardo Esparis <leo.leo.leoxnidas.c.14@gmail.com>. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
Version 1.0.47. | ||
--------------- | ||
- test.js file updated. | ||
- ord function now shall Returns string's ASCII value of every element | ||
- changin ASCII.js to _ASCII.js filename | ||
Version 1.0.46. | ||
--------------- | ||
- updating .travis.yml. | ||
- updating cheerio dependencies. | ||
- updating examples. | ||
Version 1.0.45. | ||
--------------- | ||
- extending the ASCII table. | ||
Version 1.0.44. | ||
--------------- | ||
- new function added, chr. | ||
Version 1.0.43. | ||
--------------- | ||
- new function added, ord. | ||
- new file added, ASCII. | ||
- fixed issues in getCharPosition function | ||
Version 1.0.42. | ||
--------------- | ||
- fixed issues in smartCount function. | ||
- new private function added, called _find_letter_position | ||
Version 1.0.41. | ||
--------------- | ||
- new function added smartCount. | ||
- new function isSubString changed. | ||
- new file added, utils.js. | ||
- old name _parse_tag, new name _parse_char (renamed), private function. | ||
- addstyle2tag improved the function. | ||
Version 1.0.40. | ||
--------------- | ||
- donate botton added. | ||
Version 1.0.39. | ||
--------------- | ||
- New project description. | ||
Version 1.0.38. | ||
--------------- | ||
- lReplace error fixed. | ||
Version 1.0.37. | ||
--------------- | ||
- dummycount error fixed. | ||
Version 1.0.36. | ||
--------------- | ||
- bin file added, make-l-string.web. | ||
- README.md style fixed. | ||
Version 1.0.35. | ||
--------------- | ||
- more keywords added. | ||
- error at method addIdName2Tag and addAttr2Tag fixed. | ||
- README.md style fixed. | ||
Version 1.0.34. | ||
--------------- | ||
- error at method addStyle2Tag fixed. | ||
- README.md style fixed | ||
Version 1.0.33. | ||
--------------- | ||
- error at method add2TagClassName fixed. | ||
- README.md style fixed. | ||
Version 1.0.32. | ||
--------------- | ||
- new html example added. | ||
- README.md style fixed. | ||
Version 1.0.31. | ||
--------------- | ||
- README.md style fixed. | ||
- html support. | ||
Version 1.0.30. | ||
--------------- | ||
- new l-string module ==> l-string.web.js, run onthe browser. | ||
- dummyAddTag and smartAddTag deleted. | ||
- now, there's only one way to use l-string. | ||
- new dependencies cheerio | ||
- new function trimPrefix | ||
- old name add2TagClassName, new name addClassName2Tag (renamed) | ||
- old name add2TagIdName, new name addIdName2Tag (renamed) | ||
- old name add2TagStyle, new name addStyle2Tag (renamed) | ||
- old name add2TagAttr, new name addAttr2Tag (renamed) | ||
- new private function added. | ||
- escape update it. | ||
- new documentation style add it to all functions. | ||
Version 1.0.29. | ||
--------------- | ||
- add2Tag update it. | ||
- new documentation style add it to all functions. | ||
- new examples added. | ||
Version 1.0.28. | ||
--------------- | ||
- new function added it, addAttr2Tag. | ||
- new variable declaration style, added it. | ||
- new examples added. | ||
Version 1.0.27. | ||
--------------- | ||
- issues in method insert fixed. | ||
- new README.md style added. | ||
Contributors | ||
Authors | ||
------------- | ||
``` | ||
Leonardo Javier Esparis Meza ==> leo.leo.leoxnidas.c.14@gmail.com | ||
``` | ||
[Leonardo Javier Esparis Meza](./AUTHORS.md) |
(function() { | ||
var string = require("../../l-string"), | ||
fs = require('fs'), | ||
path = './index.html', | ||
path = __dirname + '/index.html', | ||
encoding = "utf8", | ||
@@ -11,11 +11,11 @@ html = ""; | ||
for (var i = 1; i <= 5; i++) { | ||
html = html.add2TagStyle("div" + i, [ | ||
html = html.addStyle2Tag("div" + i, [ | ||
['margin', ['10dp', 0, '10dp', 0]], | ||
['color', 'red'] | ||
]) | ||
html = html.add2TagClassName("div" + i, 'algo' + i) | ||
html = html.add2TagIdName("div" + i, 'algo' + i) | ||
html = html.add2TagClassName("div" + i, 'algor' + i) | ||
html = html.add2TagIdName("div" + i, 'algor' + i) | ||
html = html.add2TagStyle("div" + i, [ | ||
html = html.addClassName2Tag("div" + i, 'algo' + i) | ||
html = html.addIdName2Tag("div" + i, 'algo' + i) | ||
html = html.addClassName2Tag("div" + i, 'algor' + i) | ||
html = html.addIdName2Tag("div" + i, 'algor' + i) | ||
html = html.addStyle2Tag("div" + i, [ | ||
['padding', ['10dp', 0, '10dp', 0]], | ||
@@ -25,4 +25,4 @@ ['background', 'red'] | ||
} | ||
html = html.add2TagAttr("section1", "data-something", "veronica"); | ||
html = html.add2TagAttr("section2", "data-leonardo-esparis", "veronica"); | ||
html = html.addAttr2Tag("section1", "data-something", "veronica"); | ||
html = html.addAttr2Tag("section2", "data-leonardo-esparis", "veronica"); | ||
fs.writeFile(path, html, function(err) { | ||
@@ -29,0 +29,0 @@ if (err) throw err; |
Sorry, the diff of this file is not supported yet
50607
-13.92%14
-76.67%13
-13.33%53
-77.64%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated