Commit 6ce7fda0 by Thimo Kraemer

randomString -> uniqueId

parent 6e2bb1b7
/*
* KSS-RPC v0.15-beta
* KSS-RPC v0.16-beta
*
* Copyright (c) 2017, joonis new media
* Author: Thimo Kraemer <thimo.kraemer@joonis.de>
......@@ -61,7 +61,7 @@
******************************************************************************************/
var kss = {
version: '0.15-beta',
version: '0.16-beta',
_initialized: false,
_ruleSheets: {},
_eventBinders: {},
......@@ -286,8 +286,9 @@ kss.ISO8601toDate = function(date) {
}
};
kss.randomString = function() {
return Math.floor(Math.random()*1e16).toString(16);
kss.uniqueId = function() {
return Math.random().toString(36).substring(2)
+ (new Date()).getTime().toString(36);
};
kss.eval = function(__expr__) {
......@@ -1059,7 +1060,7 @@ kss.RPC.prototype.invoke = function(method, params,
var request = {
method: method,
params: params || [],
id: kss.randomString()
id: kss.uniqueId()
};
if (this._protocol != 'json-rpc-v1') {
request.jsonrpc = '2.0';
......@@ -2562,10 +2563,10 @@ window.addEventListener('hashchange', function(event) {
kss.addHistoryState = function() {
var hash = window.location.hash;
if (!kss._historyre.test(hash)) {
kss._historyHash = '#kss-' + kss.randomString();
kss._historyHash = '#kss-' + kss.uniqueId();
window.location.replace(kss._historyHash);
}
window.location.hash = '#kss-' + kss.randomString();
window.location.hash = '#kss-' + kss.uniqueId();
};
kss.registerActionProvider('addHistoryState', kss.addHistoryState);
......@@ -2796,7 +2797,7 @@ kss._loadAnimationLib = function () {
window.history.pushState({}, '', '#'+id);
}
else {
window.location.hash = '#' + kss.randomString();
window.location.hash = '#' + kss.uniqueId();
}
}
return container;
......@@ -3074,7 +3075,7 @@ kss._loadAnimationLib = function () {
}
if (!kss.scroll) {
kss.scroll = function(node, params) {
window.location.hash = node.id || kss.randomString();
window.location.hash = node.id || kss.uniqueId();
node.scrollIntoView();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment