Permalink
Browse files

Allows render.js to append version string to renders

Thus if you need to update an existing render, you just need to update v1 version string, and the new version string will be appended to the render's URL, thus forcing browser to refresh.

Also updated javelin_1.png since apparently I missed a tiny bit of watermark.
  • Loading branch information...
BobbyWibowo committed Oct 23, 2018
1 parent 1517778 commit de87c37d66cf628c7c612318dcf79e192c988b24
Showing with 14 additions and 6 deletions.
  1. +11 −4 public/js/render.js
  2. BIN public/render/al/javelin_1.png
  3. +1 −1 views/_globals.njk
  4. +2 −1 views/home.njk
@@ -58,6 +58,14 @@ 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]
}
page.doRender = function () {
if (!page.renderRoot || !page.renderArray || !page.renderArray.length) { return }
@@ -68,13 +76,12 @@ page.doRender = function () {
element.title = 'ship waifu~'
element.innerHTML = '<i class="icon-picture-1"></i>'
} else {
if (!page.render) {
page.render = page.renderArray[Math.floor(Math.random() * page.renderArray.length)]
}
// Let us just allow people to get new render when toggling the option
page.render = page.renderArray[Math.floor(Math.random() * page.renderArray.length)]
element = document.createElement('img')
element.alt = element.title = 'ship waifu~'
element.className = 'is-hidden-mobile'
element.src = `${page.renderRoot}${page.render}`
element.src = `${page.renderRoot}${page.render}${page.getRenderVersion()}`
}
element.classList.add('render')
BIN +839 Bytes (100%) public/render/al/javelin_1.png
Binary file not shown.
@@ -15,7 +15,7 @@
v2: Images and config files (manifest.json, browserconfig.xml, etc).
v3: CSS and JS files (libs such as bulma, lazyload, etc).
#}
{% set v1 = "ys4BsdBoB8" %}
{% set v1 = "LZ9JN4pnIf" %}
{% set v2 = "Ii3JYKIhb0" %}
{% set v3 = "6MfcbDZldp" %}
@@ -23,7 +23,8 @@
<script type="text/javascript" src="libs/lazyload/lazyload.min.js?v={{ globals.v3 }}"></script>
<script type="text/javascript" src="js/home.js?v={{ globals.v1 }}"></script>
<script type="text/javascript" src="js/sharex.js?v={{ globals.v1 }}"></script>
<script type="text/javascript" src="js/render.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" type="text/javascript" src="js/render.js?v={{ globals.v1 }}"></script>
{% endblock %}
{% block content %}

0 comments on commit de87c37

Please sign in to comment.