make uid function reusable

pull/1/head
ansuz 7 years ago
parent 443d8a8941
commit b71f1860db

@ -7,6 +7,11 @@ define([], function () {
}, map));
};
Util.uid = function () {
return Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))
.toString(32).replace(/\./g, '');
};
Util.fixHTML = function (str) {
if (!str) { return ''; }
return str.replace(/[<>&"']/g, function (x) {

@ -98,6 +98,7 @@ define([
common.createRandomInteger = Util.createRandomInteger;
common.getAppType = Util.getAppType;
common.notAgainForAnother = Util.notAgainForAnother;
common.uid = Util.uid;
// import hash utilities for export
var createRandomHash = common.createRandomHash = Hash.createRandomHash;

@ -1,13 +1,10 @@
define([
'/common/common-util.js',
'/bower_components/tweetnacl/nacl-fast.min.js',
], function () {
], function (Util) {
var Nacl = window.nacl;
var uid = function () {
return Number(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER))
.toString(32).replace(/\./g, '');
};
var uid = Util.uid;
var signMsg = function (data, signKey) {
var buffer = Nacl.util.decodeUTF8(JSON.stringify(data));
return Nacl.util.encodeBase64(Nacl.sign.detached(buffer, signKey));

Loading…
Cancel
Save