Updated render.js

Version string for random renders will now use globals.v4 (new variable)
instead of globals.v1, since globals.v1 changes a lot more often.
Hence to allow this to happen, data-version attribute will now be added
to <script> tag of render.js in home.njk.
This commit is contained in:
Bobby Wibowo 2019-01-14 19:44:09 +07:00
parent a71b06df2b
commit 907ba3960a
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF
3 changed files with 8 additions and 7 deletions

View File

@ -60,10 +60,9 @@ page.doRenderSwal = function () {
page.getRenderVersion = function () {
const renderScript = document.getElementById('renderScript')
if (!renderScript) return ''
const match = renderScript.src.match(/\?v=\w*$/)
if (!match) return ''
return match[0]
if (renderScript && renderScript.dataset.version)
return `?v=${renderScript.dataset.version}`
return ''
}
page.doRender = function () {

View File

@ -14,10 +14,12 @@
v1: CSS and JS files (lolisafe).
v2: Images and config files (manifest.json, browserconfig.xml, etc).
v3: CSS and JS files (libs such as bulma, lazyload, etc).
v4: Renders in /public/render/* directories (to be used by render.js).
#}
{% set v1 = "kz2IMxLx9c" %}
{% set v1 = "dLp5zKKIkN" %}
{% set v2 = "hiboQUzAzp" %}
{% set v3 = "hiboQUzAzp" %}
{% set v4 = "dLp5zKKIkN" %}
{#
These will be the links in the homepage and the No-JS uploader.

View File

@ -23,8 +23,8 @@
<script src="libs/lazyload/lazyload.min.js?v={{ globals.v3 }}"></script>
<script src="js/home.js?v={{ globals.v1 }}"></script>
<script src="js/sharex.js?v={{ globals.v1 }}"></script>
<!-- We assign an ID for this so that the script can find out its own version string -->
<script id="renderScript" src="js/render.js?v={{ globals.v1 }}"></script>
<!-- We assign an ID for this so that the script can find out version string for render images -->
<script id="renderScript" data-version="{{ globals.v4 }}" src="js/render.js?v={{ globals.v1 }}"></script>
{% endblock %}
{% block content %}