element.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { lang } from "./lang.js";
  2. class element {
  3. #id;
  4. #pictures;
  5. #mesh;
  6. #name;
  7. #description;
  8. #params;
  9. #links;
  10. constructor(id) {
  11. if (typeof(id) !== "number") {
  12. throw "ID must be number.";
  13. }
  14. this.#id = id;
  15. this.#pictures = {};
  16. this.#params = {};
  17. this.#links = {};
  18. this.#name = undefined;
  19. this.#mesh = undefined;
  20. }
  21. get id() {
  22. return this.#id;
  23. }
  24. set name(content) {
  25. if (typeof(content) !== "string") {
  26. throw "Name must be string.";
  27. }
  28. this.#name = content;
  29. }
  30. get name() {
  31. return this.#name;
  32. }
  33. get mesh() {
  34. return this.#mesh;
  35. }
  36. set mesh(content) {
  37. if (typeof(content) !== "string") {
  38. throw "Mesh URL must be string.";
  39. }
  40. this.#mesh = content;
  41. }
  42. get links() {
  43. const mesh = {};
  44. mesh[lang.element.mesh.link] = this.mesh;
  45. return Object.assign(this.#links, mesh);
  46. }
  47. set links(content) {
  48. if (typeof(content) !== "object") {
  49. throw "Links must be an object.";
  50. }
  51. this.#links = Object.assign({}, content);
  52. }
  53. addLink(name, url) {
  54. if (typeof(name) !== "string") {
  55. throw "Name must be string.";
  56. }
  57. if (typeof(url) !== "string") {
  58. throw "Url must be string.";
  59. }
  60. const new_link = {};
  61. new_link[name] = url;
  62. this.#links = Object.assign(new_link, this.#links);
  63. }
  64. get title() {
  65. }
  66. }
  67. export { element };