mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
integrated webserver ... (#697)
* initial commit of webconfig * update example config with webconfig and fix format of file update debian postinst script for install example config
This commit is contained in:
56
assets/webconfig/js/app/utils/Tools.js
Normal file
56
assets/webconfig/js/app/utils/Tools.js
Normal file
@@ -0,0 +1,56 @@
|
||||
define([], function () {
|
||||
'use strict';
|
||||
|
||||
return {
|
||||
/**
|
||||
* Convert a string to ArrayBuffer
|
||||
* @param {string} str String to convert
|
||||
* @returns {ArrayBuffer} Result
|
||||
*/
|
||||
str2ab: function (str) {
|
||||
var i, buf = new ArrayBuffer(str.length), bufView = new Uint8Array(buf);
|
||||
for (i = 0; i < str.length; i++) {
|
||||
bufView[i] = str.charCodeAt(i);
|
||||
}
|
||||
return buf;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert an array to ArrayBuffer
|
||||
* @param array
|
||||
* @returns {ArrayBuffer} Result
|
||||
*/
|
||||
a2ab: function (array) {
|
||||
return new Uint8Array(array).buffer;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert ArrayBuffer to string
|
||||
* @param {ArrayBuffer} buffer Buffer to convert
|
||||
* @returns {string}
|
||||
*/
|
||||
ab2hexstr: function (buffer) {
|
||||
var i, str = '', ua = new Uint8Array(buffer);
|
||||
for (i = 0; i < ua.length; i++) {
|
||||
str += this.b2hexstr(ua[i]);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convert byte to hexstr.
|
||||
* @param {number} byte Byte to convert
|
||||
*/
|
||||
b2hexstr: function (byte) {
|
||||
return ('00' + byte.toString(16)).substr(-2);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {ArrayBuffer} buffer
|
||||
* @returns {string}
|
||||
*/
|
||||
ab2str: function (buffer) {
|
||||
return String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
}
|
||||
};
|
||||
});
|
Reference in New Issue
Block a user