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.

162 lines
6.5 KiB

1 year ago
  1. define([
  2. '/common/hyperscript.js',
  3. '/common/common-language.js',
  4. '/customize/application_config.js',
  5. '/customize/messages.js',
  6. 'jquery',
  7. ], function (h, Language, AppConfig, Msg, $) {
  8. var Pages = {};
  9. Pages.setHTML = function (e, html) {
  10. e.innerHTML = html;
  11. return e;
  12. };
  13. var languageSelector = function () {
  14. var options = [];
  15. var languages = Msg._languages;
  16. var selected = Msg._languageUsed;
  17. var keys = Object.keys(languages).sort();
  18. keys.forEach(function (l) {
  19. var attr = { value: l };
  20. if (selected === l) { attr.selected = 'selected'; }
  21. options.push(h('option', attr, languages[l]));
  22. });
  23. var select = h('select', {}, options);
  24. $(select).change(function () {
  25. Language.setLanguage($(select).val() || '', null, function () {
  26. window.location.reload();
  27. });
  28. });
  29. return select;
  30. };
  31. var footerCol = function (title, L, literal) {
  32. return h('div.col-6.col-sm-3', [
  33. h('ul.list-unstyled', [
  34. h('li.footer-title', {
  35. 'data-localization': title,
  36. }, title? Msg[title]: literal )
  37. ].concat(L.map(function (l) {
  38. return h('li', [ l ]);
  39. }))
  40. )
  41. ]);
  42. };
  43. var footLink = function (ref, loc, text) {
  44. var attrs = {
  45. href: ref,
  46. };
  47. if (!/^\//.test(ref)) {
  48. attrs.target = '_blank';
  49. attrs.rel = 'noopener noreferrer';
  50. }
  51. if (loc) {
  52. attrs['data-localization'] = loc;
  53. text = Msg[loc];
  54. }
  55. return h('a', attrs, text);
  56. };
  57. var imprintUrl = AppConfig.imprint && (typeof(AppConfig.imprint) === "boolean" ?
  58. '/imprint.html' : AppConfig.imprint);
  59. Pages.infopageFooter = function () {
  60. return h('footer', [
  61. h('div.container', [
  62. h('div.row', [
  63. footerCol(null, [
  64. h('div.cp-bio-foot', [
  65. h('p', Msg.main_footerText),
  66. languageSelector()
  67. ])
  68. ], ''),
  69. /*footerCol('footer_applications', [
  70. footLink('/drive/', 'main_drive'),
  71. footLink('/pad/', 'main_richText'),
  72. footLink('/code/', 'main_code'),
  73. footLink('/slide/', 'main_slide'),
  74. footLink('/poll/', 'main_poll'),
  75. footLink('/kanban/', 'main_kanban'),
  76. footLink('/whiteboard/', null, Msg.type.whiteboard)
  77. ]),*/
  78. footerCol('footer_product', [
  79. footLink('https://cryptpad.fr/what-is-cryptpad.html', 'topbar_whatIsCryptpad'),
  80. footLink('/faq.html', 'faq_link'),
  81. footLink('https://github.com/xwiki-labs/cryptpad', null, 'GitHub'),
  82. footLink('https://opencollective.com/cryptpad/contribute/', 'footer_donate'),
  83. ]),
  84. footerCol('footer_aboutUs', [
  85. /*footLink('https://blog.cryptpad.fr', 'blog'),
  86. footLink('https://labs.xwiki.com', null, 'XWiki Labs'),*/
  87. footLink('http://www.xwiki.com', null, 'XWiki SAS'),
  88. footLink('https://www.open-paas.org', null, 'OpenPaaS'),
  89. footLink('/about.html', 'footer_team'),
  90. footLink('/contact.html', 'contact'),
  91. ]),
  92. footerCol('footer_legal', [
  93. footLink('/terms.html', 'footer_tos'),
  94. footLink('/privacy.html', 'privacy'),
  95. AppConfig.imprint ? footLink(imprintUrl, 'imprint') : undefined,
  96. ]),
  97. /*footerCol('footer_contact', [
  98. footLink('https://riot.im/app/#/room/#cryptpad:matrix.org', null, 'Chat'),
  99. footLink('https://twitter.com/cryptpad', null, 'Twitter'),
  100. footLink('https://github.com/xwiki-labs/cryptpad', null, 'GitHub'),
  101. footLink('/contact.html', null, 'Email')
  102. ])*/
  103. ])
  104. ]),
  105. h('div.cp-version-footer', "CryptPad v3.16.0 (Quagga)")
  106. ]);
  107. };
  108. Pages.infopageTopbar = function () {
  109. var rightLinks;
  110. var username = window.localStorage.getItem('User_name');
  111. if (username === null) {
  112. rightLinks = [
  113. h('a.nav-item.nav-link.cp-login-btn', { href: '/login/'}, Msg.login_login),
  114. h('a.nav-item.nav-link.cp-register-btn', { href: '/register/'}, Msg.login_register)
  115. ];
  116. } else {
  117. rightLinks = h('a.nav-item.nav-link.cp-user-btn', { href: '/drive/' }, [
  118. h('i.fa.fa-user-circle'),
  119. " ",
  120. username
  121. ]);
  122. }
  123. var button = h('button.navbar-toggler', {
  124. 'type':'button',
  125. /*'data-toggle':'collapse',
  126. 'data-target':'#menuCollapse',
  127. 'aria-controls': 'menuCollapse',
  128. 'aria-expanded':'false',
  129. 'aria-label':'Toggle navigation'*/
  130. }, h('i.fa.fa-bars '));
  131. $(button).click(function () {
  132. if ($('#menuCollapse').is(':visible')) {
  133. return void $('#menuCollapse').slideUp();
  134. }
  135. $('#menuCollapse').slideDown();
  136. });
  137. return h('nav.navbar.navbar-expand-lg',
  138. h('a.navbar-brand', { href: '/index.html'}),
  139. button,
  140. h('div.collapse.navbar-collapse.justify-content-end#menuCollapse', [
  141. //h('a.nav-item.nav-link', { href: '/what-is-cryptpad.html'}, Msg.topbar_whatIsCryptpad), // Moved the FAQ
  142. //h('a.nav-item.nav-link', { href: '/faq.html'}, Msg.faq_link),
  143. h('a.nav-item.nav-link', { href: 'https://blog.cryptpad.fr/'}, Msg.blog),
  144. h('a.nav-item.nav-link', { href: '/features.html'}, Msg.pricing),
  145. h('a.nav-item.nav-link', { href: '/privacy.html'}, Msg.privacy),
  146. //h('a.nav-item.nav-link', { href: '/contact.html'}, Msg.contact),
  147. //h('a.nav-item.nav-link', { href: '/about.html'}, Msg.about),
  148. ].concat(rightLinks))
  149. );
  150. };
  151. return Pages;
  152. });