1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/apiclient/device.js

35 lines
818 B
JavaScript
Raw Normal View History

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