Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

util.js 4.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. var Unibase;
  2. (function (Unibase) {
  3. let Apps;
  4. (function (Apps) {
  5. let Collaboration;
  6. (function (Collaboration) {
  7. let Components;
  8. (function (Components) {
  9. let Common;
  10. (function (Common) {
  11. class Util {
  12. createElement(tagName, attType, attValue) {
  13. let ele = document.createElement(tagName);
  14. ele.setAttribute(attType, attValue);
  15. return ele;
  16. }
  17. appendChildren(parent, classIndex, ...eleArray) {
  18. let parentTag = document.getElementsByClassName(parent)[classIndex];
  19. for (let i = 0; i < eleArray.length; i++) {
  20. parentTag.appendChild(eleArray[i]);
  21. }
  22. }
  23. addAttributes(htmlElement, attrJson) {
  24. for (var attr in attrJson) {
  25. htmlElement.setAttribute(attr, attrJson[attr]);
  26. }
  27. }
  28. getCellValues(cellInfo) {
  29. var val = {};
  30. cellInfo.value && (val["value"] = cellInfo.value.toString().trim());
  31. cellInfo.formula && (val["formula"] = cellInfo.formula);
  32. cellInfo.format ? (val["format"] = cellInfo.format) : (val["format"] = "General");
  33. cellInfo.hyperlink && (val["hyperlink"] = cellInfo.hyperlink);
  34. return val;
  35. }
  36. colorHash(str) {
  37. var sum = 0;
  38. for (var i in str) {
  39. sum += str.charCodeAt(i);
  40. }
  41. let r = ~~(('0.' + Math.sin(sum + 1).toString().substr(6)) * 256);
  42. let g = ~~(('0.' + Math.sin(sum + 2).toString().substr(6)) * 256);
  43. let b = ~~(('0.' + Math.sin(sum + 3).toString().substr(6)) * 256);
  44. let rgb = "rgb(" + r + ", " + g + ", " + b + ")";
  45. let hex = "#";
  46. hex += ("00" + r.toString(16)).substr(-2, 2).toUpperCase();
  47. hex += ("00" + g.toString(16)).substr(-2, 2).toUpperCase();
  48. hex += ("00" + b.toString(16)).substr(-2, 2).toUpperCase();
  49. return {
  50. r: r,
  51. g: g,
  52. b: b,
  53. rgb: rgb,
  54. hex: hex
  55. };
  56. }
  57. makeid(length) {
  58. var result = '';
  59. var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  60. var charactersLength = characters.length;
  61. for (var i = 0; i < length; i++) {
  62. result += characters.charAt(Math.floor(Math.random() *
  63. charactersLength));
  64. }
  65. return result;
  66. }
  67. static Instance() {
  68. if (this.instance === undefined) {
  69. this.instance = new Util();
  70. }
  71. return this.instance;
  72. }
  73. }
  74. Common.Util = Util;
  75. })(Common = Components.Common || (Components.Common = {}));
  76. })(Components = Collaboration.Components || (Collaboration.Components = {}));
  77. })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {}));
  78. })(Apps = Unibase.Apps || (Unibase.Apps = {}));
  79. })(Unibase || (Unibase = {}));