/** * Copyright (C) 2024 Puter Technologies Inc. * * This file is part of Puter. * * Puter is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ import UIWindow from './UIWindow.js' import UIPopover from './UIPopover.js' async function UIWindowRefer(options){ let h = ''; let copy_btn_text = 'Copy Link'; let copied_btn_text = 'Copied!'; const url = `${gui_origin}/?r=${user.referral_code}`; h += `
`; h += `
×
`; h += ``; h += `

Get 1 GB for every friend who creates and confirms an account on Puter. Your friend will get 1 GB too!

`; h += ``; h += ``; h += `` h += ``; h += `
`; const el_window = await UIWindow({ title: `Refer a friend!`, icon: null, uid: null, is_dir: false, body_content: h, has_head: false, selectable_body: false, draggable_body: true, allow_context_menu: false, is_draggable: true, is_resizable: false, is_droppable: false, init_center: true, allow_native_ctxmenu: true, allow_user_select: true, onAppend: function(el_window){ }, width: 500, dominant: true, window_css: { height: 'initial', }, body_css: { width: 'initial', 'max-height': 'calc(100vh - 200px)', 'background-color': 'rgb(241 246 251)', 'backdrop-filter': 'blur(3px)', 'padding': '10px 20px 20px 20px', 'height': 'initial', } }); $(el_window).find('.window-body .downloadable-link').val(url); $(el_window).find('.window-body .share-copy-link-on-social').on('click', function(e){ const social_links = socialLink({url: url, title: `Get 1 GB of free storage on Puter.com!`, description: `Get 1 GB of free storage on Puter.com!`}); let social_links_html = ``; social_links_html += `
`; social_links_html += `

Share to

` social_links_html += `` social_links_html += `` social_links_html += `` social_links_html += `` social_links_html += `` social_links_html += `` social_links_html += '
'; UIPopover({ content: social_links_html, snapToElement: this, parent_element: this, // width: 300, height: 100, position: 'bottom', }); }) $(el_window).find('.window-body .copy-downloadable-link').on('click', async function(e){ var copy_btn = this; if (navigator.clipboard) { // Get link text const selected_text = $(el_window).find('.window-body .downloadable-link').val(); // copy selected text to clipboard await navigator.clipboard.writeText(selected_text); } else{ // Get the text field $(el_window).find('.window-body .downloadable-link').select(); // Copy the text inside the text field document.execCommand('copy'); } $(this).html(copied_btn_text); setTimeout(function(){ $(copy_btn).html(copy_btn_text); }, 1000); }); } export default UIWindowRefer