js code rewrite. Created _helpers.js with XHR and storage wrapper

This commit is contained in:
meow 2022-05-06 04:46:59 +03:00
parent ef8c7184de
commit 7dd699370f
23 changed files with 735 additions and 901 deletions

View file

@ -481,7 +481,7 @@ def template_reddit_comments(root, locale)
html << <<-END_HTML
<p>
<a href="javascript:void(0)" data-onclick="toggle_parent">[ - ]</a>
<a href="javascript:void(0)" data-onclick="toggle_parent">[ ]</a>
<b><a href="https://www.reddit.com/user/#{child.author}">#{child.author}</a></b>
#{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)}
<span title="#{child.created_utc.to_s(translate(locale, "%a %B %-d %T %Y UTC"))}">#{translate(locale, "`x` ago", recode_date(child.created_utc, locale))}</span>

View file

@ -29,6 +29,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/playlist_widget.js?v=<%= ASSET_COMMIT %>"></script>
<div class="pure-g">

View file

@ -93,4 +93,5 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/community.js?v=<%= ASSET_COMMIT %>"></script>

View file

@ -66,4 +66,5 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/player.js?v=<%= ASSET_COMMIT %>"></script>

View file

@ -31,6 +31,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"></script>
<% else %>
<p>

View file

@ -31,6 +31,7 @@
</script>
<%= rendered "components/player" %>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/embed.js?v=<%= ASSET_COMMIT %>"></script>
</body>
</html>

View file

@ -25,6 +25,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/watched_widget.js"></script>
<div class="pure-g">

View file

@ -50,6 +50,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/watched_widget.js"></script>
<div class="pure-g">

View file

@ -9,6 +9,20 @@
<body>
<h1><%= translate(locale, "JavaScript license information") %></h1>
<table id="jslicense-labels1">
<tr>
<td>
<a href="/js/_helpers.js?v=<%= ASSET_COMMIT %>">_helpers.js</a>
</td>
<td>
<a href="https://www.gnu.org/licenses/agpl-3.0.html">AGPL-3.0</a>
</td>
<td>
<a href="/js/_helpers.js?v=<%= ASSET_COMMIT %>"><%= translate(locale, "source") %></a>
</td>
</tr>
<tr>
<td>
<a href="/js/community.js?v=<%= ASSET_COMMIT %>">community.js</a>

View file

@ -97,6 +97,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/playlist_widget.js?v=<%= ASSET_COMMIT %>"></script>
<% end %>

View file

@ -157,6 +157,7 @@
</div>
<div class="pure-u-1 pure-u-md-2-24"></div>
</div>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/handlers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/themes.js?v=<%= ASSET_COMMIT %>"></script>
<% if env.get? "user" %>

View file

@ -165,6 +165,7 @@ we're going to need to do it here in order to allow for translations.
}.to_pretty_json
%>
</script>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/playlist_widget.js?v=<%= Time.utc.to_unix_ms %>"></script>
<% end %>
<% end %>
@ -303,4 +304,5 @@ we're going to need to do it here in order to allow for translations.
</div>
<% end %>
</div>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>