features.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. define([
  2. 'jquery',
  3. '/common/hyperscript.js',
  4. '/customize/messages.js',
  5. '/customize/application_config.js',
  6. '/common/outer/local-store.js',
  7. '/customize/pages.js'
  8. ], function ($, h, Msg, AppConfig, LocalStore, Pages) {
  9. var origin = encodeURIComponent(window.location.hostname);
  10. var accounts = {
  11. donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin,
  12. upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + origin,
  13. };
  14. return function () {
  15. Msg.features_f_apps_note = AppConfig.availablePadTypes.map(function (app) {
  16. if (AppConfig.registeredOnlyTypes.indexOf(app) !== -1) { return; }
  17. return Msg.type[app];
  18. }).filter(function (x) { return x; }).join(', ');
  19. var premiumButton = h('a', {
  20. href: accounts.upgradeURL,
  21. target: '_blank',
  22. rel: 'noopener noreferrer'
  23. }, h('button.cp-features-register-button', Msg.features_f_subscribe));
  24. $(premiumButton).click(function (e) {
  25. if (LocalStore.isLoggedIn()) { return; }
  26. // Not logged in: go to /login with a redirect to this page
  27. e.preventDefault();
  28. e.stopPropagation();
  29. sessionStorage.redirectTo = '/features.html';
  30. window.location.href = '/login/';
  31. });
  32. return h('div#cp-main', [
  33. Pages.infopageTopbar(),
  34. h('div.container-fluid.cp_cont_features',[
  35. h('div.container',[
  36. h('center', h('h1', Msg.features_title)),
  37. ]),
  38. ]),
  39. h('div.container',[
  40. h('div.row.cp-container.cp-features-web.justify-content-sm-center',[
  41. h('div.col-12.col-sm-4.cp-anon-user',[
  42. h('div.card',[
  43. h('div.card-body',[
  44. h('h3.text-center',Msg.features_anon)
  45. ]),
  46. h('ul.list-group.list-group-flush',
  47. ['apps', 'core', 'file0', 'cryptdrive0', 'storage0'].map(function (f) {
  48. return h('li.list-group-item', [
  49. h('div.cp-check'),
  50. h('div.cp-content', [
  51. h('div.cp-feature', Msg['features_f_' + f]),
  52. h('div.cp-note', Msg['features_f_' + f + '_note'])
  53. ])
  54. ]);
  55. })
  56. ),
  57. ]),
  58. ]),
  59. h('div.col-12.col-sm-4.cp-regis-user',[
  60. h('div.card',[
  61. h('div.card-body',[
  62. h('h3.text-center',Msg.features_registered)
  63. ]),
  64. h('ul.list-group.list-group-flush', [
  65. ['anon', 'social', 'file1', 'cryptdrive1', 'devices', 'storage1'].map(function (f) {
  66. return h('li.list-group-item', [
  67. h('div.cp-check'),
  68. h('div.cp-content', [
  69. h('div.cp-feature', Msg['features_f_' + f]),
  70. h('div.cp-note', Msg['features_f_' + f + '_note'])
  71. ])
  72. ]);
  73. }),
  74. ]),
  75. h('div.card-body',[
  76. h('div.cp-features-register#cp-features-register', [
  77. h('a', {
  78. href: '/register/'
  79. }, h('button.cp-features-register-button', Msg.features_f_register))
  80. ]),
  81. h('div.cp-note', Msg.features_f_register_note)
  82. ]),
  83. ]),
  84. ]),
  85. h('div.col-12.col-sm-4.cp-anon-user',[
  86. h('div.card',[
  87. h('div.card-body',[
  88. h('h3.text-center',Msg.features_premium)
  89. ]),
  90. h('ul.list-group.list-group-flush', [
  91. ['reg', 'storage2', 'support', 'supporter'].map(function (f) {
  92. return h('li.list-group-item', [
  93. h('div.cp-check'),
  94. h('div.cp-content', [
  95. h('div.cp-feature', Msg['features_f_' + f]),
  96. h('div.cp-note', Msg['features_f_' + f + '_note'])
  97. ])
  98. ]);
  99. }),
  100. ]),
  101. h('div.card-body',[
  102. h('div.cp-features-register#cp-features-subscribe', [
  103. premiumButton
  104. ]),
  105. LocalStore.isLoggedIn() ? undefined : h('div.cp-note', Msg.features_f_subscribe_note)
  106. ]),
  107. ]),
  108. ]),
  109. ]),
  110. ]),
  111. Pages.infopageFooter()
  112. ]);
  113. };
  114. });