2502 lines
157 KiB
HTML
2502 lines
157 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>RanchiMall Times</title>
|
|
<meta name="description" content="Read handpicked articles">
|
|
<link rel="stylesheet" href="css/main.min.css">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link
|
|
href="https://fonts.googleapis.com/css2?family=Calistoga&family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap"
|
|
rel="stylesheet">
|
|
<script id="floGlobals">
|
|
/* Constants for FLO blockchain operations !!Make sure to add this at beginning!! */
|
|
const floGlobals = {
|
|
blockchain: "FLO",
|
|
application: "RM_Times",
|
|
adminID: "FF5pewfsJxyrCvg8a2C8VXefeyVvKvQxmF"
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="onLoadStartUp()" class="hide">
|
|
<sm-notifications id="notification_drawer"></sm-notifications>
|
|
<sm-popup id="confirmation_popup">
|
|
<h4 id="confirm_title"></h4>
|
|
<p id="confirm_message"></p>
|
|
<div class="flex align-center">
|
|
<sm-button variant="no-outline" class="cancel-btn">Cancel</sm-button>
|
|
<sm-button variant="no-outline" class="submit-btn">OK</sm-button>
|
|
</div>
|
|
</sm-popup>
|
|
<article id="loading" class="page">
|
|
<section>
|
|
<div id="loader_container">
|
|
<svg id="loader" viewBox="0 0 112 256" xmlns="http://www.w3.org/2000/svg">
|
|
<g>
|
|
<rect x="33" width="39" height="8" rx="2" />
|
|
<rect x="33" y="11" width="79" height="13" rx="2" />
|
|
<rect x="33" y="29" width="79" height="20" rx="2" />
|
|
<rect width="27" height="27" rx="2" />
|
|
</g>
|
|
<g>
|
|
<rect x="33" y="69" width="39" height="8" rx="2" />
|
|
<rect x="33" y="80" width="79" height="13" rx="2" />
|
|
<rect x="33" y="98" width="79" height="20" rx="2" />
|
|
<rect y="69" width="27" height="27" rx="2" />
|
|
</g>
|
|
<g>
|
|
<rect x="33" y="138" width="39" height="8" rx="2" />
|
|
<rect x="33" y="149" width="79" height="13" rx="2" />
|
|
<rect x="33" y="167" width="79" height="20" rx="2" />
|
|
<rect y="138" width="27" height="27" rx="2" />
|
|
</g>
|
|
<g>
|
|
<rect x="33" y="207" width="39" height="8" rx="2" />
|
|
<rect x="33" y="218" width="79" height="13" rx="2" />
|
|
<rect x="33" y="236" width="79" height="20" rx="2" />
|
|
<rect y="207" width="27" height="27" rx="2" />
|
|
</g>
|
|
</svg>
|
|
</div>
|
|
<h4>Loading RanchiMall Times</h4>
|
|
</section>
|
|
</article>
|
|
<div id="main" class="hide">
|
|
<header id="main_header">
|
|
<a href="#/home" class="logo">
|
|
<svg class="main-logo" viewBox="0 0 27.25 32">
|
|
<title>RanchiMall</title>
|
|
<path
|
|
d="M27.14,30.86c-.74-2.48-3-4.36-8.25-6.94a20,20,0,0,1-4.2-2.49,6,6,0,0,1-1.25-1.67,4,4,0,0,1,0-2.26c.37-1.08.79-1.57,3.89-4.55a11.66,11.66,0,0,0,3.34-4.67,6.54,6.54,0,0,0,.05-2.82C20,3.6,18.58,2,16.16.49c-.89-.56-1.29-.64-1.3-.24a3,3,0,0,1-.3.72l-.3.55L13.42.94C13,.62,12.4.26,12.19.15c-.4-.2-.73-.18-.72.05a9.39,9.39,0,0,1-.61,1.33s-.14,0-.27-.13C8.76.09,8-.27,8,.23A11.73,11.73,0,0,1,6.76,2.6C4.81,5.87,2.83,7.49.77,7.49c-.89,0-.88,0-.61,1,.22.85.33.92,1.09.69A5.29,5.29,0,0,0,3,8.33c.23-.17.45-.29.49-.26a2,2,0,0,1,.22.63A1.31,1.31,0,0,0,4,9.34a5.62,5.62,0,0,0,2.27-.87L7,8l.13.55c.19.74.32.82,1,.65a7.06,7.06,0,0,0,3.46-2.47l.6-.71-.06.64c-.17,1.63-1.3,3.42-3.39,5.42L6.73,14c-3.21,3.06-3,5.59.6,8a46.77,46.77,0,0,0,4.6,2.41c.28.13,1,.52,1.59.87,3.31,2,4.95,3.92,4.95,5.93a2.49,2.49,0,0,0,.07.77h0c.09.09,0,.1.9-.14a2.61,2.61,0,0,0,.83-.32,3.69,3.69,0,0,0-.55-1.83A11.14,11.14,0,0,0,17,26.81a35.7,35.7,0,0,0-5.1-2.91C9.37,22.64,8.38,22,7.52,21.17a3.53,3.53,0,0,1-1.18-2.48c0-1.38.71-2.58,2.5-4.23,2.84-2.6,3.92-3.91,4.67-5.65a3.64,3.64,0,0,0,.42-2A3.37,3.37,0,0,0,13.61,5l-.32-.74.29-.48c.17-.27.37-.63.46-.8l.15-.3.44.64a5.92,5.92,0,0,1,1,2.81,5.86,5.86,0,0,1-.42,1.94c0,.12-.12.3-.15.4a9.49,9.49,0,0,1-.67,1.1,28,28,0,0,1-4,4.29C8.62,15.49,8.05,16.44,8,17.78a3.28,3.28,0,0,0,1.11,2.76c.95,1,2.07,1.74,5.25,3.32,3.64,1.82,5.22,2.9,6.41,4.38A4.78,4.78,0,0,1,21.94,31a3.21,3.21,0,0,0,.14.92,1.06,1.06,0,0,0,.43-.05l.83-.22.46-.12-.06-.46c-.21-1.53-1.62-3.25-3.94-4.8a37.57,37.57,0,0,0-5.22-2.82A13.36,13.36,0,0,1,11,21.19a3.36,3.36,0,0,1-.8-4.19c.41-.85.83-1.31,3.77-4.15,2.39-2.31,3.43-4.13,3.43-6a5.85,5.85,0,0,0-2.08-4.29c-.23-.21-.44-.43-.65-.65A2.5,2.5,0,0,1,15.27.69a10.6,10.6,0,0,1,2.91,2.78A4.16,4.16,0,0,1,19,6.16a4.91,4.91,0,0,1-.87,3c-.71,1.22-1.26,1.82-4.27,4.67a9.47,9.47,0,0,0-2.07,2.6,2.76,2.76,0,0,0-.33,1.54,2.76,2.76,0,0,0,.29,1.47c.57,1.21,2.23,2.55,4.65,3.73a32.41,32.41,0,0,1,5.82,3.24c2.16,1.6,3.2,3.16,3.2,4.8a1.94,1.94,0,0,0,.09.76,4.54,4.54,0,0,0,1.66-.4C27.29,31.42,27.29,31.37,27.14,30.86ZM6.1,7h0a3.77,3.77,0,0,1-1.46.45L4,7.51l.68-.83a25.09,25.09,0,0,0,3-4.82A12,12,0,0,1,8.28.76c.11-.12.77.32,1.53,1l.63.58-.57.84A10.34,10.34,0,0,1,6.1,7Zm5.71-1.78A9.77,9.77,0,0,1,9.24,7.18h0a5.25,5.25,0,0,1-1.17.28l-.58,0,.65-.78a21.29,21.29,0,0,0,2.1-3.12c.22-.41.42-.76.44-.79s.5.43.9,1.24L12,5ZM13.41,3a2.84,2.84,0,0,1-.45.64,11,11,0,0,1-.9-.91l-.84-.9.19-.45c.34-.79.39-.8,1-.31A9.4,9.4,0,0,1,13.8,2.33q-.18.34-.39.69Z" />
|
|
</svg>
|
|
<h4>RanchiMall Times</h4>
|
|
</a>
|
|
<button id="search_button" class="icon-only hide-on-desktop" title="Search for articles"
|
|
onclick="revealSearch()">
|
|
<svg class="icon" slot="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
|
|
</svg>
|
|
</button>
|
|
<div id="expanding_search" class="hide-on-mobile">
|
|
<div class="flex align-center">
|
|
<button class="icon-only hide-on-desktop" onclick="hideSearch()">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
|
|
</svg>
|
|
</button>
|
|
<div class="w-100">
|
|
<sm-input id="search_articles" placeholder="Search articles" type="search">
|
|
<svg class="icon" slot="icon" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
|
|
</svg>
|
|
</sm-input>
|
|
</div>
|
|
</div>
|
|
<div id="search_suggestions" class="flex direction-column hide"></div>
|
|
</div>
|
|
<theme-toggle></theme-toggle>
|
|
<button id="user_popup_button" class="hide full-bleed justify-center" onclick="openPopup('user_popup')"
|
|
title="Click to view user profile" aria-label="User profile"></button>
|
|
<button id="show_sign_in_button" class="button button--primary full-bleed">Sign In</button>
|
|
</header>
|
|
<article id="main_page" class="page hide">
|
|
<section id="main_page__header" class="flex align-center">
|
|
<div id="news_categories_list" class="flex"></div>
|
|
</section>
|
|
<section class="flex direction-column gap-1-5">
|
|
<div class="flex align-center">
|
|
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path d="M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6h-6z" />
|
|
</svg>
|
|
<h5>Top articles</h5>
|
|
</div>
|
|
<div id="trending_article_container" class="grid"></div>
|
|
</section>
|
|
<section id="lastest_articles_section" class="flex direction-column gap-1-5">
|
|
<div class="flex align-center space-between">
|
|
<div class="flex">
|
|
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8zm.5-13H11v6l5.25 3.15.75-1.23-4.5-2.67z" />
|
|
</svg>
|
|
<h5>Latest</h5>
|
|
</div>
|
|
<a class="button" href="#/explore?type=recent">See all</a>
|
|
</div>
|
|
<ul id="latest_articles_list" class="grid gap-2"></ul>
|
|
</section>
|
|
</article>
|
|
<article id="explore" class="page page-layout hide">
|
|
<section class="grid gap-1-5">
|
|
<h1 id="explore_heading">Explore</h1>
|
|
<div id="query_results_list" class="grid observe-empty-state"></div>
|
|
<p class="empty-state">No related articles</p>
|
|
</section>
|
|
</article>
|
|
<article id="writer" class="page grid hide">
|
|
<section class="grid gap-1-5">
|
|
<div id="writer_profile">
|
|
<span id="writer_initials"></span>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h3 id="writer_name"></h3>
|
|
<p id="writer_bio"></p>
|
|
</div>
|
|
<div class="grid">
|
|
<h5>FLO address</h5>
|
|
<sm-copy id="writer_id"></sm-copy>
|
|
</div>
|
|
</section>
|
|
<section class="grid gap-1-5 align-start">
|
|
<h4>Articles contributed</h4>
|
|
<div id="written_article_list" class="grid observe-empty-state"></div>
|
|
<p class="empty-state">No articles written</p>
|
|
</section>
|
|
</article>
|
|
<article id="article" class="page hide">
|
|
<aside id="article_aside">
|
|
<nav id="article_map" class="hide-on-mobile" aria-label="secondary navigation for article sections">
|
|
<h4>In this article</h4>
|
|
<ul id="article_map_container"></ul>
|
|
</nav>
|
|
<div id="action_panel" class="flex">
|
|
<button class="icon-only" title="Share article" onclick="sharePreview()">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24"
|
|
height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<g>
|
|
<rect fill="none" height="24" width="24" />
|
|
</g>
|
|
<g>
|
|
<path
|
|
d="M16,5l-1.42,1.42l-1.59-1.59V16h-1.98V4.83L9.42,6.42L8,5l4-4L16,5z M20,10v11c0,1.1-0.9,2-2,2H6c-1.11,0-2-0.9-2-2V10 c0-1.11,0.89-2,2-2h3v2H6v11h12V10h-3V8h3C19.1,8,20,8.89,20,10z" />
|
|
</g>
|
|
</svg>
|
|
</button>
|
|
<button id="upvote_button" class="up-vote" title="Give a like">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0z" fill="none" />
|
|
<path
|
|
d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
</svg>
|
|
<div id="like_count">Loading...</div>
|
|
</button>
|
|
</div>
|
|
</aside>
|
|
<main class="grid gap-2">
|
|
<header class="hero-section">
|
|
<div class="flex align-center" style="margin-bottom: 0.5rem; font-size: 0.9rem; font-weight: 500;">
|
|
<a href="#/home">Home</a>
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6-6-6z" />
|
|
</svg>
|
|
<div id="article_category"></div>
|
|
</div>
|
|
<h1 id="article_title"></h1>
|
|
<p id="article_summary"></p>
|
|
<div class="flex align-center">
|
|
<time id="published_time"></time>
|
|
<span class="bullet-point"></span><span id="reading_time" style="white-space: nowrap;"></span>
|
|
</div>
|
|
<section class="margin-top-1">
|
|
<h5>Article by</h5>
|
|
<div id="article_contributors" class="flex"></div>
|
|
</section>
|
|
<img id="article_image" src="" alt="" loading="lazy">
|
|
</header>
|
|
<details id="article_map_accordion" class="hide-on-desktop">
|
|
<summary class="space-between">
|
|
<h4>In this article</h4>
|
|
<svg class="icon down-arrow" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M24 24H0V0h24v24z" fill="none" opacity=".87" />
|
|
<path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6-1.41-1.41z" />
|
|
</svg>
|
|
</summary>
|
|
</details>
|
|
<section id="article_body" class="grid"></section>
|
|
<section>
|
|
<h5>Pick something to read </h5>
|
|
<div id="related_articles" class="grid"></div>
|
|
</section>
|
|
</main>
|
|
|
|
<button id="go_to_top" class="floating-button hide" onclick="goToTop()">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14l-6-6z" />
|
|
</svg>
|
|
</button>
|
|
</article>
|
|
<article id="dashboard" class="page page-layout hide">
|
|
<div class="flex justify-center align-center">
|
|
<sm-chips id="section_selector">
|
|
<sm-chip value="analytic" selected>Analytics</sm-chip>
|
|
<sm-chip value="request">Requests</sm-chip>
|
|
<sm-chip value="writers">Writers</sm-chip>
|
|
<sm-chip value="cc">CC</sm-chip>
|
|
</sm-chips>
|
|
</div>
|
|
<section id="analytic_section" class="admin-section">
|
|
<ul id="article_analytics" class="grid gap-2 observe-empty-state"></ul>
|
|
<p class="empty-state">No articles</p>
|
|
</section>
|
|
<section id="request_section" class="admin-section hide">
|
|
<ul id="publishing_requests" class="grid gap-2 observe-empty-state"></ul>
|
|
<p class="empty-state">No requests</p>
|
|
</section>
|
|
<section id="writers_section" class="admin-section hide">
|
|
<button id="add_writer_button" class="floating-button cta" onclick="showAddWriterPopup()">
|
|
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
|
|
</svg>
|
|
Add writer
|
|
</button>
|
|
<ul id="writers_list" class="grid gap-1-5 observe-empty-state"></ul>
|
|
<p class="empty-state">No writers</p>
|
|
</section>
|
|
<section id="cc_section" class="admin-section hide grid gap-1-5">
|
|
<div class="grid gap-1-5">
|
|
<div class="grid gap-0-5">
|
|
<h4>Approve FLO IDs</h4>
|
|
<p>Add FLO IDs that are allowed to submit article publishing requests from CC.</p>
|
|
|
|
</div>
|
|
<sm-form>
|
|
<div class="flex">
|
|
<sm-input id="get_id_to_add" placeholder="Add FLO IDs" class="w-100" required></sm-input>
|
|
<sm-button variant="primary" onclick="addApprovedID()">Add</sm-button>
|
|
</div>
|
|
</sm-form>
|
|
</div>
|
|
<ul id="approved_ids" class="grid gap-0-5 observe-empty-state"></ul>
|
|
<p class="empty-state">No approved FLO IDs</p>
|
|
</section>
|
|
</article>
|
|
<footer id="main_footer" class="page-layout hide">
|
|
<h4>A RanchiMall product</h4>
|
|
<ul>
|
|
<li>
|
|
<a href="#/about_us">How it works</a>
|
|
</li>
|
|
</ul>
|
|
</footer>
|
|
</div>
|
|
<sm-popup id="sign_in_popup">
|
|
<header slot="header" class="popup__header">
|
|
<button class="popup__header__close">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
|
</svg>
|
|
</button>
|
|
</header>
|
|
<section id="sign_in" class="grid gap-1">
|
|
<div class="grid gap-0-5">
|
|
<h3>Sign in</h3>
|
|
<p>Liking an article supports and encourages the creators.</p>
|
|
</div>
|
|
<sm-form>
|
|
<sm-input id="private_key_field" type="password" placeholder="FLO private key"
|
|
error-text="Private key is invalid" data-private-key autofocus required></sm-input>
|
|
<sm-button id="sign_in_button" class="cta" variant="primary" disabled>Sign In</sm-button>
|
|
</sm-form>
|
|
<div class="grid gap-0-5">
|
|
<p>New here? Generate your FLO credentials below to continue</p>
|
|
<button class="button" onclick="generateCredentials()">
|
|
Get FLO credentials
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0z" fill="none" />
|
|
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</section>
|
|
<section id="sign_up" class="grid gap-1-5 hide">
|
|
<button class="justify-self-start" onclick="goToSignIn()">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0z" fill="none" />
|
|
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
|
|
</svg>
|
|
</button>
|
|
<div class="grid gap-0-5">
|
|
<h3>FLO credentials</h3>
|
|
<p>You can use FLO credentials with RanchiMall Times and all RanchiMall FLO apps. </p>
|
|
</div>
|
|
<div class="grid gap-1-5 card">
|
|
<div class="grid gap-0-5">
|
|
<h5>FLO address</h5>
|
|
<sm-copy id="generated_flo_id"></sm-copy>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>Private key</h5>
|
|
<sm-copy id="generated_private_key"></sm-copy>
|
|
</div>
|
|
</div>
|
|
<sm-button id="sign_up_button" variant="primary">Sign in with these credentials</sm-button>
|
|
<strong class="warning">
|
|
Keep your private key secure and don't share with anyone.
|
|
Once lost there is no way to recover private key.
|
|
</strong>
|
|
</section>
|
|
</sm-popup>
|
|
<sm-popup id="share_popup">
|
|
<header slot="header" class="popup__header">
|
|
<div class="flex align-center">
|
|
<button class="popup__header__close">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
|
</svg>
|
|
</button>
|
|
<h3>Share article</h3>
|
|
</div>
|
|
</header>
|
|
<span class="label">Copy link</span>
|
|
<sm-copy id="shared_url" clip-text></sm-copy>
|
|
</sm-popup>
|
|
<sm-popup id="preview_popup">
|
|
<header slot="header" class="popup__header">
|
|
<div class="flex align-center">
|
|
<button class="popup__header__close">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<h4>
|
|
Preview
|
|
</h4>
|
|
</header>
|
|
<section id="preview_container" class="grid gap-1-5"></section>
|
|
</sm-popup>
|
|
<sm-popup id="edit_article_meta_popup">
|
|
<header slot="header" class="popup__header">
|
|
<div class="flex align-center">
|
|
<button class="popup__header__close">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<h4 id="edit_popup__title">
|
|
Edit
|
|
</h4>
|
|
</header>
|
|
<section class="grid gap-1-5">
|
|
<div class="grid gap-1-5">
|
|
<div class="grid gap-0-5">
|
|
<h5>Title</h5>
|
|
<sm-input id="edit_title" required></sm-input>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>Select category</h5>
|
|
<fieldset id="edit_category"></fieldset>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>Hero image</h5>
|
|
<!-- <img src="" alt="" id="preview_image"> -->
|
|
<sm-input id="select_full_image" placeholder="High-res image name" animate></sm-input>
|
|
<sm-input id="select_thumbnail_image" placeholder="Thumbnail image name" animate></sm-input>
|
|
</div>
|
|
|
|
<!-- <label class="grid gap-0-5">
|
|
<h5>Hero Image</h5>
|
|
<img src="" alt="" id="preview_image">
|
|
<input id="select_image" type="file" accept="image">
|
|
</label> -->
|
|
</div>
|
|
<div class="grid gap-1-5">
|
|
<div class="grid gap-0-5">
|
|
<h5>Summary</h5>
|
|
<sm-textarea id="edit_summary" rows="4"></sm-textarea>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>Add tags</h5>
|
|
<tags-input id="edit_tags" limit="10"></tags-input>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>contributors</h5>
|
|
<tags-input id="edit_contributors"></tags-input>
|
|
</div>
|
|
<label class="grid gap-0-5">
|
|
<h5>Publishing date</h5>
|
|
<input type="date" id="edit_published">
|
|
</label>
|
|
<div class="flex align-center w-100">
|
|
<button id="set_article_meta" class="button button--primary cta w-100"
|
|
onclick="defineArticle()">Save</button>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</sm-popup>
|
|
|
|
<sm-popup id="add_writer_popup">
|
|
<header slot="header" class="popup__header">
|
|
<div class="flex align-center">
|
|
<button class="popup__header__close">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
|
</svg>
|
|
</button>
|
|
<h3 id="writer_popup_title">Add writer</h3>
|
|
</div>
|
|
</header>
|
|
<sm-form>
|
|
<div class="grid">
|
|
<h5 class="label">FLO address</h5>
|
|
<sm-input id="get_writer_id" error-text="Incorrect FLO address" data-flo-id required></sm-input>
|
|
</div>
|
|
<div class="grid">
|
|
<h5 class="label">Name</h5>
|
|
<sm-input id="get_writer_name" required></sm-input>
|
|
</div>
|
|
<div class="grid">
|
|
<h5 class="label">Bio</h5>
|
|
<sm-textarea id="get_writer_bio" rows="2"></sm-textarea>
|
|
</div>
|
|
<sm-button id="save_writer" variant="primary" class="cta" onclick="saveWriter()">Add writer</sm-button>
|
|
</sm-form>
|
|
</sm-popup>
|
|
<sm-popup id="user_popup">
|
|
<header slot="header" class="grid gap-1">
|
|
<div class="flex align-center">
|
|
<button class="popup__header__close">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<svg id="user_background" viewBox="0 0 1866 801" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<g clip-path="url(#clip0_1_2)">
|
|
<rect width="1866" height="801" fill="#256EFF" />
|
|
<path d="M655.459 352.774L-428.587 256.546L-150.856 1393.08L655.459 352.774Z" fill="#FFC887" />
|
|
<circle cx="1792" cy="300" r="441" fill="#145FF4" />
|
|
<path d="M299.304 497.528L-155.279 457.524L-39.1418 933.681L299.304 497.528Z" fill="#FFD4A1" />
|
|
<circle cx="1675" cy="36" r="217" fill="#1966FF" />
|
|
</g>
|
|
<defs>
|
|
<clipPath id="clip0_1_2">
|
|
<rect width="1866" height="801" fill="white" />
|
|
</clipPath>
|
|
</defs>
|
|
</svg>
|
|
<h2>Settings</h2>
|
|
</header>
|
|
<section class="grid gap-1-5">
|
|
<div class="grid gap-1">
|
|
<div class="grid gap-0-5">
|
|
<h4>
|
|
BTC integrated with FLO
|
|
</h4>
|
|
<p>
|
|
You can use your FLO private key to perform transactions on the BTC network within our app
|
|
ecosystem. The private key is the same for both.
|
|
</p>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>My FLO address</h5>
|
|
<sm-copy id="user_flo_id"></sm-copy>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h5>My Bitcoin address</h5>
|
|
<sm-copy id="user_btc_id"></sm-copy>
|
|
</div>
|
|
<sm-button class="danger cta justify-self-start" onclick="signOut()">Sign out</sm-button>
|
|
</div>
|
|
<a href="#/dashboard" class="button hide admin-option close-popup-on-click">Admin
|
|
dashboard</a>
|
|
</section>
|
|
</sm-popup>
|
|
<template id="trending_article_template">
|
|
<div class="trending-article grid gap-0-5">
|
|
<a class="article-card--highlight grid gap-0-5" href="" style="color: inherit">
|
|
<img class="trending-article__image" src="" alt="" loading="lazy">
|
|
<div class="flex align-center" style="margin-top: 0.3rem;">
|
|
<time class="trending-article__published h5"></time>
|
|
<span class="bullet-point"></span>
|
|
<span class="trending-article__read-time h5"></span>
|
|
<span class="bullet-point"></span>
|
|
<div class="flex align-center h5">
|
|
<svg class="icon icon--small margin-right-0-3" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z" />
|
|
</svg>
|
|
<span class="trending-article__votes h5"></span>
|
|
</div>
|
|
</div>
|
|
<h3 class="trending-article__title"></h3>
|
|
<p class="trending-article__summary"></p>
|
|
</a>
|
|
<div class="flex align-center trending-article__categories flex-wrap" style="margin-top: 0.3rem;"></div>
|
|
</div>
|
|
</template>
|
|
<template id="article_card_template">
|
|
<li class="article-card grid">
|
|
<a href="" class="grid article-link">
|
|
<img class="article-card__image" src="" alt="" loading="lazy">
|
|
<div class="flex align-center meta-data">
|
|
<time class="article-card__published"></time>
|
|
<span class="bullet-point"></span>
|
|
<span class="article-card__read-time"></span>
|
|
<span class="bullet-point"></span>
|
|
<div class="flex align-center h5">
|
|
<svg class="icon icon--small margin-right-0-3" xmlns="http://www.w3.org/2000/svg" height="24px"
|
|
viewBox="0 0 24 24" width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z" />
|
|
</svg>
|
|
<span class="article-card__votes h5"></span>
|
|
</div>
|
|
</div>
|
|
<h4 class="article-card__title"></h4>
|
|
</a>
|
|
<div class="flex align-center article-card__categories flex-wrap" style="margin-top: 0.3rem;"></div>
|
|
</li>
|
|
</template>
|
|
<template id="article_row_template">
|
|
<li class="grid article-row">
|
|
<!-- <time class="article-row__published"></time> -->
|
|
<h4 class="article-card__title"></h4>
|
|
<div class="flex space-between align-center gap-0-5">
|
|
<div class="flex align-center">
|
|
<svg class="icon margin-right-0-5" style="fill: var(--like-color);"
|
|
xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0z" fill="none" />
|
|
<path
|
|
d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z" />
|
|
</svg>
|
|
<span class="article-row__votes"></span>
|
|
</div>
|
|
<div class="flex gap-0-5">
|
|
<button class="icon-only edit-article">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" />
|
|
</svg>
|
|
</button>
|
|
<button class="icon-only delete-article" title="Delete article">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
</template>
|
|
<template id="request_template">
|
|
<li class="request-card">
|
|
<div class="grid gap-0-5">
|
|
<time class="request-card__time"></time>
|
|
<h4 class="request-card__title"></h4>
|
|
</div>
|
|
<div class="flex space-between align-center gap-0-5">
|
|
<div class="flex gap-0-5">
|
|
<button class="icon-only preview-button" title="Preview article">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z" />
|
|
</svg>
|
|
</button>
|
|
<button class="icon-only delete-request" title="Delete request">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<button class="button button--primary publish-button cta">Publish</button>
|
|
</div>
|
|
</li>
|
|
</template>
|
|
|
|
<template id="article_writer_template">
|
|
<li class="writer-card">
|
|
<div class="flex align-start space-between">
|
|
<div class="writer-profile"></div>
|
|
<div class="flex gap-0-5">
|
|
<button class="icon-only edit-writer" title="Edit details">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M14.06 9.02l.92.92L5.92 19H5v-.92l9.06-9.06M17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29zm-3.6 3.19L3 17.25V21h3.75L17.81 9.94l-3.75-3.75z" />
|
|
</svg>
|
|
</button>
|
|
<button class="icon-only delete-writer" title="Delete writer">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
|
width="24px" fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" />
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="grid gap-0-5">
|
|
<h4 class="writer-name capitalize"></h4>
|
|
<p class="writer-bio"></p>
|
|
</div>
|
|
<sm-copy class="writer-flo-id"></sm-copy>
|
|
</li>
|
|
</template>
|
|
<template id="flo_id_card_template">
|
|
<li class="flo-id-card flex align-center">
|
|
<div class="flo-id"></div>
|
|
<button class="icon-only delete-flo-id" title="Delete approved FLO address">
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
|
fill="#000000">
|
|
<path d="M0 0h24v24H0V0z" fill="none" />
|
|
<path
|
|
d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" />
|
|
</svg>
|
|
</button>
|
|
</li>
|
|
</template>
|
|
<script src="scripts/components.js"></script>
|
|
<script src="scripts/purify.min.js" defer></script>
|
|
<script src="https://unpkg.com/uhtml@3.0.1/es.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.6.2" defer></script>
|
|
<script src="scripts/lib.js"></script>
|
|
<script src="scripts/floCrypto.js"></script>
|
|
<script src="scripts/btcOperator.js"></script>
|
|
<script src="scripts/floBlockchainAPI.js"></script>
|
|
<script src="scripts/compactIDB.js"></script>
|
|
<script src="scripts/floCloudAPI.js"></script>
|
|
<script src="scripts/floDapps.js"></script>
|
|
<script>
|
|
|
|
/**
|
|
* @yaireo/relative-time - javascript function to transform timestamp or date to local relative-time
|
|
*
|
|
* @version v1.0.0
|
|
* @homepage https://github.com/yairEO/relative-time
|
|
*/
|
|
|
|
!function (e, t) { var o = o || {}; "function" == typeof o && o.amd ? o([], t) : "object" == typeof exports && "object" == typeof module ? module.exports = t() : "object" == typeof exports ? exports.RelativeTime = t() : e.RelativeTime = t() }(this, (function () { const e = { year: 31536e6, month: 2628e6, day: 864e5, hour: 36e5, minute: 6e4, second: 1e3 }, t = "en", o = { numeric: "auto" }; function n(e) { e = { locale: (e = e || {}).locale || t, options: { ...o, ...e.options } }, this.rtf = new Intl.RelativeTimeFormat(e.locale, e.options) } return n.prototype = { from(t, o) { const n = t - (o || new Date); for (let t in e) if (Math.abs(n) > e[t] || "second" == t) return this.rtf.format(Math.round(n / e[t]), t) } }, n }));
|
|
</script>
|
|
|
|
<script id="ui_utils">
|
|
// Global variables
|
|
const { html, render: renderElem } = uhtml;
|
|
const domRefs = {}
|
|
const currentYear = new Date().getFullYear();
|
|
|
|
//Checks for internet connection status
|
|
if (!navigator.onLine)
|
|
notify(
|
|
"There seems to be a problem connecting to the internet, Please check you internet connection.",
|
|
"error"
|
|
);
|
|
window.addEventListener("offline", () => {
|
|
notify(
|
|
"There seems to be a problem connecting to the internet, Please check you internet connection.",
|
|
"error",
|
|
{ pinned: true }
|
|
);
|
|
});
|
|
window.addEventListener("online", () => {
|
|
getRef("notification_drawer").clearAll();
|
|
notify("We are back online.", "success");
|
|
});
|
|
|
|
// Use instead of document.getElementById
|
|
function getRef(elementId) {
|
|
if (!domRefs.hasOwnProperty(elementId)) {
|
|
domRefs[elementId] = {
|
|
count: 1,
|
|
ref: null,
|
|
};
|
|
return document.getElementById(elementId);
|
|
} else {
|
|
if (domRefs[elementId].count < 3) {
|
|
domRefs[elementId].count = domRefs[elementId].count + 1;
|
|
return document.getElementById(elementId);
|
|
} else {
|
|
if (!domRefs[elementId].ref)
|
|
domRefs[elementId].ref = document.getElementById(elementId);
|
|
return domRefs[elementId].ref;
|
|
}
|
|
}
|
|
}
|
|
|
|
// returns dom with specified element
|
|
function createElement(tagName, options = {}) {
|
|
const { className, textContent, innerHTML, attributes = {} } = options
|
|
const elem = document.createElement(tagName)
|
|
for (let attribute in attributes) {
|
|
elem.setAttribute(attribute, attributes[attribute])
|
|
}
|
|
if (className)
|
|
elem.className = className
|
|
if (textContent)
|
|
elem.textContent = textContent
|
|
if (innerHTML)
|
|
elem.innerHTML = innerHTML
|
|
return elem
|
|
}
|
|
|
|
// Use when a function needs to be executed after user finishes changes
|
|
const debounce = (callback, wait) => {
|
|
let timeoutId = null;
|
|
return (...args) => {
|
|
window.clearTimeout(timeoutId);
|
|
timeoutId = window.setTimeout(() => {
|
|
callback.apply(null, args);
|
|
}, wait);
|
|
};
|
|
}
|
|
|
|
let zIndex = 10
|
|
// function required for popups or modals to appear
|
|
function openPopup(popupId, pinned) {
|
|
zIndex++
|
|
getRef(popupId).setAttribute('style', `z-index: ${zIndex}`)
|
|
getRef(popupId).show({ pinned })
|
|
return getRef(popupId);
|
|
}
|
|
|
|
// hides the popup or modal
|
|
function closePopup() {
|
|
if (popupStack.peek() === undefined)
|
|
return;
|
|
popupStack.peek().popup.hide()
|
|
}
|
|
|
|
document.addEventListener('popupopened', e => {
|
|
})
|
|
document.addEventListener('popupclosed', e => {
|
|
zIndex--
|
|
switch (e.target.id) {
|
|
case 'preview_popup':
|
|
getRef('preview_container').innerHTML = ''
|
|
break;
|
|
case 'sign_in_popup':
|
|
getRef('sign_in').style = ''
|
|
getRef('sign_in').classList.remove('hide')
|
|
getRef('sign_up').style = ''
|
|
getRef('sign_up').classList.add('hide')
|
|
break;
|
|
}
|
|
})
|
|
|
|
// displays a popup for asking permission. Use this instead of JS confirm
|
|
const getConfirmation = (title, options = {}) => {
|
|
return new Promise(resolve => {
|
|
const { message, cancelText = 'Cancel', confirmText = 'OK' } = options
|
|
openPopup('confirmation_popup', true)
|
|
getRef('confirm_title').textContent = title;
|
|
getRef('confirm_message').textContent = message;
|
|
let cancelButton = getRef('confirmation_popup').children[2].children[0],
|
|
submitButton = getRef('confirmation_popup').children[2].children[1]
|
|
submitButton.textContent = confirmText
|
|
cancelButton.textContent = cancelText
|
|
submitButton.onclick = () => {
|
|
closePopup()
|
|
resolve(true);
|
|
}
|
|
cancelButton.onclick = () => {
|
|
closePopup()
|
|
resolve(false);
|
|
}
|
|
})
|
|
}
|
|
|
|
//Function for displaying toast notifications. pass in error for mode param if you want to show an error.
|
|
function notify(message, mode, options = {}) {
|
|
const { pinned = false, sound = false } = options
|
|
let icon
|
|
switch (mode) {
|
|
case 'success':
|
|
icon = `<svg class="icon icon--success" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 15.172l9.192-9.193 1.415 1.414L10 18l-6.364-6.364 1.414-1.414z"/></svg>`
|
|
break;
|
|
case 'error':
|
|
icon = `<svg class="icon icon--error" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>`
|
|
break;
|
|
}
|
|
getRef("notification_drawer").push(message, { pinned, icon });
|
|
if (mode === 'error') {
|
|
console.error(message)
|
|
}
|
|
}
|
|
|
|
function getFormattedTime(time, format) {
|
|
try {
|
|
if (String(time).indexOf('_'))
|
|
time = String(time).split('_')[0]
|
|
const intTime = parseInt(time)
|
|
if (String(intTime).length < 13)
|
|
time *= 1000
|
|
let [day, month, date, year] = new Date(intTime).toString().split(' '),
|
|
minutes = new Date(intTime).getMinutes(),
|
|
hours = new Date(intTime).getHours(),
|
|
currentTime = new Date().toString().split(' ')
|
|
|
|
minutes = minutes < 10 ? `0${minutes}` : minutes
|
|
let finalHours = ``;
|
|
if (hours > 12)
|
|
finalHours = `${hours - 12}:${minutes}`
|
|
else if (hours === 0)
|
|
finalHours = `12:${minutes}`
|
|
else
|
|
finalHours = `${hours}:${minutes}`
|
|
|
|
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
|
|
switch (format) {
|
|
case 'date-only':
|
|
return `${month} ${date}, ${year}`;
|
|
break;
|
|
default:
|
|
return `${month} ${date} ${year}, ${finalHours}`;
|
|
}
|
|
} catch (e) {
|
|
console.error(e);
|
|
return time;
|
|
}
|
|
}
|
|
// implement event delegation
|
|
function delegate(el, event, selector, fn) {
|
|
el.addEventListener(event, function (e) {
|
|
const potentialTarget = e.target.closest(selector)
|
|
if (potentialTarget) {
|
|
e.delegateTarget = potentialTarget
|
|
fn.call(this, e)
|
|
}
|
|
})
|
|
}
|
|
|
|
window.addEventListener('hashchange', e => showPage(window.location.hash))
|
|
window.addEventListener("load", () => {
|
|
document.body.classList.remove('hide')
|
|
document.querySelectorAll('sm-input[data-flo-id]').forEach(input => input.customValidation = floCrypto.validateAddr)
|
|
document.querySelectorAll('sm-input[data-private-key]').forEach(input => input.customValidation = floCrypto.getPubKeyHex)
|
|
document.addEventListener('keyup', (e) => {
|
|
if (e.key === 'Escape') {
|
|
closePopup()
|
|
}
|
|
})
|
|
document.addEventListener('copy', () => {
|
|
notify('copied', 'success')
|
|
})
|
|
document.addEventListener("pointerdown", (e) => {
|
|
if (e.target.closest("button, sm-button:not([disabled]), .interact")) {
|
|
createRipple(e, e.target.closest("button, sm-button, .interact"));
|
|
}
|
|
});
|
|
document.querySelectorAll('.popup__header__close, .close-popup-on-click').forEach(elem => {
|
|
elem.addEventListener('click', () => {
|
|
closePopup()
|
|
})
|
|
})
|
|
});
|
|
function createRipple(event, target) {
|
|
const circle = document.createElement("span");
|
|
const diameter = Math.max(target.clientWidth, target.clientHeight);
|
|
const radius = diameter / 2;
|
|
const targetDimensions = target.getBoundingClientRect();
|
|
circle.style.width = circle.style.height = `${diameter}px`;
|
|
circle.style.left = `${event.clientX - (targetDimensions.left + radius)}px`;
|
|
circle.style.top = `${event.clientY - (targetDimensions.top + radius)}px`;
|
|
circle.classList.add("ripple");
|
|
const rippleAnimation = circle.animate(
|
|
[
|
|
{
|
|
opacity: 1,
|
|
transform: `scale(0)`
|
|
},
|
|
{
|
|
transform: "scale(4)",
|
|
opacity: 0,
|
|
},
|
|
],
|
|
{
|
|
duration: 600,
|
|
fill: "forwards",
|
|
easing: "ease-out",
|
|
}
|
|
);
|
|
target.append(circle);
|
|
rippleAnimation.onfinish = () => {
|
|
circle.remove();
|
|
};
|
|
}
|
|
|
|
const pagesData = {
|
|
openedPages: [],
|
|
params: {}
|
|
}
|
|
|
|
async function showPage(targetPage, options = {}) {
|
|
const { firstLoad, hashChange, isPreview } = options
|
|
let pageId
|
|
let params = {}
|
|
let searchParams
|
|
if (targetPage === '') {
|
|
pageId = 'main_page'
|
|
} else {
|
|
if (targetPage.includes('/')) {
|
|
if (targetPage.includes('?')) {
|
|
const splitAddress = targetPage.split('?')
|
|
searchParams = splitAddress.pop()
|
|
const pages = splitAddress.pop().split('/')
|
|
pageId = pages[1]
|
|
subPageId = pages[2]
|
|
} else {
|
|
const pages = targetPage.split('/')
|
|
pageId = pages[1]
|
|
subPageId = pages[2]
|
|
}
|
|
} else {
|
|
pageId = targetPage
|
|
}
|
|
}
|
|
if (pageId === 'dashboard' && !floGlobals.isSubAdmin) {
|
|
pageId = 'home'
|
|
history.replaceState(null, null, '#/home')
|
|
}
|
|
if (searchParams) {
|
|
const urlSearchParams = new URLSearchParams('?' + searchParams);
|
|
params = Object.fromEntries(urlSearchParams.entries());
|
|
}
|
|
switch (pageId) {
|
|
case 'home':
|
|
case 'main_page':
|
|
targetPage = 'main_page'
|
|
render.homepage()
|
|
break;
|
|
case 'article':
|
|
targetPage = 'article'
|
|
await render.article(params.articleID)
|
|
break;
|
|
case 'explore':
|
|
targetPage = 'explore'
|
|
render.explorePage(params)
|
|
break;
|
|
case 'writer':
|
|
targetPage = 'writer'
|
|
render.writerPage(params)
|
|
break;
|
|
case 'dashboard':
|
|
targetPage = 'dashboard'
|
|
await Promise.all([
|
|
floCloudAPI.requestObjectData('adminData'),
|
|
floCloudAPI.requestGeneralData('publishing_requests', {
|
|
callback: (d, e) => renderDashboard(d)
|
|
})
|
|
])
|
|
calculateVotes()
|
|
break;
|
|
}
|
|
if (targetPage === 'article') {
|
|
setTimeout(() => {
|
|
window.scroll({ top: 0 })
|
|
}, 0)
|
|
mobileQuery.addListener(handleMobileChange)
|
|
handleMobileChange(mobileQuery)
|
|
articleTitleObserver.observe(getRef('article_title'))
|
|
} else {
|
|
mobileQuery.removeListener(handleMobileChange)
|
|
articleTitleObserver.disconnect()
|
|
}
|
|
if (pageId !== 'loading') {
|
|
getRef('main').classList.remove('hide')
|
|
}
|
|
document.querySelectorAll('.page').forEach(page => page.classList.add('hide'))
|
|
getRef(targetPage).classList.remove('hide')
|
|
getRef(targetPage).animate([{ opacity: 0 }, { opacity: 1 }], { duration: 300, fill: 'forwards', easing: 'ease' })
|
|
if (pagesData.lastPage !== pageId) {
|
|
pagesData.lastPage = pageId
|
|
if (!pagesData.openedPages.includes(pageId)) {
|
|
pagesData.openedPages.push(pageId)
|
|
}
|
|
}
|
|
if (params)
|
|
pagesData.params = params
|
|
}
|
|
// class based lazy loading
|
|
class LazyLoader {
|
|
constructor(container, elementsToRender, renderFn, options = {}) {
|
|
const { batchSize = 10 } = options
|
|
|
|
this.elementsToRender = elementsToRender
|
|
this.arrayOfElements = (typeof elementsToRender === 'function') ? this.elementsToRender() : elementsToRender || []
|
|
this.renderFn = renderFn
|
|
this.intersectionObserver
|
|
|
|
this.batchSize = batchSize
|
|
|
|
this.lazyContainer = document.querySelector(container)
|
|
|
|
this.update = this.update.bind(this)
|
|
this.render = this.render.bind(this)
|
|
this.init = this.init.bind(this)
|
|
this.clear = this.clear.bind(this)
|
|
}
|
|
init() {
|
|
this.intersectionObserver = new IntersectionObserver((entries, observer) => {
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
observer.disconnect()
|
|
this.render({ lazyLoad: true })
|
|
}
|
|
})
|
|
}, {
|
|
threshold: 0.3
|
|
})
|
|
this.mutationObserver = new MutationObserver(mutationList => {
|
|
mutationList.forEach(mutation => {
|
|
if (mutation.type === 'childList') {
|
|
if (mutation.addedNodes.length) {
|
|
this.intersectionObserver.observe(this.lazyContainer.lastElementChild)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
this.mutationObserver.observe(this.lazyContainer, {
|
|
childList: true,
|
|
})
|
|
this.render()
|
|
}
|
|
update(elementsToRender) {
|
|
this.arrayOfElements = (typeof elementsToRender === 'function') ? this.elementsToRender() : elementsToRender || []
|
|
this.render()
|
|
}
|
|
render(options = {}) {
|
|
let { lazyLoad = false } = options
|
|
const frag = document.createDocumentFragment();
|
|
if (lazyLoad) {
|
|
this.updateStartIndex = this.updateEndIndex
|
|
this.updateEndIndex = this.arrayOfElements.length > this.updateEndIndex + this.batchSize ? this.updateEndIndex + this.batchSize : this.arrayOfElements.length
|
|
} else {
|
|
this.intersectionObserver.disconnect()
|
|
this.lazyContainer.innerHTML = ``;
|
|
this.updateStartIndex = 0
|
|
this.updateEndIndex = this.arrayOfElements.length > this.batchSize ? this.batchSize : this.arrayOfElements.length
|
|
}
|
|
for (let index = this.updateStartIndex; index < this.updateEndIndex; index++) {
|
|
frag.append(this.renderFn(this.arrayOfElements[index]))
|
|
}
|
|
this.lazyContainer.append(frag)
|
|
}
|
|
clear() {
|
|
this.intersectionObserver.disconnect()
|
|
this.mutationObserver.disconnect()
|
|
this.lazyContainer.innerHTML = ``;
|
|
}
|
|
reset() {
|
|
this.arrayOfElements = (typeof this.elementsToRender === 'function') ? this.elementsToRender() : this.elementsToRender || []
|
|
this.render()
|
|
}
|
|
}
|
|
function animateTo(element, keyframes, options) {
|
|
const anime = element.animate(keyframes, { ...options, fill: 'both' })
|
|
anime.finished.then(() => {
|
|
anime.commitStyles()
|
|
anime.cancel()
|
|
})
|
|
return anime
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
const openedArticles = {}
|
|
const relativeTime = new RelativeTime({ style: 'narrow' });
|
|
// checks if an article image is already fetched and if not, fetches it and returns the image
|
|
const getImage = (articleID) => new Promise((resolve, reject) => {
|
|
const { heroImage: heroImageVC } = floGlobals.appObjects.rmTimes.articles[articleID]
|
|
if (mappedImages.hasOwnProperty(articleID) && mappedImages[articleID] === heroImageVC) {
|
|
compactIDB.readData('images', articleID).then(image => {
|
|
if (image) {
|
|
resolve(image.heroImage)
|
|
}
|
|
})
|
|
} else {
|
|
floCloudAPI.requestApplicationData('images', {
|
|
atVectorClock: heroImageVC
|
|
}).then(result => {
|
|
const decoded = floCloudAPI.util.decodeMessage(result[0].message)
|
|
compactIDB.writeData('images', {
|
|
heroImage: decoded,
|
|
heroImageVC
|
|
}, articleID)
|
|
mappedImages[articleID] = heroImageVC
|
|
resolve(decoded)
|
|
})
|
|
}
|
|
})
|
|
const render = {
|
|
articleCard(details) {
|
|
const { uid: articleID, categories, title, readTime, published, heroImage, votes } = details
|
|
const clone = getRef('article_card_template').content.cloneNode(true).firstElementChild
|
|
const frag = document.createDocumentFragment()
|
|
categories.forEach(category => {
|
|
frag.append(createElement('a', {
|
|
className: 'article-card__category interact',
|
|
attributes: { href: `#/explore?type=category&query=${category}` },
|
|
textContent: category
|
|
}))
|
|
})
|
|
clone.querySelector('.article-card__categories').append(frag)
|
|
clone.querySelector('.article-card__votes').textContent = votes
|
|
clone.querySelector('.article-link').href = `#/article?articleID=${articleID}`
|
|
clone.querySelector('.article-card__title').textContent = title
|
|
clone.querySelector('.article-card__read-time').textContent = `${readTime} Min read`
|
|
clone.querySelector('.article-card__published').textContent = relativeTime.from(published)
|
|
clone.querySelector('.article-card__image').src = heroImage ? `./images/${heroImage.thumbnail}` : ''
|
|
// getImage(articleID).then(image => {
|
|
// if (image.thumbnail)
|
|
// clone.querySelector('.article-card__image').src = image.thumbnail
|
|
// })
|
|
return clone
|
|
},
|
|
trendingArticleCard(details) {
|
|
const { uid: articleID, categories, title, readTime, published, summary, heroImage, votes } = details
|
|
const clone = getRef('trending_article_template').content.cloneNode(true).firstElementChild
|
|
const frag = document.createDocumentFragment()
|
|
categories.forEach(category => {
|
|
frag.append(createElement('a', {
|
|
className: 'article-card__category interact',
|
|
attributes: { href: `#/explore?type=category&query=${category}` },
|
|
textContent: category
|
|
}))
|
|
})
|
|
clone.querySelector('.trending-article__categories').append(frag)
|
|
clone.querySelector('.trending-article__votes').textContent = votes
|
|
clone.querySelector('.article-card--highlight').href = `#/article?articleID=${articleID}`
|
|
clone.querySelector('.trending-article__title').textContent = title
|
|
clone.querySelector('.trending-article__read-time').textContent = `${readTime} Min read`
|
|
clone.querySelector('.trending-article__published').textContent = relativeTime.from(published)
|
|
clone.querySelector('.trending-article__summary').textContent = summary
|
|
clone.querySelector('.trending-article__image').src = heroImage ? `./images/${heroImage.thumbnail}` : ''
|
|
// getImage(articleID).then(image => {
|
|
// if (image.thumbnail)
|
|
// clone.querySelector('.trending-article__image').src = image.thumbnail
|
|
// })
|
|
return clone
|
|
},
|
|
requestCard(details) {
|
|
const { senderID, message: { articleID, title }, time, vectorClock } = details
|
|
const { publishedVc, rejectedVc, approvedID } = floGlobals.appObjects.adminData
|
|
const shouldRender = (approvedID.hasOwnProperty(senderID) || floGlobals.subAdmins.includes(senderID)) && !publishedVc.hasOwnProperty(vectorClock) && !rejectedVc.hasOwnProperty(vectorClock)
|
|
if (shouldRender) {
|
|
const clone = getRef('request_template').content.cloneNode(true).firstElementChild
|
|
clone.dataset.vc = vectorClock
|
|
clone.querySelector('.request-card__title').textContent = title
|
|
clone.querySelector('.request-card__time').textContent = getFormattedTime(time)
|
|
clone.querySelector('.publish-button').textContent = floGlobals.appObjects.rmTimes.articles.hasOwnProperty(articleID) ? 'Update' : 'Publish'
|
|
return clone
|
|
}
|
|
},
|
|
articleRow(articleID) {
|
|
const { title, published, votes } = floGlobals.appObjects.rmTimes.articles[articleID]
|
|
const clone = getRef('article_row_template').content.cloneNode(true).firstElementChild
|
|
clone.dataset.articleId = articleID
|
|
clone.querySelector('.article-card__title').textContent = title
|
|
// clone.querySelector('.article-row__published').textContent = relativeTime.from(published)
|
|
clone.querySelector('.article-row__votes').textContent = votes
|
|
return clone
|
|
},
|
|
writerCard(writerID) {
|
|
const { name, bio } = floGlobals.appObjects.rmTimes.articleWriters[writerID]
|
|
const clone = getRef('article_writer_template').content.cloneNode(true).firstElementChild
|
|
clone.dataset.writerId = writerID
|
|
clone.querySelector('.writer-profile').textContent = name[0]
|
|
clone.querySelector('.writer-name').textContent = name
|
|
clone.querySelector('.writer-bio').textContent = bio
|
|
clone.querySelector('.writer-flo-id').setAttribute('value', writerID)
|
|
return clone
|
|
},
|
|
floIDCard(floID) {
|
|
const clone = getRef('flo_id_card_template').content.cloneNode(true).firstElementChild
|
|
clone.dataset.floId = floID
|
|
clone.querySelector('.flo-id').textContent = floID
|
|
return clone
|
|
},
|
|
async homepage() {
|
|
const frag = document.createDocumentFragment()
|
|
// Render article topics
|
|
allCategories.forEach(({ title, icon }) => frag.append(createElement('a', {
|
|
attributes: { href: `#/explore?type=category&query=${title.toLowerCase()}` },
|
|
className: 'category interact',
|
|
innerHTML: `${icon}<div>${title}</div>`,
|
|
})))
|
|
getRef('news_categories_list').innerHTML = ''
|
|
getRef('news_categories_list').append(frag)
|
|
const arrOfArticles = getArrayOfObj(floGlobals.appObjects.rmTimes.articles)
|
|
let sortedByVotes = arrOfArticles.sort((a, b) => b.votes - a.votes)
|
|
const allImages = await compactIDB.readAllData('images')
|
|
// Render trending article card
|
|
sortedByVotes.slice(0, 4).forEach(articleDetail => {
|
|
frag.append(render.trendingArticleCard({
|
|
...articleDetail,
|
|
// heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
|
|
}))
|
|
})
|
|
getRef('trending_article_container').innerHTML = ''
|
|
getRef('trending_article_container').append(frag)
|
|
// render latest articles
|
|
const sortedArticles = sortedByVotes.slice(4).sort((a, b) => b.published - a.published)
|
|
sortedArticles.slice(0, 6).forEach(articleDetail => {
|
|
frag.append(render.articleCard({
|
|
...articleDetail,
|
|
// heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
|
|
}))
|
|
})
|
|
getRef('latest_articles_list').innerHTML = ''
|
|
getRef('latest_articles_list').append(frag)
|
|
},
|
|
async article(articleID, firstLoad = true) {
|
|
const frag = document.createDocumentFragment()
|
|
// const [allArticles, allImages] = await Promise.all([compactIDB.readData('appObjects', 'articlesContent'), compactIDB.readAllData('images')])
|
|
const allArticles = await compactIDB.readData('appObjects', 'articlesContent');
|
|
const { title, published, readTime, contributors, updated, summary, categories, heroImage } = floGlobals.appObjects.rmTimes.articles[articleID]
|
|
categories.forEach(category => {
|
|
frag.append(createElement('a', {
|
|
className: 'article-card__category interact',
|
|
attributes: { href: `#/explore?type=category&query=${category}` },
|
|
textContent: category.charAt(0).toUpperCase() + category.slice(1)
|
|
}))
|
|
})
|
|
getRef('article_category').innerHTML = ''
|
|
getRef('article_category').append(frag)
|
|
getRef('article_title').textContent = title
|
|
getRef('article_summary').textContent = summary
|
|
getRef('published_time').textContent = `${getFormattedTime(published, 'date-only')}${updated ? `, Updated ${relativeTime.from(updated)}` : ''}`
|
|
getRef('reading_time').textContent = `${readTime} Min read`
|
|
getRef('article_image').src = heroImage ? `./images/${heroImage.full}` : ''
|
|
getRef('article_body').innerHTML = DOMPurify.sanitize(allArticles[articleID], { FORBID_ATTR: ['style'], ADD_ATTR: ['target'] })
|
|
const allHeadings = getRef('article_body').querySelectorAll('h3')
|
|
allHeadings.forEach(heading => {
|
|
const headingText = heading.textContent
|
|
const headingID = `s${floCrypto.randString(8)}`
|
|
heading.id = headingID
|
|
frag.append(createElement('li', {
|
|
innerHTML: `<button class="heading-shortcut" data-heading-id="${headingID}">${headingText}</button>`
|
|
}))
|
|
})
|
|
getRef('article').querySelector('#article_map_container').innerHTML = ''
|
|
getRef('article').querySelector('#article_map_container').append(frag)
|
|
allHeadings.forEach(heading => {
|
|
headingObserver.observe(heading.nextElementSibling)
|
|
})
|
|
const contributorList = contributors.filter(v => v).map(id => {
|
|
const contributorName = floGlobals.appObjects.rmTimes.articleWriters.hasOwnProperty(id) ? floGlobals.appObjects.rmTimes.articleWriters[id].name : id;
|
|
return html` <a href="${`#/writer?id=${id}`}" class="contributor"> ${contributorName} </a> `
|
|
})
|
|
renderElem(getRef('article_contributors'), html`${contributorList}`)
|
|
|
|
const fuse = new Fuse(getArrayOfObj(floGlobals.appObjects.rmTimes.articles), { keys: ['categories'], threshold: 0, useExtendedSearch: true })
|
|
const searchResult = fuse.search(categories.join('|')).map(v => v.item).filter(v => v.uid !== articleID)
|
|
let randomNumbers = []
|
|
if (searchResult.length > 3) {
|
|
// generate non-repeating random numbers
|
|
while (randomNumbers.length < 3) {
|
|
const randomNumber = Math.floor(Math.random() * searchResult.length)
|
|
if (!randomNumbers.includes(randomNumber)) {
|
|
randomNumbers.push(randomNumber)
|
|
}
|
|
}
|
|
} else {
|
|
randomNumbers = searchResult.map((v, i) => i)
|
|
}
|
|
randomNumbers.forEach((index) => {
|
|
const { uid } = searchResult[index]
|
|
frag.append(render.articleCard({ ...searchResult[index], /* heroImage: allImages[uid] ? allImages[uid].heroImage.thumbnail : '' */ }))
|
|
})
|
|
getRef('related_articles').innerHTML = ''
|
|
getRef('related_articles').append(frag)
|
|
|
|
// implement live voting
|
|
getRef('like_count').textContent = floGlobals.appObjects.rmTimes.articles[articleID].votes
|
|
if (!openedArticles.hasOwnProperty(articleID)) {
|
|
floCloudAPI.requestApplicationData(`article_${articleID}_votes`, {
|
|
lowerVectorClock: floGlobals.appObjects.rmTimes.articles[articleID].lastCountedVC + 1,
|
|
callback: (allVotes, e) => {
|
|
if (firstLoad) {
|
|
for (const vote in allVotes) {
|
|
floGlobals.appObjects.rmTimes.articles[articleID].votes += allVotes[vote].message.voteCount || 1
|
|
}
|
|
getRef('like_count').textContent = floGlobals.appObjects.rmTimes.articles[articleID].votes
|
|
} else {
|
|
for (const msg in allVotes) {
|
|
animateLikeCount(allVotes[msg].message.voteCount, articleID)
|
|
}
|
|
}
|
|
firstLoad = false
|
|
}
|
|
})
|
|
openedArticles[articleID] = true
|
|
} else {
|
|
getRef('like_count').textContent = floGlobals.appObjects.rmTimes.articles[articleID].votes
|
|
}
|
|
},
|
|
async explorePage(params) {
|
|
// const allImages = await compactIDB.readAllData('images')
|
|
const { type, query } = params
|
|
const frag = document.createDocumentFragment()
|
|
const sortedByTime = getArrayOfObj(floGlobals.appObjects.rmTimes.articles).sort((a, b) => b.published - a.published)
|
|
if (type === 'recent') {
|
|
sortedByTime.forEach(articleDetail => {
|
|
frag.append(render.trendingArticleCard({
|
|
...articleDetail,
|
|
// heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
|
|
}))
|
|
})
|
|
getRef('explore_heading').textContent = 'Explore all'
|
|
} else {
|
|
const options = (type === 'category') ? { keys: ['categories'], threshold: 0 } : { keys: ['title', 'tags'], threshold: 0, ignoreLocation: true }
|
|
const fuse = new Fuse(sortedByTime, options)
|
|
const searchResult = fuse.search(query).map(v => v.item)
|
|
searchResult.forEach(articleDetail => {
|
|
frag.append(render.trendingArticleCard({
|
|
...articleDetail,
|
|
// heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
|
|
}))
|
|
})
|
|
getRef('explore_heading').textContent = `${type === 'category' ? 'Explore' : 'Related to'} ${query}`
|
|
}
|
|
getRef('query_results_list').innerHTML = ''
|
|
getRef('query_results_list').append(frag)
|
|
},
|
|
async writerPage(params) {
|
|
// const allImages = await compactIDB.readAllData('images')
|
|
if (floGlobals.appObjects.rmTimes.articleWriters.hasOwnProperty(params.id)) {
|
|
const { name, bio } = floGlobals.appObjects.rmTimes.articleWriters[params.id]
|
|
getRef('writer_initials').textContent = name.split(' ').map(v => v.charAt(0)).join('')
|
|
getRef('writer_name').textContent = name
|
|
getRef('writer_bio').textContent = bio
|
|
} else {
|
|
getRef('writer_initials').textContent = 'F'
|
|
getRef('writer_name').textContent = ''
|
|
getRef('writer_bio').textContent = ''
|
|
}
|
|
getRef('writer_id').value = params.id
|
|
const frag = document.createDocumentFragment()
|
|
const sortedByTime = getArrayOfObj(floGlobals.appObjects.rmTimes.articles).sort((a, b) => b.published - a.published)
|
|
const options = { keys: ['contributors'], threshold: 0 }
|
|
const fuse = new Fuse(sortedByTime, options)
|
|
const searchResult = fuse.search(params.id).map(v => v.item)
|
|
searchResult.forEach(articleDetail => {
|
|
frag.append(render.trendingArticleCard({
|
|
...articleDetail,
|
|
// heroImage: allImages[articleDetail.uid] ? allImages[articleDetail.uid].heroImage.thumbnail : ''
|
|
}))
|
|
})
|
|
getRef('written_article_list').innerHTML = ''
|
|
getRef('written_article_list').append(frag)
|
|
},
|
|
}
|
|
|
|
let mappedImages = {}
|
|
const getArticles = async () => {
|
|
compactIDB.readAllData('images').then(allImages => {
|
|
for (const imageID in allImages) {
|
|
mappedImages[imageID] = allImages[imageID].heroImageVC
|
|
}
|
|
})
|
|
Promise.all([
|
|
floCloudAPI.requestObjectData('rmTimes'),
|
|
floCloudAPI.requestObjectData('articlesContent'),
|
|
]).then((res) => {
|
|
delete floGlobals.appObjects.articlesContent
|
|
showPage(window.location.hash, { firstLoad: true })
|
|
})
|
|
}
|
|
|
|
// Create array of objects from object of objects
|
|
function getArrayOfObj(obj) {
|
|
const arr = []
|
|
for (const key in obj) {
|
|
arr.push({
|
|
uid: key,
|
|
...obj[key]
|
|
})
|
|
}
|
|
return arr
|
|
}
|
|
|
|
const allCategories = [
|
|
{
|
|
title: 'Culture',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><g><g><g><path d="M12,22C6.49,22,2,17.51,2,12S6.49,2,12,2s10,4.04,10,9c0,3.31-2.69,6-6,6h-1.77c-0.28,0-0.5,0.22-0.5,0.5 c0,0.12,0.05,0.23,0.13,0.33c0.41,0.47,0.64,1.06,0.64,1.67C14.5,20.88,13.38,22,12,22z M12,4c-4.41,0-8,3.59-8,8s3.59,8,8,8 c0.28,0,0.5-0.22,0.5-0.5c0-0.16-0.08-0.28-0.14-0.35c-0.41-0.46-0.63-1.05-0.63-1.65c0-1.38,1.12-2.5,2.5-2.5H16 c2.21,0,4-1.79,4-4C20,7.14,16.41,4,12,4z"/><circle cx="6.5" cy="11.5" r="1.5"/><circle cx="9.5" cy="7.5" r="1.5"/><circle cx="14.5" cy="7.5" r="1.5"/><circle cx="17.5" cy="11.5" r="1.5"/></g></g></g></g></svg>`
|
|
},
|
|
{
|
|
title: 'Crypto',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M17.06,11.57C17.65,10.88,18,9.98,18,9c0-1.86-1.27-3.43-3-3.87L15,3h-2v2h-2V3H9v2H6v2h2v10H6v2h3v2h2v-2h2v2h2v-2 c2.21,0,4-1.79,4-4C19,13.55,18.22,12.27,17.06,11.57z M10,7h4c1.1,0,2,0.9,2,2s-0.9,2-2,2h-4V7z M15,17h-5v-4h5c1.1,0,2,0.9,2,2 S16.1,17,15,17z"/></g></svg>`
|
|
},
|
|
{
|
|
title: 'Discover',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-5.5-2.5l7.51-3.49L17.5 6.5 9.99 9.99 6.5 17.5zm5.5-6.6c.61 0 1.1.49 1.1 1.1s-.49 1.1-1.1 1.1-1.1-.49-1.1-1.1.49-1.1 1.1-1.1z"/></svg>`
|
|
},
|
|
{
|
|
title: 'Economics',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M20 7h-4V5l-2-2h-4L8 5v2H4c-1.1 0-2 .9-2 2v5c0 .75.4 1.38 1 1.73V19c0 1.11.89 2 2 2h14c1.11 0 2-.89 2-2v-3.28c.59-.35 1-.99 1-1.72V9c0-1.1-.9-2-2-2zM10 5h4v2h-4V5zM4 9h16v5h-5v-3H9v3H4V9zm9 6h-2v-2h2v2zm6 4H5v-3h4v1h6v-1h4v3z"/></svg>`
|
|
},
|
|
{
|
|
title: 'Fiction',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><g/><g><path d="M12,3c-0.46,0-0.93,0.04-1.4,0.14C7.84,3.67,5.64,5.9,5.12,8.66c-0.48,2.61,0.48,5.01,2.22,6.56 C7.77,15.6,8,16.13,8,16.69V19c0,1.1,0.9,2,2,2h0.28c0.35,0.6,0.98,1,1.72,1s1.38-0.4,1.72-1H14c1.1,0,2-0.9,2-2v-2.31 c0-0.55,0.22-1.09,0.64-1.46C18.09,13.95,19,12.08,19,10C19,6.13,15.87,3,12,3z M14,17h-4v-1h4V17z M10,19v-1h4v1H10z M15.31,13.74c-0.09,0.08-0.16,0.18-0.24,0.26H8.92c-0.08-0.09-0.15-0.19-0.24-0.27c-1.32-1.18-1.91-2.94-1.59-4.7 c0.36-1.94,1.96-3.55,3.89-3.93C11.32,5.03,11.66,5,12,5c2.76,0,5,2.24,5,5C17,11.43,16.39,12.79,15.31,13.74z"/></g><g><rect height="3" width="1" x="11.5" y="11"/><rect height="3" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -4.0312 10.8536)" width="1" x="10.59" y="8.79"/><rect height="3" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 14.7678 26.7028)" width="1" x="12.41" y="8.79"/></g></g></svg>`
|
|
},
|
|
{
|
|
title: 'Film',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M5.76 10H20v8H4V6.47M22 4h-4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4z"/></svg>`
|
|
},
|
|
{
|
|
title: 'History',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M6.5 10h-2v7h2v-7zm6 0h-2v7h2v-7zm8.5 9H2v2h19v-2zm-2.5-9h-2v7h2v-7zm-7-6.74L16.71 6H6.29l5.21-2.74m0-2.26L2 6v2h19V6l-9.5-5z"/></svg>`
|
|
},
|
|
{
|
|
title: 'People',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24" x="0"/></g><g><path d="M22.47,5.2C22,4.96,21.51,4.76,21,4.59v12.03C19.86,16.21,18.69,16,17.5,16c-1.9,0-3.78,0.54-5.5,1.58V5.48 C10.38,4.55,8.51,4,6.5,4C4.71,4,3.02,4.44,1.53,5.2C1.2,5.36,1,5.71,1,6.08v12.08c0,0.58,0.47,0.99,1,0.99 c0.16,0,0.32-0.04,0.48-0.12C3.69,18.4,5.05,18,6.5,18c2.07,0,3.98,0.82,5.5,2c1.52-1.18,3.43-2,5.5-2c1.45,0,2.81,0.4,4.02,1.04 c0.16,0.08,0.32,0.12,0.48,0.12c0.52,0,1-0.41,1-0.99V6.08C23,5.71,22.8,5.36,22.47,5.2z M10,16.62C8.86,16.21,7.69,16,6.5,16 c-1.19,0-2.36,0.21-3.5,0.62V6.71C4.11,6.24,5.28,6,6.5,6C7.7,6,8.89,6.25,10,6.72V16.62z M19,0.5l-5,5V15l5-4.5V0.5z"/></g></svg>`
|
|
},
|
|
{
|
|
title: 'Politics',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><path d="M18,11c0,0.67,0,1.33,0,2c1.2,0,2.76,0,4,0c0-0.67,0-1.33,0-2C20.76,11,19.2,11,18,11z"/><path d="M16,17.61c0.96,0.71,2.21,1.65,3.2,2.39c0.4-0.53,0.8-1.07,1.2-1.6c-0.99-0.74-2.24-1.68-3.2-2.4 C16.8,16.54,16.4,17.08,16,17.61z"/><path d="M20.4,5.6C20,5.07,19.6,4.53,19.2,4c-0.99,0.74-2.24,1.68-3.2,2.4c0.4,0.53,0.8,1.07,1.2,1.6 C18.16,7.28,19.41,6.35,20.4,5.6z"/><path d="M4,9c-1.1,0-2,0.9-2,2v2c0,1.1,0.9,2,2,2h1v4h2v-4h1l5,3V6L8,9H4z M9.03,10.71L11,9.53v4.94l-1.97-1.18L8.55,13H8H4v-2h4 h0.55L9.03,10.71z"/><path d="M15.5,12c0-1.33-0.58-2.53-1.5-3.35v6.69C14.92,14.53,15.5,13.33,15.5,12z"/></svg>`
|
|
},
|
|
{
|
|
title: 'Science',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M13,11.33L18,18H6l5-6.67V6h2 M15.96,4H8.04C7.62,4,7.39,4.48,7.65,4.81L9,6.5v4.17L3.2,18.4C2.71,19.06,3.18,20,4,20h16 c0.82,0,1.29-0.94,0.8-1.6L15,10.67V6.5l1.35-1.69C16.61,4.48,16.38,4,15.96,4L15.96,4z"/></g></svg>`
|
|
},
|
|
{
|
|
title: 'Sustenance',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><rect fill="none" height="24" width="24"/><path d="M12.87,11.81c-0.23-0.38-0.37-0.83-0.37-1.31C12.5,9.12,13.62,8,15,8l1,0c1.51,0,2-1,2-1s0.55,6-3,6 c-0.49,0-0.94-0.14-1.32-0.38c-0.24,0.64-0.59,1.76-0.76,2.96c1.26,0.22,2.28,0.89,2.77,1.77c1.69-1.17,2.81-3.13,2.81-5.35h3 c0,5.24-4.26,9.5-9.5,9.5S2.5,17.24,2.5,12S6.76,2.5,12,2.5V0l4,4l-4,4V5.5c-3.58,0-6.5,2.92-6.5,6.5c0,2.21,1.11,4.17,2.81,5.35 c0.51-0.92,1.63-1.62,2.98-1.8c-0.09-0.69-0.26-1.42-0.49-2.03C10.45,13.82,10,14,9.5,14c-1.1,0-2-0.9-2-2v-0.99 c0-0.56-0.19-1.09-0.5-1.51c0,0,4.45-0.23,4.5,2.5c0,0.29-0.06,0.56-0.17,0.8C10.91,12.48,10.47,12.2,10,12 c0.58,0.43,1.37,1.37,2,2.6c0.67-1.62,1.68-3.27,3-4.6C14.24,10.52,13.53,11.12,12.87,11.81z"/></svg>`
|
|
},
|
|
{
|
|
title: 'Tech',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M19.93,8.35l-3.6,1.68L14,7.7V6.3l2.33-2.33l3.6,1.68c0.38,0.18,0.82,0.01,1-0.36c0.18-0.38,0.01-0.82-0.36-1l-3.92-1.83 c-0.38-0.18-0.83-0.1-1.13,0.2L13.78,4.4C13.6,4.16,13.32,4,13,4c-0.55,0-1,0.45-1,1v1H8.82C8.4,4.84,7.3,4,6,4C4.34,4,3,5.34,3,7 c0,1.1,0.6,2.05,1.48,2.58L7.08,18H6c-1.1,0-2,0.9-2,2v1h13v-1c0-1.1-0.9-2-2-2h-1.62L8.41,8.77C8.58,8.53,8.72,8.28,8.82,8H12v1 c0,0.55,0.45,1,1,1c0.32,0,0.6-0.16,0.78-0.4l1.74,1.74c0.3,0.3,0.75,0.38,1.13,0.2l3.92-1.83c0.38-0.18,0.54-0.62,0.36-1 C20.75,8.34,20.31,8.17,19.93,8.35z M6,8C5.45,8,5,7.55,5,7c0-0.55,0.45-1,1-1s1,0.45,1,1C7,7.55,6.55,8,6,8z M11.11,18H9.17 l-2.46-8h0.1L11.11,18z"/></g></svg>`
|
|
},
|
|
{
|
|
title: 'World',
|
|
icon: `<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-.61.08-1.21.21-1.78L8.99 15v1c0 1.1.9 2 2 2v1.93C7.06 19.43 4 16.07 4 12zm13.89 5.4c-.26-.81-1-1.4-1.9-1.4h-1v-3c0-.55-.45-1-1-1h-6v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41C17.92 5.77 20 8.65 20 12c0 2.08-.81 3.98-2.11 5.4z"/></svg>`
|
|
},
|
|
]
|
|
|
|
const headingObserver = new IntersectionObserver(entries => {
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
const allShortcuts = [...getRef('article').querySelectorAll('.heading-shortcut')]
|
|
allShortcuts.forEach(elem => elem.classList.remove('active'))
|
|
allShortcuts.find(elem => elem.dataset.headingId === entry.target.previousElementSibling.id).classList.add('active')
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
let isSearchOn = false
|
|
function revealSearch() {
|
|
const animOptions = {
|
|
easing: 'ease',
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
}
|
|
if (!isSearchOn && getRef('expanding_search').classList.contains('hide-on-mobile')) {
|
|
getRef('expanding_search').classList.remove('hide-on-mobile')
|
|
getRef('search_articles').focusIn()
|
|
getRef('expanding_search').animate([
|
|
{
|
|
transform: 'scale(0.95)',
|
|
},
|
|
{
|
|
transform: 'scale(1)',
|
|
},
|
|
], animOptions).onfinish = e => {
|
|
isSearchOn = true
|
|
}
|
|
}
|
|
}
|
|
function hideSearch() {
|
|
const animOptions = {
|
|
easing: 'ease',
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
}
|
|
if (isSearchOn && !getRef('expanding_search').classList.contains('hide-on-mobile')) {
|
|
getRef('expanding_search').animate([
|
|
{
|
|
transform: 'scale(1)',
|
|
},
|
|
{
|
|
transform: 'scale(0.95)',
|
|
},
|
|
], animOptions)
|
|
.onfinish = (e) => {
|
|
getRef('expanding_search').classList.add('hide-on-mobile');
|
|
getRef('search_articles').value = ''
|
|
e.target.cancel()
|
|
isSearchOn = false
|
|
}
|
|
}
|
|
}
|
|
getRef('search_articles').addEventListener('input', debounce((e) => {
|
|
const searchKey = e.target.value.trim()
|
|
if (searchKey !== '') {
|
|
const options = {
|
|
threshold: 0,
|
|
ignoreLocation: true
|
|
}
|
|
const maxSuggestions = 6;
|
|
const allSortedArticles = getArrayOfObj(floGlobals.appObjects.rmTimes.articles).sort((a, b) => b.published - a.published);
|
|
const titleSearch = new Fuse(allSortedArticles, { ...options, keys: ['title'] })
|
|
const titleSearchResult = titleSearch.search(searchKey).map(v => v.item)
|
|
const regEx = new RegExp(`(${searchKey})`, 'gi')
|
|
let suggestions = titleSearchResult.slice(0, maxSuggestions).map((result) => {
|
|
const { uid, title } = result
|
|
const pre = createElement('pre', { innerHTML: title.replace(regEx, `<span>$&</span>`), })
|
|
return html`<a class="search-suggestion interact" href="${`#/article?articleID=${uid}`}">${pre}</a>`;
|
|
})
|
|
// check for related tags if titles don't have enough exact matches
|
|
if (titleSearchResult.length < 4) {
|
|
const tagSearch = new Fuse(allSortedArticles, { ...options, keys: ['tags'] })
|
|
const tagSearchResult = tagSearch.search(searchKey).map(v => v.item)
|
|
const tagSuggestions = tagSearchResult.slice(0, maxSuggestions - titleSearchResult.length).map((result) => {
|
|
const { uid, title } = result
|
|
return html`<a class="search-suggestion interact" href="${`#/article?articleID=${uid}`}">${title}</a>`;
|
|
})
|
|
if (tagSuggestions.length) {
|
|
const related = html`<p class="more-related">Might be related</p>`
|
|
suggestions = [...suggestions, related, ...tagSuggestions]
|
|
}
|
|
}
|
|
if (titleSearchResult.length > maxSuggestions) {
|
|
const seeMore = html.node`<a class="search-suggestion interact" href="${`#/explore?type=search&query=${searchKey}`}">See all results</a>`;
|
|
suggestions.push(seeMore)
|
|
}
|
|
renderElem(getRef('search_suggestions'), html`${suggestions}`)
|
|
if (suggestions.length === 0) {
|
|
renderElem(getRef('search_suggestions'), html`<div style="padding: 0.5rem 1rem">No articles related to <strong>${searchKey}</strong></div>`)
|
|
}
|
|
getRef('search_suggestions').classList.remove('hide')
|
|
} else {
|
|
getRef('search_suggestions').classList.add('hide')
|
|
}
|
|
}, 200))
|
|
|
|
getRef('search_articles').addEventListener('keyup', e => {
|
|
// detect enter key press
|
|
if (e.target.value.trim() !== '' && e.key === 'Enter') {
|
|
location.hash = `#/explore?type=search&query=${e.target.value.trim()}`
|
|
e.target.value = ''
|
|
hideSearch()
|
|
}
|
|
})
|
|
|
|
delegate(getRef('search_suggestions'), 'click', '.search-suggestion', e => {
|
|
getRef('search_articles').value = ''
|
|
hideSearch()
|
|
})
|
|
const slideInLeft = [
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateX(1rem)'
|
|
},
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateX(0)'
|
|
}
|
|
]
|
|
const slideOutLeft = [
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateX(0)'
|
|
},
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateX(-1rem)'
|
|
},
|
|
]
|
|
const slideInRight = [
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateX(-1rem)'
|
|
},
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateX(0)'
|
|
}
|
|
]
|
|
const slideOutRight = [
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateX(0)'
|
|
},
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateX(1rem)'
|
|
},
|
|
]
|
|
const slideInDown = [
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateY(-1rem)'
|
|
},
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateY(0)'
|
|
},
|
|
]
|
|
const slideInUp = [
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateY(1rem)'
|
|
},
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateY(0)'
|
|
},
|
|
]
|
|
const slideOutUp = [
|
|
{
|
|
opacity: 1,
|
|
transform: 'translateY(0)'
|
|
},
|
|
{
|
|
opacity: 0,
|
|
transform: 'translateY(-1rem)'
|
|
},
|
|
]
|
|
|
|
let tempVoteCount = 0
|
|
getRef('upvote_button').addEventListener('mouseup', function () {
|
|
if (typeof myFloID !== 'undefined') {
|
|
tempVoteCount++;
|
|
const animOptions = {
|
|
fill: 'forwards',
|
|
duration: 300,
|
|
ease: 'easing',
|
|
}
|
|
const ring = document.createElement('div')
|
|
ring.classList.add('ring')
|
|
ring.animate([
|
|
{ transform: 'none' },
|
|
{ transform: 'scale(6)', opacity: 0 }
|
|
], animOptions).onfinish = e => {
|
|
e.target.cancel()
|
|
ring.remove()
|
|
}
|
|
this.append(ring)
|
|
this.firstElementChild.animate([
|
|
{ transform: 'scale(0.5)' },
|
|
{ transform: 'scale(1.4)', offset: 0.5 },
|
|
{ transform: 'none' },
|
|
], animOptions).onfinish = e => e.target.cancel()
|
|
}
|
|
})
|
|
function animateLikeCount(voteCount = 1, articleID) {
|
|
const animOptions = {
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
ease: 'easing',
|
|
}
|
|
floGlobals.appObjects.rmTimes.articles[articleID].votes += voteCount
|
|
getRef('like_count').animate(slideOutUp, animOptions)
|
|
.onfinish = (e) => {
|
|
e.target.cancel()
|
|
}
|
|
const tempCount = document.createElement('div')
|
|
tempCount.classList.add('temp-count')
|
|
tempCount.textContent = floGlobals.appObjects.rmTimes.articles[articleID].votes
|
|
getRef('like_count').after(tempCount)
|
|
tempCount.animate(slideInUp, animOptions)
|
|
.onfinish = () => {
|
|
getRef('like_count').textContent = floGlobals.appObjects.rmTimes.articles[articleID].votes
|
|
tempCount.remove()
|
|
}
|
|
}
|
|
delegate(getRef('article'), 'click', '.heading-shortcut', (e) => {
|
|
const button = e.target.closest('.heading-shortcut');
|
|
const headingID = button.dataset.headingId;
|
|
const heading = getRef('article_body').querySelector(`#${headingID}`)
|
|
heading.scrollIntoView({
|
|
behavior: 'smooth'
|
|
})
|
|
})
|
|
getRef('upvote_button').addEventListener('click', debounce(() => {
|
|
if (typeof myFloID !== 'undefined') {
|
|
floCloudAPI.sendApplicationData({
|
|
voteCount: tempVoteCount,
|
|
}, `article_${pagesData.params.articleID}_votes`)
|
|
.then(res => {
|
|
tempVoteCount = 0
|
|
})
|
|
.catch(err => console.log(err))
|
|
} else {
|
|
openPopup('sign_in_popup')
|
|
}
|
|
}, 300))
|
|
|
|
function sharePreview() {
|
|
if (window.navigator.share) {
|
|
navigator.share({
|
|
title: "Share article preview",
|
|
url: window.location.href
|
|
})
|
|
} else {
|
|
getRef('shared_url').value = window.location.href
|
|
openPopup('share_popup')
|
|
}
|
|
}
|
|
|
|
const articleTitleObserver = new IntersectionObserver(entries => {
|
|
const animOptions = {
|
|
easing: 'ease',
|
|
duration: 150
|
|
}
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
if (getRef('go_to_top').classList.contains('hide')) return
|
|
getRef('go_to_top').animate([
|
|
{
|
|
transform: 'none',
|
|
opacity: 1
|
|
},
|
|
{
|
|
transform: 'translateY(1rem)',
|
|
opacity: 0
|
|
},
|
|
], animOptions).onfinish = () => {
|
|
getRef('go_to_top').classList.add('hide')
|
|
}
|
|
} else {
|
|
getRef('go_to_top').classList.remove('hide')
|
|
getRef('go_to_top').animate([
|
|
{
|
|
transform: 'translateY(1rem)',
|
|
opacity: 0
|
|
},
|
|
{
|
|
opacity: 1,
|
|
transform: 'none',
|
|
},
|
|
], animOptions)
|
|
|
|
}
|
|
})
|
|
}, {
|
|
threshold: 0.8
|
|
})
|
|
|
|
function goToTop() {
|
|
window.scroll({
|
|
top: 0,
|
|
behavior: 'smooth'
|
|
});
|
|
}
|
|
|
|
let isMobileView = false
|
|
const mobileQuery = window.matchMedia('(max-width: 40rem)')
|
|
function handleMobileChange(e) {
|
|
isMobileView = e.matches
|
|
// move article key points
|
|
if (isMobileView) {
|
|
const original = getRef('article_map').querySelector('#article_map_container')
|
|
if (original) {
|
|
const clone = original.cloneNode(true)
|
|
original.remove()
|
|
getRef('article_map_accordion').append(clone)
|
|
}
|
|
} else {
|
|
const original = getRef('article_map_accordion').querySelector('#article_map_container')
|
|
if (original) {
|
|
const clone = original.cloneNode(true)
|
|
original.remove()
|
|
getRef('article_map').append(clone)
|
|
}
|
|
getRef('expanding_search').getAnimations().forEach(anim => anim.cancel())
|
|
}
|
|
const allHeadings = getRef('article_body').querySelectorAll('h3')
|
|
allHeadings.forEach(heading => {
|
|
headingObserver.observe(heading.nextElementSibling)
|
|
})
|
|
}
|
|
|
|
function generateCredentials() {
|
|
const animOptions = {
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
ease: 'easing',
|
|
}
|
|
const { floID, privKey } = floCrypto.generateNewID()
|
|
getRef('generated_flo_id').value = floID
|
|
getRef('generated_private_key').value = privKey
|
|
getRef('sign_in').animate(slideOutLeft, animOptions).onfinish = () => {
|
|
getRef('sign_in').classList.add('hide')
|
|
getRef('sign_up').classList.remove('hide')
|
|
getRef('sign_up').animate(slideInLeft, animOptions)
|
|
}
|
|
}
|
|
function goToSignIn() {
|
|
const animOptions = {
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
ease: 'easing',
|
|
}
|
|
getRef('sign_up').animate(slideOutRight, animOptions).onfinish = () => {
|
|
getRef('sign_in').classList.remove('hide')
|
|
getRef('sign_in').animate(slideInRight, animOptions)
|
|
getRef('sign_up').classList.add('hide')
|
|
}
|
|
}
|
|
function getSignedIn() {
|
|
return new Promise((resolve, reject) => {
|
|
getRef('sign_in_button').onclick = () => {
|
|
resolve(getRef('private_key_field').value.trim())
|
|
getRef('private_key_field').value = ''
|
|
closePopup()
|
|
notify('Signed in', 'success')
|
|
}
|
|
getRef('sign_up_button').onclick = () => {
|
|
getConfirmation('Sign in?', { message: 'Make sure you have copied your private key.' })
|
|
.then((res) => {
|
|
if (res) {
|
|
resolve(getRef('generated_private_key').value.trim())
|
|
getRef('generated_private_key').value = ''
|
|
closePopup()
|
|
notify('Signed in', 'success')
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
function signOut() {
|
|
getConfirmation('Sign out?', 'You are about to sign out of the app, continue?', 'Stay', 'Leave')
|
|
.then(async (res) => {
|
|
if (res) {
|
|
await floDapps.clearCredentials()
|
|
location.reload()
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
// RanchiMall Times admin functions
|
|
async function renderDashboard() {
|
|
const requests = floGlobals.generalData[`publishing_requests|${floGlobals.adminID}|${floGlobals.application}`]
|
|
const frag = document.createDocumentFragment()
|
|
for (const key in requests) {
|
|
const card = render.requestCard(requests[key])
|
|
if (card)
|
|
frag.prepend(card)
|
|
}
|
|
getRef('publishing_requests').innerHTML = ''
|
|
getRef('publishing_requests').append(frag)
|
|
|
|
for (const articleKey in floGlobals.appObjects.rmTimes.articles) {
|
|
frag.prepend(render.articleRow(articleKey))
|
|
}
|
|
getRef('article_analytics').innerHTML = ''
|
|
getRef('article_analytics').append(frag)
|
|
|
|
for (const articleKey in floGlobals.appObjects.rmTimes.articleWriters) {
|
|
frag.prepend(render.writerCard(articleKey))
|
|
}
|
|
getRef('writers_list').innerHTML = ''
|
|
getRef('writers_list').append(frag)
|
|
|
|
for (const floID in floGlobals.appObjects.adminData.approvedID) {
|
|
frag.prepend(render.floIDCard(floID))
|
|
}
|
|
getRef('approved_ids').innerHTML = ''
|
|
getRef('approved_ids').append(frag)
|
|
|
|
allCategories.forEach(({ title }) => {
|
|
frag.append(createElement('label', {
|
|
className: 'category-chip interact',
|
|
attributes: { tabindex: 0 },
|
|
innerHTML: `
|
|
<input type="checkbox" name="category" value="${title.toLowerCase()}" />
|
|
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>
|
|
<span class="checkmark">${title}</span>
|
|
`
|
|
}))
|
|
})
|
|
getRef('edit_category').innerHTML = ''
|
|
getRef('edit_category').append(frag)
|
|
}
|
|
|
|
|
|
function showLoader(loadingText) {
|
|
const animOptions = {
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
ease: 'easing',
|
|
}
|
|
getRef('set_article_meta').animate(slideOutUp, animOptions)
|
|
.onfinish = () => {
|
|
getRef('set_article_meta').disabled = true
|
|
getRef('set_article_meta').classList.add('hide')
|
|
const loader = createElement('div', {
|
|
className: 'flex align-center justify-center gap-0-5 cta w-100',
|
|
innerHTML: `<sm-spinner></sm-spinner> ${loadingText}`
|
|
})
|
|
getRef('set_article_meta').after(loader)
|
|
loader.animate(slideInUp, animOptions)
|
|
}
|
|
}
|
|
function hideLoader(loadingText) {
|
|
const animOptions = {
|
|
fill: 'forwards',
|
|
duration: 150,
|
|
ease: 'easing',
|
|
}
|
|
getRef('set_article_meta').nextElementSibling.animate(slideOutUp, animOptions)
|
|
.onfinish = () => {
|
|
getRef('set_article_meta').disabled = false
|
|
getRef('set_article_meta').textContent = loadingText
|
|
getRef('set_article_meta').nextElementSibling.remove()
|
|
getRef('set_article_meta').classList.remove('hide')
|
|
getRef('set_article_meta').animate(slideInUp, animOptions)
|
|
}
|
|
}
|
|
function publishArticle(vc) {
|
|
const { message: { articleID, content, contributors, title, readTime }, vectorClock } = floGlobals.generalData[`publishing_requests|${floGlobals.adminID}|${floGlobals.application}`][vc];
|
|
const isPublished = floGlobals.appObjects.rmTimes.articles.hasOwnProperty(articleID)
|
|
getConfirmation(`${isPublished ? 'Update' : 'Publish'} article?`).then(async res => {
|
|
if (res) {
|
|
showLoader(` ${isPublished ? 'UPDATING...' : 'PUBLISHING...'}`)
|
|
const { title, categories, summary, published, tags, contributors, heroImage } = getArticleMetaData()
|
|
floGlobals.appObjects.adminData.publishedVc[vectorClock] = true
|
|
floGlobals.appObjects.articlesContent[articleID] = content
|
|
if (isPublished) {
|
|
floGlobals.appObjects.rmTimes.articles[articleID]['updated'] = Date.now();
|
|
} else {
|
|
floGlobals.appObjects.rmTimes.articles[articleID] = {
|
|
published,
|
|
votes: 0,
|
|
lastCountedVC: ''
|
|
}
|
|
floGlobals.appObjects.adminData.articleVotes[articleID] = { votes: {} }
|
|
}
|
|
floGlobals.appObjects.rmTimes.articles[articleID].categories = categories
|
|
floGlobals.appObjects.rmTimes.articles[articleID].contributors = contributors
|
|
floGlobals.appObjects.rmTimes.articles[articleID].title = title
|
|
floGlobals.appObjects.rmTimes.articles[articleID].tags = tags
|
|
floGlobals.appObjects.rmTimes.articles[articleID].readTime = readTime
|
|
floGlobals.appObjects.rmTimes.articles[articleID].summary = summary
|
|
floGlobals.appObjects.rmTimes.articles[articleID].heroImage = heroImage
|
|
// if (heroImage.hasOwnProperty('full')) {
|
|
// try {
|
|
// compactIDB.writeData('images', { heroImage }, articleID)
|
|
// const response = await floCloudAPI.sendApplicationData(heroImage, 'images')
|
|
// for (const key in response) {
|
|
// floGlobals.appObjects.rmTimes.articles[articleID].heroImage = response[key].vectorClock
|
|
// }
|
|
// } catch (err) {
|
|
// console.log(err)
|
|
// }
|
|
// }
|
|
Promise.all([
|
|
floCloudAPI.updateObjectData('rmTimes'),
|
|
floCloudAPI.updateObjectData('adminData'),
|
|
floCloudAPI.updateObjectData('articlesContent'),
|
|
]).then(() => {
|
|
notify(`${isPublished ? 'Updated' : 'Published'} article`, 'success')
|
|
if (!isPublished) {
|
|
getRef('article_analytics').prepend(render.articleRow(articleID))
|
|
}
|
|
document.querySelector(`.request-card[data-vc="${vc}"]`).remove()
|
|
closePopup()
|
|
}).catch(err => {
|
|
notify(`${isPublished ? 'UPDATE' : 'PUBLISH'} article failed`, 'error')
|
|
console.error(err)
|
|
}).finally(() => {
|
|
hideLoader(` ${isPublished ? 'UPDATE' : 'PUBLISH'}`)
|
|
})
|
|
}
|
|
})
|
|
}
|
|
function handleRequestClick(e) {
|
|
if (e.target.closest('.publish-button')) {
|
|
const button = e.target.closest('.publish-button');
|
|
const vc = button.closest('.request-card').dataset.vc;
|
|
const { message: { articleID, title, contributors } } = floGlobals.generalData[`publishing_requests|${floGlobals.adminID}|${floGlobals.application}`][vc]
|
|
const isPublished = floGlobals.appObjects.rmTimes.articles.hasOwnProperty(articleID)
|
|
if (isPublished)
|
|
setArticleMetaData(floGlobals.appObjects.rmTimes.articles[articleID], articleID)
|
|
else
|
|
setArticleMetaData({ title, contributors }, articleID)
|
|
floGlobals.subAdminData = {
|
|
actionType: 'request',
|
|
articleID,
|
|
vc
|
|
}
|
|
getRef('set_article_meta').textContent = isPublished ? 'UPDATE' : 'PUBLISH'
|
|
getRef('edit_popup__title').textContent = isPublished ? 'Update' : 'Publish'
|
|
openPopup('edit_article_meta_popup')
|
|
} else if (e.target.closest('.preview-button')) {
|
|
const button = e.target.closest('.preview-button');
|
|
const vc = button.closest('.request-card').dataset.vc;
|
|
const { message: { content, title } } = floGlobals.generalData[`publishing_requests|${floGlobals.adminID}|${floGlobals.application}`][vc];
|
|
|
|
getRef('preview_container').innerHTML = DOMPurify.sanitize(content, { FORBID_ATTR: ['style'], ADD_ATTR: ['target'] })
|
|
getRef('preview_container').prepend(createElement('h1', {
|
|
textContent: title
|
|
}))
|
|
openPopup('preview_popup')
|
|
} else if (e.target.closest('.delete-request')) {
|
|
getConfirmation(`Delete this request?`).then(res => {
|
|
if (res) {
|
|
const button = e.target.closest('.delete-request');
|
|
const vc = button.closest('.request-card').dataset.vc;
|
|
floGlobals.appObjects.adminData.rejectedVc[vc] = true
|
|
|
|
floCloudAPI.updateObjectData('adminData')
|
|
.then(() => {
|
|
notify(`Deleted request`, 'success')
|
|
document.querySelector(`.request-card[data-vc="${vc}"]`).remove()
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
function setSelectedCategories(categories = []) {
|
|
getRef('edit_category').querySelectorAll(`[name="category"]`).forEach(checkbox => {
|
|
checkbox.checked = categories.includes(checkbox.value)
|
|
})
|
|
}
|
|
function getSelectedCategories() {
|
|
return [...getRef('edit_category').querySelectorAll('input:checked')].map(input => input.value)
|
|
}
|
|
|
|
async function setArticleMetaData(details, articleID) {
|
|
const { categories, title, tags, summary, published, contributors, heroImage } = details
|
|
// const articleImages = await compactIDB.readData('images', articleID)
|
|
if (heroImage && heroImage.hasOwnProperty('full')) {
|
|
// getRef('preview_image').src = `./images/${heroImage}`
|
|
getRef('select_full_image').value = heroImage.full;
|
|
getRef('select_thumbnail_image').value = heroImage.thumbnail;
|
|
} else {
|
|
getRef('select_full_image').value = '';
|
|
getRef('select_thumbnail_image').value = '';
|
|
}
|
|
getRef('edit_title').value = title;
|
|
getRef('edit_summary').value = summary || '';
|
|
setSelectedCategories(categories || '');
|
|
getRef('edit_contributors').value = contributors || [];
|
|
getRef('edit_tags').value = tags || [];
|
|
getRef('edit_published').value = formatDate(published || Date.now())
|
|
}
|
|
// format unix timestamp to yyyy-mm-dd
|
|
function formatDate(unixTimestamp) {
|
|
const date = new Date(unixTimestamp);
|
|
const year = date.getFullYear();
|
|
const month = date.getMonth() + 1;
|
|
const day = date.getDate();
|
|
return `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day}`;
|
|
}
|
|
function getArticleMetaData() {
|
|
return {
|
|
title: getRef('edit_title').value.trim(),
|
|
categories: getSelectedCategories(),
|
|
heroImage: {
|
|
full: getRef('select_full_image').value,
|
|
thumbnail: getRef('select_thumbnail_image').value,
|
|
},
|
|
summary: getRef('edit_summary').value.trim(),
|
|
published: new Date(getRef('edit_published').value).getTime(),
|
|
contributors: getRef('edit_contributors').value.filter(v => v),
|
|
tags: getRef('edit_tags').value,
|
|
}
|
|
}
|
|
function handleAnalyticsClick(e) {
|
|
if (e.target.closest('.edit-article')) {
|
|
const button = e.target.closest('.edit-article');
|
|
const articleID = button.closest('.article-row').dataset.articleId;
|
|
setArticleMetaData(floGlobals.appObjects.rmTimes.articles[articleID], articleID)
|
|
floGlobals.subAdminData = {
|
|
actionType: 'analytics',
|
|
articleID,
|
|
}
|
|
getRef('set_article_meta').textContent = "UPDATE"
|
|
getRef('edit_popup__title').textContent = "Update"
|
|
openPopup('edit_article_meta_popup')
|
|
} else if (e.target.closest('.delete-article')) {
|
|
getConfirmation(`Delete this article?`, {
|
|
confirmText: 'Delete'
|
|
}).then(res => {
|
|
if (res) {
|
|
const articleCard = e.target.closest('.article-row');
|
|
const articleID = articleCard.dataset.articleId;
|
|
delete floGlobals.appObjects.rmTimes.articles[articleID]
|
|
delete floGlobals.appObjects.adminData.articleVotes[articleID]
|
|
delete floGlobals.appObjects.articlesContent[articleID]
|
|
Promise.all([
|
|
floCloudAPI.updateObjectData('rmTimes'),
|
|
floCloudAPI.updateObjectData('adminData'),
|
|
floCloudAPI.updateObjectData('articlesContent'),
|
|
]).then(() => {
|
|
notify(`Deleted article`, 'success')
|
|
articleCard.remove()
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
function updateArticleMetaData(articleID) {
|
|
getConfirmation('Update article meta data?').then(async res => {
|
|
if (res) {
|
|
showLoader('UPDATING...')
|
|
// const { title, categories, summary, published, tags, contributors, heroImage } = getArticleMetaData()
|
|
console.log(getArticleMetaData())
|
|
floGlobals.appObjects.rmTimes.articles[articleID] = { ...floGlobals.appObjects.rmTimes.articles[articleID], ...getArticleMetaData() }
|
|
// if (heroImage.hasOwnProperty('full')) {
|
|
// try {
|
|
// compactIDB.writeData('images', { heroImage }, articleID)
|
|
// const response = await floCloudAPI.sendApplicationData(heroImage, 'images')
|
|
// for (const key in response) {
|
|
// floGlobals.appObjects.rmTimes.articles[articleID].heroImage = response[key].vectorClock
|
|
// }
|
|
// } catch (e) {
|
|
// notify(`Error uploading image`, 'error')
|
|
// console.error(e)
|
|
// }
|
|
// }
|
|
floCloudAPI.updateObjectData('rmTimes').then(() => {
|
|
notify(`Updated article meta data`, 'success')
|
|
closePopup()
|
|
}).catch(err => {
|
|
notify(`Error updating article meta data: ${err}`, 'error')
|
|
}).finally(() => {
|
|
hideLoader('UPDATE')
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
function defineArticle() {
|
|
if (floGlobals.subAdminData.actionType === 'analytics') {
|
|
updateArticleMetaData(floGlobals.subAdminData.articleID)
|
|
} else {
|
|
publishArticle(floGlobals.subAdminData.vc)
|
|
}
|
|
}
|
|
|
|
async function calculateVotes() {
|
|
const articlesVotesProm = []
|
|
const articleIDs = []
|
|
for (const articleKey in floGlobals.appObjects.rmTimes.articles) {
|
|
if (floGlobals.appObjects.adminData.articleVotes.hasOwnProperty(articleKey) && floGlobals.appObjects.rmTimes.articles[articleKey].lastCountedVC !== '') {
|
|
articlesVotesProm.push(
|
|
floCloudAPI.requestApplicationData(`article_${articleKey}_votes`, {
|
|
lowerVectorClock: floGlobals.appObjects.rmTimes.articles[articleKey].lastCountedVC + 1
|
|
})
|
|
)
|
|
} else {
|
|
articlesVotesProm.push(
|
|
floCloudAPI.requestApplicationData(`article_${articleKey}_votes`)
|
|
)
|
|
}
|
|
articleIDs.push(articleKey)
|
|
}
|
|
Promise.all(articlesVotesProm).then(res => {
|
|
res.forEach((articleVotes, index) => {
|
|
if (!floGlobals.appObjects.adminData.articleVotes.hasOwnProperty(articleIDs[index])) {
|
|
floGlobals.appObjects.adminData.articleVotes[articleIDs[index]].votes = {}
|
|
}
|
|
articleVotes.forEach(vote => {
|
|
const { senderID, message, type, vectorClock, time } = vote;
|
|
const { voteCount } = floCloudAPI.util.decodeMessage(message)
|
|
const { votes } = floGlobals.appObjects.adminData.articleVotes[articleIDs[index]];
|
|
if (votes[senderID]) {
|
|
floGlobals.appObjects.adminData.articleVotes[articleIDs[index]].votes[senderID] += voteCount || 1
|
|
} else {
|
|
floGlobals.appObjects.adminData.articleVotes[articleIDs[index]].votes[senderID] = voteCount || 1
|
|
}
|
|
floGlobals.appObjects.rmTimes.articles[articleIDs[index]].lastCountedVC = vectorClock
|
|
})
|
|
let totalArticleVotes = 0
|
|
for (const voter in floGlobals.appObjects.adminData.articleVotes[articleIDs[index]].votes) {
|
|
totalArticleVotes += floGlobals.appObjects.adminData.articleVotes[articleIDs[index]].votes[voter]
|
|
}
|
|
floGlobals.appObjects.rmTimes.articles[articleIDs[index]].votes = totalArticleVotes
|
|
})
|
|
Promise.all([
|
|
floCloudAPI.updateObjectData('rmTimes'),
|
|
floCloudAPI.updateObjectData('adminData')
|
|
]).then(() => {
|
|
console.log('calculated votes')
|
|
}).catch(err => {
|
|
console.error(err)
|
|
})
|
|
}).catch(err => {
|
|
console.error(err)
|
|
})
|
|
Promise.all([compactIDB.readData('appObjects', 'articlesContent'), compactIDB.readData('appObjects', 'heroImages')]).then(([articlesContent, heroImages]) => {
|
|
floGlobals.appObjects.articlesContent = articlesContent;
|
|
floGlobals.appObjects.heroImages = heroImages;
|
|
}).catch(err => {
|
|
console.error(err)
|
|
})
|
|
}
|
|
|
|
getRef('section_selector').addEventListener('change', e => {
|
|
document.querySelectorAll('.admin-section').forEach(section => { section.classList.add('hide') })
|
|
getRef(`${e.target.value}_section`).classList.remove('hide')
|
|
})
|
|
|
|
function setWriterDetails(writerID) {
|
|
console.log(writerID)
|
|
const { name, bio } = floGlobals.appObjects.rmTimes.articleWriters[writerID]
|
|
getRef('get_writer_id').value = writerID
|
|
getRef('get_writer_name').value = name
|
|
getRef('get_writer_bio').value = bio
|
|
}
|
|
function getWriterDetails() {
|
|
return {
|
|
floID: getRef('get_writer_id').value.trim(),
|
|
name: getRef('get_writer_name').value.trim(),
|
|
bio: getRef('get_writer_bio').value.trim(),
|
|
}
|
|
}
|
|
|
|
function showAddWriterPopup() {
|
|
getRef('writer_popup_title').textContent = "Add writer"
|
|
getRef('save_writer').textContent = "ADD"
|
|
getRef('get_writer_id').removeAttribute('disabled')
|
|
getRef('get_writer_id').parentNode.classList.remove('hide')
|
|
openPopup('add_writer_popup')
|
|
}
|
|
|
|
function handleWritersClick(e) {
|
|
if (e.target.closest('.edit-writer')) {
|
|
const button = e.target.closest('.edit-writer');
|
|
const writerID = button.closest('.writer-card').dataset.writerId;
|
|
setWriterDetails(writerID)
|
|
getRef('writer_popup_title').textContent = "Edit"
|
|
getRef('save_writer').textContent = "UPDATE"
|
|
getRef('get_writer_id').setAttribute('disabled', 'true')
|
|
getRef('get_writer_id').parentNode.classList.add('hide')
|
|
openPopup('add_writer_popup')
|
|
} else if (e.target.closest('.delete-writer')) {
|
|
const button = e.target.closest('.delete-writer');
|
|
const writerID = button.closest('.writer-card').dataset.writerId;
|
|
getConfirmation('Delete this writer?').then(res => {
|
|
if (res) {
|
|
delete floGlobals.appObjects.rmTimes.articleWriters[writerID]
|
|
button.closest('.writer-card').remove()
|
|
floCloudAPI.updateObjectData('rmTimes').then(() => {
|
|
notify('Writer deleted', 'success')
|
|
}).catch(error => console.error(error))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
function saveWriter() {
|
|
const { floID, name, bio } = getWriterDetails()
|
|
if (floGlobals.appObjects.rmTimes.articleWriters.hasOwnProperty(floID)) {
|
|
const { name: oldName, bio: oldBio } = floGlobals.appObjects.rmTimes.articleWriters[floID]
|
|
if (name !== oldName || bio !== oldBio) {
|
|
floGlobals.appObjects.rmTimes.articleWriters[floID].name = name
|
|
floGlobals.appObjects.rmTimes.articleWriters[floID].bio = bio
|
|
const writerCard = getRef('writers_list').querySelector(`.writer-card[data-writer-id="${floID}"]`)
|
|
if (writerCard) {
|
|
writerCard.querySelector('.writer-name').textContent = name
|
|
writerCard.querySelector('.writer-bio').textContent = bio
|
|
}
|
|
floCloudAPI.updateObjectData('rmTimes').then(() => {
|
|
notify('Writer details updated', 'success')
|
|
closePopup()
|
|
}).catch(error => console.error(error))
|
|
} else {
|
|
notify('Details are not changed', 'error')
|
|
}
|
|
} else {
|
|
floGlobals.appObjects.rmTimes.articleWriters[floID] = { name, bio }
|
|
floCloudAPI.updateObjectData('rmTimes').then(() => {
|
|
getRef('writers_list').append(render.writerCard(floID))
|
|
notify('Added writer details', 'success')
|
|
closePopup()
|
|
}).catch(error => console.error(error))
|
|
}
|
|
}
|
|
|
|
|
|
function addApprovedID() {
|
|
getConfirmation('Approve FLO address?').then(res => {
|
|
if (res) {
|
|
const idToAdd = getRef('get_id_to_add').value.trim()
|
|
const validIds = idToAdd.split(',').filter(floID => {
|
|
return (floCrypto.validateAddr(floID) && !floGlobals.appObjects.adminData.approvedID.hasOwnProperty(floID))
|
|
})
|
|
if (validIds.length) {
|
|
const frag = document.createDocumentFragment()
|
|
validIds.forEach(floID => {
|
|
floGlobals.appObjects.adminData.approvedID[floID] = true
|
|
frag.append(render.floIDCard(floID))
|
|
})
|
|
getRef('approved_ids').prepend(frag)
|
|
floCloudAPI.updateObjectData('adminData').then(() => {
|
|
notify('Approved FLO IDs', 'success')
|
|
}).catch(error => console.error(error))
|
|
} else {
|
|
notify('Given FLO IDs are already added', 'error')
|
|
}
|
|
getRef('get_id_to_add').value = ''
|
|
}
|
|
})
|
|
}
|
|
|
|
function handleApprovedIDsClick(e) {
|
|
if (e.target.closest('.delete-flo-id')) {
|
|
const floIdCard = e.target.closest('.flo-id-card');
|
|
const floID = floIdCard.dataset.floId;
|
|
getConfirmation('Remove this FLO address from approved list?').then(res => {
|
|
if (res) {
|
|
delete floGlobals.appObjects.adminData.approvedID[floID]
|
|
floIdCard.remove()
|
|
floCloudAPI.updateObjectData('adminData').then(() => {
|
|
notify('Removed FLO address', 'success')
|
|
}).catch(error => console.error(error))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
let currentSelectedImage = {}
|
|
// getRef('select_image').addEventListener('change', function (e) {
|
|
// currentSelectedImage = {}
|
|
// if (this.files.length === 0) return
|
|
// const selectedFile = this.files[0]
|
|
// const reader = new FileReader();
|
|
// reader.onload = function (e) {
|
|
// // show selected image in the preview
|
|
// getRef('preview_image').src = e.target.result;
|
|
// getRef('preview_image').addEventListener('load', function (event) {
|
|
// // Dynamically create a canvas element
|
|
// const canvas = createElement("canvas");
|
|
// const context = canvas.getContext("2d");
|
|
// const originalWidth = getRef('preview_image').width;
|
|
// const originalHeight = getRef('preview_image').height;
|
|
// const resizingFactor = parseFloat((1 / (originalWidth / 600)).toFixed(2));
|
|
|
|
// const canvasWidth = originalWidth * resizingFactor;
|
|
// const canvasHeight = originalHeight * resizingFactor;
|
|
|
|
// canvas.width = canvasWidth;
|
|
// canvas.height = canvasHeight;
|
|
|
|
// context.drawImage(
|
|
// getRef('preview_image'),
|
|
// 0,
|
|
// 0,
|
|
// originalWidth * resizingFactor,
|
|
// originalHeight * resizingFactor
|
|
// );
|
|
// currentSelectedImage['thumbnail'] = canvas.toDataURL(selectedFile.type);
|
|
// }, { once: true });
|
|
// currentSelectedImage.name = selectedFile.name
|
|
// currentSelectedImage.type = selectedFile.type
|
|
// currentSelectedImage.full = e.target.result
|
|
// }
|
|
// reader.readAsDataURL(this.files[0]);
|
|
// })
|
|
|
|
</script>
|
|
<script id="onLoadStartUp">
|
|
let isShowingFloID = true
|
|
function onLoadStartUp() {
|
|
getRef('show_sign_in_button').addEventListener('click', () => openPopup('sign_in_popup'))
|
|
//floDapps.addStartUpFunction('Sample', Promised Function)
|
|
floDapps.setAppObjectStores({ images: {} })
|
|
floDapps.setCustomPrivKeyInput(getSignedIn)
|
|
floDapps.setMidStartup(getArticles)
|
|
floDapps.launchStartUp().then(async result => {
|
|
getRef('show_sign_in_button').classList.add('hide')
|
|
getRef('user_popup_button').classList.remove('hide')
|
|
getRef('user_flo_id').value = myFloID
|
|
getRef('user_btc_id').value = btc_api.convert.legacy2bech(myFloID)
|
|
renderElem(getRef('user_popup_button'), html`
|
|
<svg class="icon margin-right-0-5" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <mask id="path-1-outside-1_16_6" maskUnits="userSpaceOnUse" x="3" y="3" width="58" height="58"> <rect fill="white" x="3" y="3" width="58" height="58" /> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> </mask> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> <path d="M31.946 43.6019L32.6728 42.915L31.918 42.1163L31.1938 42.943L31.946 43.6019ZM31.9811 55.1957L31.2716 55.9004L31.9657 56.5992L32.6749 55.9159L31.9811 55.1957ZM31.9487 10.6835L32.7051 11.3376L32.9487 11.0559V10.6835H31.9487ZM31.9433 37.4108L31.18 38.0569L31.9442 38.9597L32.7074 38.056L31.9433 37.4108ZM31.9487 10.6808L32.7068 10.0287L30.9487 7.98495V10.6808H31.9487ZM59 28.7654L59.9166 29.1651L60.4326 27.9819L59.158 27.778L59 28.7654ZM45.7214 42.53L45.1042 41.7432L46.0802 43.4634L45.7214 42.53ZM49.7984 39.3089L49.1332 38.5622L49.1326 38.5628L49.7984 39.3089ZM54.0293 32.6075L53.0647 32.3439L53.0646 32.3441L54.0293 32.6075ZM53.1896 31.406L53.3484 30.4187L53.348 30.4186L53.1896 31.406ZM45.1733 32.702L45.588 33.612L45.5881 33.6119L45.1733 32.702ZM34.1735 40.8938L33.467 40.1861L33.4585 40.1946L33.4501 40.2033L34.1735 40.8938ZM33.9899 41.2259L33.114 40.7435L32.3319 42.1635L33.9519 42.2252L33.9899 41.2259ZM48.119 49.9064L48.3359 50.8826L49.5751 50.6072L49.0173 49.4669L48.119 49.9064ZM37.778 48.5213L38.0715 47.5653L37.2372 49.3625L37.778 48.5213ZM45.176 48.5483L45.6045 49.4518L46.6008 48.9794L46.0335 48.0338L45.176 48.5483ZM44.231 47.0228L44.8645 46.2491L44.8637 46.2484L44.231 47.0228ZM40.505 44.3498L40.9866 43.4734L40.9845 43.4723L40.505 44.3498ZM33.5768 42.1682L33.7777 41.1886L31.6127 40.7446L32.7083 42.664L33.5768 42.1682ZM31.946 59L31.1626 59.6216L31.9457 60.6085L32.7292 59.6218L31.946 59ZM28.2389 50.8946L29.2314 50.7725L29.2314 50.7721L28.2389 50.8946ZM30.1991 42.3896L31.0736 42.8747L31.7652 41.6279L30.3574 41.4022L30.1991 42.3896ZM18.7916 48.5645L17.855 48.2141L17.5413 49.0527L18.3402 49.4568L18.7916 48.5645ZM26.33 48.3161L27.0473 49.0128L25.9814 47.3788L26.33 48.3161ZM15.8108 49.8335L14.9131 49.393L14.4073 50.4237L15.4977 50.7832L15.8108 49.8335ZM30.0263 41.2286L30.0635 42.2279L32.3372 42.1433L30.7373 40.5255L30.0263 41.2286ZM28.8167 40.0082L28.1226 40.7281L28.1228 40.7282L28.8167 40.0082ZM19.823 33.2366L19.3644 34.1252L19.3645 34.1253L19.823 33.2366ZM10.9481 31.3871L10.8001 30.3981L10.7998 30.3982L10.9481 31.3871ZM9.6656 31.6436L9.46564 30.6638L8.49474 30.8619L8.68401 31.8346L9.6656 31.6436ZM18.1274 42.3464L18.0073 43.3392L18.6607 41.5005L18.1274 42.3464ZM5 28.7546L4.84003 27.7675L3.75363 27.9435L4.03268 29.0082L5 28.7546ZM26.897 35.2319L26.173 35.9217L27.8093 34.8223L26.897 35.2319ZM31.946 5L32.7265 4.37488L31.9461 3.40036L31.1655 4.37483L31.946 5ZM31.1938 42.943C27.7974 46.8199 27.6566 52.261 31.2716 55.9004L32.6906 54.491C29.9012 51.6828 29.9116 47.4417 32.6982 44.2609L31.1938 42.943ZM32.6749 55.9159C36.1304 52.5867 36.081 46.5214 32.6728 42.915L31.2192 44.2888C33.94 47.1678 33.8852 51.9727 31.2873 54.4755L32.6749 55.9159ZM31.1923 10.0294C27.4048 14.4092 25.5379 19.2455 25.5737 24.1102C25.6095 28.971 27.5438 33.7608 31.18 38.0569L32.7066 36.7647C29.3201 32.7637 27.6054 28.4127 27.5736 24.0955C27.5419 19.7822 29.1891 15.4034 32.7051 11.3376L31.1923 10.0294ZM32.7074 38.056C36.4083 33.6729 38.31 28.8504 38.3133 23.9938C38.3165 19.1359 36.42 14.3451 32.7068 10.0287L31.1906 11.3329C34.6405 15.3433 36.3161 19.6839 36.3133 23.9925C36.3104 28.3024 34.6279 32.6815 31.1792 36.7656L32.7074 38.056ZM30.9487 10.6808V10.6835H32.9487V10.6808H30.9487ZM37.8259 35.7503C43.6131 29.8345 50.6632 28.444 58.842 29.7528L59.158 27.778C50.532 26.3976 42.7591 27.8475 36.3963 34.3517L37.8259 35.7503ZM58.0834 28.3657C55.4402 34.4268 51.7791 39.1301 45.3626 41.5966L46.0802 43.4634C53.1637 40.7405 57.1436 35.524 59.9166 29.1651L58.0834 28.3657ZM46.3386 43.3168C47.7733 42.1914 49.2057 41.178 50.4642 40.055L49.1326 38.5628C47.9341 39.6322 46.6503 40.5304 45.1042 41.7432L46.3386 43.3168ZM50.4636 40.0556C52.6466 38.111 54.2121 35.7338 54.994 32.871L53.0646 32.3441C52.3939 34.8002 51.0542 36.851 49.1332 38.5622L50.4636 40.0556ZM54.9939 32.8711C55.1262 32.3872 55.2248 31.6946 54.7698 31.1186C54.3643 30.6053 53.7257 30.4794 53.3484 30.4187L53.0308 32.3933C53.1086 32.4058 53.17 32.4181 53.2184 32.43C53.2671 32.442 53.2955 32.4518 53.3091 32.4572C53.3227 32.4626 53.3139 32.4606 53.2926 32.4461C53.2699 32.4307 53.2353 32.4025 53.2004 32.3583C53.1832 32.3366 53.1677 32.3132 53.1543 32.2886C53.1409 32.264 53.1307 32.2402 53.1231 32.2182C53.1079 32.1742 53.1053 32.144 53.1049 32.1366C53.1046 32.1302 53.1059 32.1427 53.1007 32.1797C53.0955 32.2165 53.0849 32.27 53.0647 32.3439L54.9939 32.8711ZM53.348 30.4186C50.274 29.9254 47.4176 30.5801 44.7585 31.7921L45.5881 33.6119C47.9996 32.5127 50.4514 31.9794 53.0312 32.3934L53.348 30.4186ZM44.7586 31.792C40.3293 33.8104 36.7535 36.9051 33.467 40.1861L34.88 41.6015C38.1113 38.3755 41.4853 35.4816 45.588 33.612L44.7586 31.792ZM33.4501 40.2033C33.3063 40.354 33.2291 40.5156 33.2033 40.5674C33.1672 40.64 33.1517 40.6749 33.114 40.7435L34.8658 41.7083C34.9307 41.5906 34.9786 41.4891 34.9945 41.4572C35.0049 41.4363 35.0004 41.4467 34.9882 41.4667C34.9731 41.4914 34.9435 41.5355 34.8969 41.5843L33.4501 40.2033ZM33.9519 42.2252C37.0233 42.3421 39.6629 43.0109 41.8597 44.3098C44.0485 45.6039 45.857 47.5582 47.2207 50.3459L49.0173 49.4669C47.5001 46.3659 45.4368 44.1014 42.8776 42.5882C40.3265 41.0798 37.342 40.3527 34.0279 40.2266L33.9519 42.2252ZM47.9021 48.9302C44.3241 49.7253 41.1983 49.5313 38.3188 47.6801L37.2372 49.3625C40.7081 51.5937 44.4295 51.7507 48.3359 50.8826L47.9021 48.9302ZM37.4845 49.4773C39.9089 50.2215 42.6205 50.8669 45.6045 49.4518L44.7475 47.6448C42.4935 48.7137 40.4315 48.2899 38.0715 47.5653L37.4845 49.4773ZM46.0335 48.0338C45.8849 47.7862 45.8212 47.6158 45.6292 47.2504C45.4736 46.9544 45.2423 46.5584 44.8645 46.2491L43.5975 47.7965C43.6517 47.8409 43.7309 47.9377 43.8588 48.181C43.9503 48.3549 44.1431 48.7704 44.3185 49.0628L46.0335 48.0338ZM44.8637 46.2484C43.6913 45.2906 42.4149 44.2582 40.9866 43.4734L40.0234 45.2262C41.2681 45.9102 42.4109 46.8272 43.5983 47.7972L44.8637 46.2484ZM40.9845 43.4723C38.7711 42.2628 36.3236 41.7107 33.7777 41.1886L33.3759 43.1478C35.9384 43.6733 38.1079 44.1796 40.0255 45.2273L40.9845 43.4723ZM32.7083 42.664C34.346 45.5328 34.9255 48.203 34.6411 50.7474C34.3555 53.3015 33.1882 55.8274 31.1628 58.3782L32.7292 59.6218C34.9185 56.8644 36.2905 53.9944 36.6287 50.9696C36.9679 47.9351 36.2555 44.8435 34.4453 41.6724L32.7083 42.664ZM32.7294 58.3784C30.8397 55.9968 29.577 53.5818 29.2314 50.7725L27.2464 51.0167C27.6514 54.3094 29.1319 57.0622 31.1626 59.6216L32.7294 58.3784ZM29.2314 50.7721C28.8877 47.9881 29.6602 45.4224 31.0736 42.8747L29.3247 41.9045C27.7842 44.6812 26.8341 47.6775 27.2464 51.0171L29.2314 50.7721ZM30.3574 41.4022C29.3303 41.2375 28.1125 41.4187 26.9159 41.7622C25.6987 42.1117 24.4105 42.6564 23.2045 43.307C21.999 43.9574 20.8488 44.728 19.9166 45.543C19.005 46.3399 18.2137 47.2553 17.855 48.2141L19.7282 48.9149C19.9149 48.4157 20.4139 47.7647 21.233 47.0487C22.0314 46.3507 23.0524 45.6616 24.1541 45.0672C25.2552 44.4732 26.4102 43.9882 27.4678 43.6846C28.5458 43.3751 29.4344 43.2798 30.0408 43.377L30.3574 41.4022ZM18.3402 49.4568C21.2702 50.939 24.0958 50.214 26.6786 49.2534L25.9814 47.3788C23.4828 48.3082 21.3728 48.7496 19.243 47.6722L18.3402 49.4568ZM25.6127 47.6194C24.9334 48.3187 23.4333 48.9382 21.5294 49.2141C19.6667 49.484 17.6562 49.3889 16.1239 48.8838L15.4977 50.7832C17.3971 51.4094 19.7336 51.4952 21.8162 51.1934C23.8578 50.8976 25.9014 50.1927 27.0473 49.0128L25.6127 47.6194ZM16.7085 50.274C18.0554 47.5292 19.8486 45.5942 22.044 44.3081C24.2482 43.0169 26.918 42.345 30.0635 42.2279L29.9891 40.2293C26.606 40.3552 23.5923 41.0832 21.0331 42.5824C18.4649 44.0869 16.4147 46.3328 14.9131 49.393L16.7085 50.274ZM30.7373 40.5255C30.2757 40.0586 29.8942 39.6578 29.5106 39.2882L28.1228 40.7282C28.4844 41.0768 28.8157 41.4266 29.3153 41.9317L30.7373 40.5255ZM29.5108 39.2883C26.7637 36.6396 23.7967 34.1615 20.2815 32.3479L19.3645 34.1253C22.6317 35.8109 25.4373 38.1388 28.1226 40.7281L29.5108 39.2883ZM20.2816 32.348C17.4111 30.8666 14.2829 29.877 10.8001 30.3981L11.0961 32.3761C14.0015 31.9414 16.6891 32.7446 19.3644 34.1252L20.2816 32.348ZM10.7998 30.3982C10.388 30.4599 9.94468 30.566 9.46564 30.6638L9.86556 32.6234C10.4449 32.5052 10.7522 32.4277 11.0964 32.376L10.7998 30.3982ZM8.68401 31.8346C9.73479 37.2345 13.3673 40.5279 17.5941 43.1923L18.6607 41.5005C14.6039 38.9431 11.5404 36.0427 10.6472 31.4526L8.68401 31.8346ZM18.2475 41.3536C17.3819 41.2489 16.2594 40.7693 14.9918 39.9335C13.742 39.1093 12.427 37.9891 11.1875 36.7057C8.68437 34.1137 6.62095 30.9947 5.96732 28.5011L4.03268 29.0082C4.81005 31.9739 7.13413 35.3875 9.74885 38.095C11.0683 39.4613 12.4947 40.6825 13.8908 41.6031C15.2691 42.512 16.6967 43.1806 18.0073 43.3392L18.2475 41.3536ZM5.15997 29.7417C13.3246 28.4186 20.4108 29.874 26.173 35.9217L27.621 34.5421C21.2872 27.8944 13.4694 26.369 4.84003 27.7675L5.15997 29.7417ZM27.8093 34.8223C25.3851 29.4232 24.8341 24.3801 25.7561 19.5859C26.6809 14.7778 29.1009 10.1516 32.7265 5.62517L31.1655 4.37483C27.4012 9.07433 24.7952 13.9927 23.7921 19.2082C22.7863 24.4378 23.4058 29.8977 25.9847 35.6415L27.8093 34.8223ZM31.1655 5.62512C34.7619 10.1157 37.1747 14.7077 38.1168 19.4869C39.0562 24.2523 38.5469 29.2701 36.1948 34.6504L38.0274 35.4515C40.5299 29.7268 41.1033 24.2956 40.0791 19.1001C39.0576 13.9183 36.4606 9.03731 32.7265 4.37488L31.1655 5.62512Z" mask="url(#path-1-outside-1_16_6)" /> </svg>
|
|
<div>${myFloID}</div>
|
|
`)
|
|
setInterval(() => {
|
|
if (!isShowingFloID) {
|
|
renderElem(getRef('user_popup_button'), html`
|
|
<svg class="icon margin-right-0-5" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <mask id="path-1-outside-1_16_6" maskUnits="userSpaceOnUse" x="3" y="3" width="58" height="58"> <rect fill="white" x="3" y="3" width="58" height="58" /> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> </mask> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> <path d="M31.946 43.6019L32.6728 42.915L31.918 42.1163L31.1938 42.943L31.946 43.6019ZM31.9811 55.1957L31.2716 55.9004L31.9657 56.5992L32.6749 55.9159L31.9811 55.1957ZM31.9487 10.6835L32.7051 11.3376L32.9487 11.0559V10.6835H31.9487ZM31.9433 37.4108L31.18 38.0569L31.9442 38.9597L32.7074 38.056L31.9433 37.4108ZM31.9487 10.6808L32.7068 10.0287L30.9487 7.98495V10.6808H31.9487ZM59 28.7654L59.9166 29.1651L60.4326 27.9819L59.158 27.778L59 28.7654ZM45.7214 42.53L45.1042 41.7432L46.0802 43.4634L45.7214 42.53ZM49.7984 39.3089L49.1332 38.5622L49.1326 38.5628L49.7984 39.3089ZM54.0293 32.6075L53.0647 32.3439L53.0646 32.3441L54.0293 32.6075ZM53.1896 31.406L53.3484 30.4187L53.348 30.4186L53.1896 31.406ZM45.1733 32.702L45.588 33.612L45.5881 33.6119L45.1733 32.702ZM34.1735 40.8938L33.467 40.1861L33.4585 40.1946L33.4501 40.2033L34.1735 40.8938ZM33.9899 41.2259L33.114 40.7435L32.3319 42.1635L33.9519 42.2252L33.9899 41.2259ZM48.119 49.9064L48.3359 50.8826L49.5751 50.6072L49.0173 49.4669L48.119 49.9064ZM37.778 48.5213L38.0715 47.5653L37.2372 49.3625L37.778 48.5213ZM45.176 48.5483L45.6045 49.4518L46.6008 48.9794L46.0335 48.0338L45.176 48.5483ZM44.231 47.0228L44.8645 46.2491L44.8637 46.2484L44.231 47.0228ZM40.505 44.3498L40.9866 43.4734L40.9845 43.4723L40.505 44.3498ZM33.5768 42.1682L33.7777 41.1886L31.6127 40.7446L32.7083 42.664L33.5768 42.1682ZM31.946 59L31.1626 59.6216L31.9457 60.6085L32.7292 59.6218L31.946 59ZM28.2389 50.8946L29.2314 50.7725L29.2314 50.7721L28.2389 50.8946ZM30.1991 42.3896L31.0736 42.8747L31.7652 41.6279L30.3574 41.4022L30.1991 42.3896ZM18.7916 48.5645L17.855 48.2141L17.5413 49.0527L18.3402 49.4568L18.7916 48.5645ZM26.33 48.3161L27.0473 49.0128L25.9814 47.3788L26.33 48.3161ZM15.8108 49.8335L14.9131 49.393L14.4073 50.4237L15.4977 50.7832L15.8108 49.8335ZM30.0263 41.2286L30.0635 42.2279L32.3372 42.1433L30.7373 40.5255L30.0263 41.2286ZM28.8167 40.0082L28.1226 40.7281L28.1228 40.7282L28.8167 40.0082ZM19.823 33.2366L19.3644 34.1252L19.3645 34.1253L19.823 33.2366ZM10.9481 31.3871L10.8001 30.3981L10.7998 30.3982L10.9481 31.3871ZM9.6656 31.6436L9.46564 30.6638L8.49474 30.8619L8.68401 31.8346L9.6656 31.6436ZM18.1274 42.3464L18.0073 43.3392L18.6607 41.5005L18.1274 42.3464ZM5 28.7546L4.84003 27.7675L3.75363 27.9435L4.03268 29.0082L5 28.7546ZM26.897 35.2319L26.173 35.9217L27.8093 34.8223L26.897 35.2319ZM31.946 5L32.7265 4.37488L31.9461 3.40036L31.1655 4.37483L31.946 5ZM31.1938 42.943C27.7974 46.8199 27.6566 52.261 31.2716 55.9004L32.6906 54.491C29.9012 51.6828 29.9116 47.4417 32.6982 44.2609L31.1938 42.943ZM32.6749 55.9159C36.1304 52.5867 36.081 46.5214 32.6728 42.915L31.2192 44.2888C33.94 47.1678 33.8852 51.9727 31.2873 54.4755L32.6749 55.9159ZM31.1923 10.0294C27.4048 14.4092 25.5379 19.2455 25.5737 24.1102C25.6095 28.971 27.5438 33.7608 31.18 38.0569L32.7066 36.7647C29.3201 32.7637 27.6054 28.4127 27.5736 24.0955C27.5419 19.7822 29.1891 15.4034 32.7051 11.3376L31.1923 10.0294ZM32.7074 38.056C36.4083 33.6729 38.31 28.8504 38.3133 23.9938C38.3165 19.1359 36.42 14.3451 32.7068 10.0287L31.1906 11.3329C34.6405 15.3433 36.3161 19.6839 36.3133 23.9925C36.3104 28.3024 34.6279 32.6815 31.1792 36.7656L32.7074 38.056ZM30.9487 10.6808V10.6835H32.9487V10.6808H30.9487ZM37.8259 35.7503C43.6131 29.8345 50.6632 28.444 58.842 29.7528L59.158 27.778C50.532 26.3976 42.7591 27.8475 36.3963 34.3517L37.8259 35.7503ZM58.0834 28.3657C55.4402 34.4268 51.7791 39.1301 45.3626 41.5966L46.0802 43.4634C53.1637 40.7405 57.1436 35.524 59.9166 29.1651L58.0834 28.3657ZM46.3386 43.3168C47.7733 42.1914 49.2057 41.178 50.4642 40.055L49.1326 38.5628C47.9341 39.6322 46.6503 40.5304 45.1042 41.7432L46.3386 43.3168ZM50.4636 40.0556C52.6466 38.111 54.2121 35.7338 54.994 32.871L53.0646 32.3441C52.3939 34.8002 51.0542 36.851 49.1332 38.5622L50.4636 40.0556ZM54.9939 32.8711C55.1262 32.3872 55.2248 31.6946 54.7698 31.1186C54.3643 30.6053 53.7257 30.4794 53.3484 30.4187L53.0308 32.3933C53.1086 32.4058 53.17 32.4181 53.2184 32.43C53.2671 32.442 53.2955 32.4518 53.3091 32.4572C53.3227 32.4626 53.3139 32.4606 53.2926 32.4461C53.2699 32.4307 53.2353 32.4025 53.2004 32.3583C53.1832 32.3366 53.1677 32.3132 53.1543 32.2886C53.1409 32.264 53.1307 32.2402 53.1231 32.2182C53.1079 32.1742 53.1053 32.144 53.1049 32.1366C53.1046 32.1302 53.1059 32.1427 53.1007 32.1797C53.0955 32.2165 53.0849 32.27 53.0647 32.3439L54.9939 32.8711ZM53.348 30.4186C50.274 29.9254 47.4176 30.5801 44.7585 31.7921L45.5881 33.6119C47.9996 32.5127 50.4514 31.9794 53.0312 32.3934L53.348 30.4186ZM44.7586 31.792C40.3293 33.8104 36.7535 36.9051 33.467 40.1861L34.88 41.6015C38.1113 38.3755 41.4853 35.4816 45.588 33.612L44.7586 31.792ZM33.4501 40.2033C33.3063 40.354 33.2291 40.5156 33.2033 40.5674C33.1672 40.64 33.1517 40.6749 33.114 40.7435L34.8658 41.7083C34.9307 41.5906 34.9786 41.4891 34.9945 41.4572C35.0049 41.4363 35.0004 41.4467 34.9882 41.4667C34.9731 41.4914 34.9435 41.5355 34.8969 41.5843L33.4501 40.2033ZM33.9519 42.2252C37.0233 42.3421 39.6629 43.0109 41.8597 44.3098C44.0485 45.6039 45.857 47.5582 47.2207 50.3459L49.0173 49.4669C47.5001 46.3659 45.4368 44.1014 42.8776 42.5882C40.3265 41.0798 37.342 40.3527 34.0279 40.2266L33.9519 42.2252ZM47.9021 48.9302C44.3241 49.7253 41.1983 49.5313 38.3188 47.6801L37.2372 49.3625C40.7081 51.5937 44.4295 51.7507 48.3359 50.8826L47.9021 48.9302ZM37.4845 49.4773C39.9089 50.2215 42.6205 50.8669 45.6045 49.4518L44.7475 47.6448C42.4935 48.7137 40.4315 48.2899 38.0715 47.5653L37.4845 49.4773ZM46.0335 48.0338C45.8849 47.7862 45.8212 47.6158 45.6292 47.2504C45.4736 46.9544 45.2423 46.5584 44.8645 46.2491L43.5975 47.7965C43.6517 47.8409 43.7309 47.9377 43.8588 48.181C43.9503 48.3549 44.1431 48.7704 44.3185 49.0628L46.0335 48.0338ZM44.8637 46.2484C43.6913 45.2906 42.4149 44.2582 40.9866 43.4734L40.0234 45.2262C41.2681 45.9102 42.4109 46.8272 43.5983 47.7972L44.8637 46.2484ZM40.9845 43.4723C38.7711 42.2628 36.3236 41.7107 33.7777 41.1886L33.3759 43.1478C35.9384 43.6733 38.1079 44.1796 40.0255 45.2273L40.9845 43.4723ZM32.7083 42.664C34.346 45.5328 34.9255 48.203 34.6411 50.7474C34.3555 53.3015 33.1882 55.8274 31.1628 58.3782L32.7292 59.6218C34.9185 56.8644 36.2905 53.9944 36.6287 50.9696C36.9679 47.9351 36.2555 44.8435 34.4453 41.6724L32.7083 42.664ZM32.7294 58.3784C30.8397 55.9968 29.577 53.5818 29.2314 50.7725L27.2464 51.0167C27.6514 54.3094 29.1319 57.0622 31.1626 59.6216L32.7294 58.3784ZM29.2314 50.7721C28.8877 47.9881 29.6602 45.4224 31.0736 42.8747L29.3247 41.9045C27.7842 44.6812 26.8341 47.6775 27.2464 51.0171L29.2314 50.7721ZM30.3574 41.4022C29.3303 41.2375 28.1125 41.4187 26.9159 41.7622C25.6987 42.1117 24.4105 42.6564 23.2045 43.307C21.999 43.9574 20.8488 44.728 19.9166 45.543C19.005 46.3399 18.2137 47.2553 17.855 48.2141L19.7282 48.9149C19.9149 48.4157 20.4139 47.7647 21.233 47.0487C22.0314 46.3507 23.0524 45.6616 24.1541 45.0672C25.2552 44.4732 26.4102 43.9882 27.4678 43.6846C28.5458 43.3751 29.4344 43.2798 30.0408 43.377L30.3574 41.4022ZM18.3402 49.4568C21.2702 50.939 24.0958 50.214 26.6786 49.2534L25.9814 47.3788C23.4828 48.3082 21.3728 48.7496 19.243 47.6722L18.3402 49.4568ZM25.6127 47.6194C24.9334 48.3187 23.4333 48.9382 21.5294 49.2141C19.6667 49.484 17.6562 49.3889 16.1239 48.8838L15.4977 50.7832C17.3971 51.4094 19.7336 51.4952 21.8162 51.1934C23.8578 50.8976 25.9014 50.1927 27.0473 49.0128L25.6127 47.6194ZM16.7085 50.274C18.0554 47.5292 19.8486 45.5942 22.044 44.3081C24.2482 43.0169 26.918 42.345 30.0635 42.2279L29.9891 40.2293C26.606 40.3552 23.5923 41.0832 21.0331 42.5824C18.4649 44.0869 16.4147 46.3328 14.9131 49.393L16.7085 50.274ZM30.7373 40.5255C30.2757 40.0586 29.8942 39.6578 29.5106 39.2882L28.1228 40.7282C28.4844 41.0768 28.8157 41.4266 29.3153 41.9317L30.7373 40.5255ZM29.5108 39.2883C26.7637 36.6396 23.7967 34.1615 20.2815 32.3479L19.3645 34.1253C22.6317 35.8109 25.4373 38.1388 28.1226 40.7281L29.5108 39.2883ZM20.2816 32.348C17.4111 30.8666 14.2829 29.877 10.8001 30.3981L11.0961 32.3761C14.0015 31.9414 16.6891 32.7446 19.3644 34.1252L20.2816 32.348ZM10.7998 30.3982C10.388 30.4599 9.94468 30.566 9.46564 30.6638L9.86556 32.6234C10.4449 32.5052 10.7522 32.4277 11.0964 32.376L10.7998 30.3982ZM8.68401 31.8346C9.73479 37.2345 13.3673 40.5279 17.5941 43.1923L18.6607 41.5005C14.6039 38.9431 11.5404 36.0427 10.6472 31.4526L8.68401 31.8346ZM18.2475 41.3536C17.3819 41.2489 16.2594 40.7693 14.9918 39.9335C13.742 39.1093 12.427 37.9891 11.1875 36.7057C8.68437 34.1137 6.62095 30.9947 5.96732 28.5011L4.03268 29.0082C4.81005 31.9739 7.13413 35.3875 9.74885 38.095C11.0683 39.4613 12.4947 40.6825 13.8908 41.6031C15.2691 42.512 16.6967 43.1806 18.0073 43.3392L18.2475 41.3536ZM5.15997 29.7417C13.3246 28.4186 20.4108 29.874 26.173 35.9217L27.621 34.5421C21.2872 27.8944 13.4694 26.369 4.84003 27.7675L5.15997 29.7417ZM27.8093 34.8223C25.3851 29.4232 24.8341 24.3801 25.7561 19.5859C26.6809 14.7778 29.1009 10.1516 32.7265 5.62517L31.1655 4.37483C27.4012 9.07433 24.7952 13.9927 23.7921 19.2082C22.7863 24.4378 23.4058 29.8977 25.9847 35.6415L27.8093 34.8223ZM31.1655 5.62512C34.7619 10.1157 37.1747 14.7077 38.1168 19.4869C39.0562 24.2523 38.5469 29.2701 36.1948 34.6504L38.0274 35.4515C40.5299 29.7268 41.1033 24.2956 40.0791 19.1001C39.0576 13.9183 36.4606 9.03731 32.7265 4.37488L31.1655 5.62512Z" mask="url(#path-1-outside-1_16_6)" /> </svg>
|
|
<div>${myFloID}</div>
|
|
`)
|
|
isShowingFloID = true
|
|
} else {
|
|
renderElem(getRef('user_popup_button'), html`
|
|
<svg class="icon margin-right-0-5" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M17.06,11.57C17.65,10.88,18,9.98,18,9c0-1.86-1.27-3.43-3-3.87L15,3h-2v2h-2V3H9v2H6v2h2v10H6v2h3v2h2v-2h2v2h2v-2 c2.21,0,4-1.79,4-4C19,13.55,18.22,12.27,17.06,11.57z M10,7h4c1.1,0,2,0.9,2,2s-0.9,2-2,2h-4V7z M15,17h-5v-4h5c1.1,0,2,0.9,2,2 S16.1,17,15,17z"/></g></svg>
|
|
<div >${btc_api.convert.legacy2bech(myFloID)}</div>
|
|
`)
|
|
isShowingFloID = false
|
|
}
|
|
}, 1000 * 60);
|
|
floGlobals.isSubAdmin = floGlobals.subAdmins.includes(myFloID)
|
|
if (floGlobals.isSubAdmin) {
|
|
floGlobals.subAdminData = {}
|
|
getRef('publishing_requests').addEventListener('click', handleRequestClick);
|
|
getRef('article_analytics').addEventListener('click', handleAnalyticsClick);
|
|
getRef('writers_list').addEventListener('click', handleWritersClick);
|
|
getRef('approved_ids').addEventListener('click', handleApprovedIDsClick);
|
|
document.querySelectorAll('.admin-option').forEach(elem => elem.classList.remove('hide'));
|
|
} else {
|
|
getRef('publishing_requests').removeEventListener('click', handleRequestClick)
|
|
getRef('article_analytics').removeEventListener('click', handleAnalyticsClick);
|
|
getRef('writers_list').removeEventListener('click', handleWritersClick);
|
|
getRef('approved_ids').removeEventListener('click', handleApprovedIDsClick);
|
|
document.querySelectorAll('.admin-option').forEach(elem => elem.classList.add('hide'))
|
|
}
|
|
console.log(result)
|
|
}).catch(error => console.error(error))
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html> |