jellyfin-web/dashboard-ui/apiclient/device.js

35 lines
818 B
JavaScript
Raw Normal View History

2015-01-16 13:54:37 -07:00
(function (globalScope) {
2014-10-26 17:19:52 -07:00
2014-10-27 14:45:50 -07:00
if (!globalScope.MediaBrowser) {
globalScope.MediaBrowser = {};
}
2014-10-26 20:06:01 -07:00
globalScope.MediaBrowser.generateDeviceId = function (keyName, seed) {
2014-10-26 17:19:52 -07:00
2015-07-02 05:55:07 -07:00
keyName = keyName || 'randomId';
2014-10-26 17:19:52 -07:00
var keys = [];
keys.push(navigator.userAgent);
keys.push((navigator.cpuClass || ""));
if (seed) {
keys.push(seed);
}
2014-10-26 17:19:52 -07:00
var randomId = '';
// Since the above is not guaranteed to be unique per device, add a little more
2015-05-20 10:29:26 -07:00
randomId = appStorage.getItem(keyName);
2014-10-26 17:19:52 -07:00
if (!randomId) {
randomId = new Date().getTime();
2015-05-20 10:29:26 -07:00
appStorage.setItem(keyName, randomId.toString());
2014-10-26 17:19:52 -07:00
}
keys.push(randomId);
2014-11-05 12:28:41 -07:00
return CryptoJS.SHA1(keys.join('|')).toString();
2014-10-26 17:19:52 -07:00
};
2015-01-16 13:54:37 -07:00
})(window);