lib/plan.js (1154 bytes)
1 // The plan of an sbm Sync account and the payments that the server offers, 2 // as the options page shows them. The server gives them at GET /api/account. 3 // This file has no browser code, so the tests run in node. 4 "use strict"; 5 6 const Plan = (() => { 7 /** The address as text when its scheme is one of schemes, else "". */ 8 function web(address, schemes = ["https:", "http:"]) { 9 try { 10 const u = new URL(address); 11 return schemes.includes(u.protocol) ? u.href : ""; 12 } catch (e) { 13 return ""; 14 } 15 } 16 17 return { 18 web, 19 20 /** The payment pages of the server and its terms of sale, as links with texts. */ 21 links(info) { 22 return [ 23 { href: web(info.support), text: "Become a supporter" }, 24 { href: web(info.manage), text: "Manage or cancel a supporter subscription" }, 25 { href: web(info.teams), text: "Team bookmarks: up to 10 people" }, 26 { href: web(info.teams_large), text: "Team bookmarks: 11 people or more" }, 27 { href: web(info.terms), text: "Terms of sale" }, 28 ].filter((l) => l.href !== ""); 29 }, 30 }; 31 })(); 32 33 if (typeof module !== "undefined") module.exports = Plan;