mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-16 12:45:49 +02:00
Merge pull request #685 from koalyptus/679-uuid-generator-fix
fix TableFilter table id generation with more robust uuid generator
This commit is contained in:
commit
f1febe1688
4
dist/starter.html
vendored
4
dist/starter.html
vendored
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>tablefilter v0.6.78 - Starter</title>
|
||||
<title>tablefilter v0.6.79 - Starter</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>tablefilter v0.6.78</h1>
|
||||
<h1>tablefilter v0.6.79</h1>
|
||||
|
||||
|
||||
|
||||
|
|
2
dist/tablefilter/tablefilter.js
vendored
2
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
2
dist/tablefilter/tablefilter.js.map
vendored
2
dist/tablefilter/tablefilter.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tablefilter",
|
||||
"version": "0.6.78",
|
||||
"version": "0.6.79",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
|
|
@ -89,3 +89,24 @@ export const toCamelCase = (text = '') => {
|
|||
return p1.toLowerCase();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a string in the format of a UUID (Universally Unique IDentifier).
|
||||
* NOTE: This format of 8 chars, followed by 3 groups of 4 chars, followed by 12
|
||||
* chars is known as a UUID and is defined in RFC4122 and is a standard for
|
||||
* generating unique IDs. This function DOES NOT implement this standard.
|
||||
* It simply outputs a string that looks similar. The standard is found here:
|
||||
* https://www.ietf.org/rfc/rfc4122.txt
|
||||
* source: https://gist.github.com/gordonbrander/2230317
|
||||
* @return {String}
|
||||
*/
|
||||
export const uuid = () => {
|
||||
const chr4 = () => Math.random().toString(16).slice(-4);
|
||||
|
||||
return chr4() + chr4()
|
||||
+ '-' + chr4()
|
||||
+ '-' + chr4()
|
||||
+ '-' + chr4()
|
||||
+ '-' + chr4()
|
||||
+ chr4() + chr4();
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@ import {addEvt, cancelEvt, stopEvt, targetEvt, isKeyPressed} from './event';
|
|||
import {
|
||||
addClass, createElm, elm, getText, getFirstTextNode, removeClass, tag
|
||||
} from './dom';
|
||||
import {contains, matchCase, rgxEsc, trim, toCamelCase} from './string';
|
||||
import {contains, matchCase, rgxEsc, trim, toCamelCase, uuid} from './string';
|
||||
import {
|
||||
isArray, isEmpty, isFn, isNumber, isObj, isString, isUndef, EMPTY_FN,
|
||||
isBoolean
|
||||
|
@ -142,7 +142,7 @@ export class TableFilter {
|
|||
args.forEach((arg) => {
|
||||
if (typeof arg === 'object' && arg.nodeName === 'TABLE') {
|
||||
this.tbl = arg;
|
||||
this.id = arg.id || `tf_${new Date().getTime()}_`;
|
||||
this.id = arg.id || `tf_${uuid()}`;
|
||||
this.tbl.id = this.id;
|
||||
} else if (isString(arg)) {
|
||||
this.id = arg;
|
||||
|
|
Loading…
Reference in a new issue