-
Notifications
You must be signed in to change notification settings - Fork 7
/
random.html
28 lines (27 loc) · 1.5 KB
/
random.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
title: "Random Recommendation"
section: library
permalink: /content/random/
description: This page redirects you to a random piece of content. It's a fun and low-pressure way to explore the library.
---
<p>{{ page.description }}</p>
<p id="no-js">Unfortunately for you, this page requires Javascript. I guess you could get the same effect by visiting <a href="/sitemap.xml">the sitemap</a> and selecting an arbitrary url?</p>
<p id="yes-js" style="display:none;">Now, let me see... How about...</p>
<script>
document.getElementById('no-js').style.display = 'none';
document.getElementById('yes-js').style = "";
var alltheurls = [
{%- for content in site.content -%}
{%- unless forloop.first -%},{%- endunless -%}
{%- assign w = site.data.random.w_archive -%}
{%- if content.course -%}{% assign w = site.data.random.w_three %}{%- endif -%}
{%- if content.status == 'rejected' -%}{% assign w = site.data.random.w_reject %}{%- endif -%}
{%- if content.status == 'featured' -%}{% assign w = site.data.random.w_featured %}{%- endif -%}
{%- unless content.external_url or content.drive_links.size > 0 or content.file_links.size > 0 -%}{% assign w = site.data.random.w_paid %}{%- endunless -%}
{%- for i in (1..w) -%}{{ content.url | jsonify }}{% unless forloop.last %},{% endunless %}{%- endfor -%}
{%- endfor -%}
];
var i = Math.floor(Math.random() * alltheurls.length);
if (typeof gtag != 'undefined') gtag('event', 'random_item', {link_url: alltheurls[i]});
location.replace(alltheurls[i]);
</script>