Skip to content
This repository was archived by the owner on Oct 5, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"streetsidesoftware.code-spell-checker"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"openrct"
]
}
3 changes: 0 additions & 3 deletions assets/css/blog.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ iframe {
margin: 0 auto;
display: block;
border: 1px solid #ccc;
seamless;
frameborder: 0;
scrolling: no;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://caniuse.com/ all these attributes are not supported by any browser any more

}

#gradient {
Expand Down
25 changes: 13 additions & 12 deletions assets/js/getting-started.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
function setupPageControl(container, pageType) {
var buttons = document.querySelectorAll(container + ' .btn-' + pageType);
for (var i = 0; i < buttons.length; i++) {
function setupPageControl (container, pageType) {
const buttons = document.querySelectorAll(container + ' .btn-' + pageType);
for (let i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('click', function () {
if (!this.classList.contains('active')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you verified that this still works? IIRC, this does not exist in arrow functions, but it does in normal functions like how it was before. I don't really see a reason for changing all functions into arrow functions in the first place.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the change, I guess there isn't a strong reason to really use arrow functions in most places

var activeButtons = document.querySelectorAll(container + ' .btn-' + pageType + '.active');
for (var j = 0; j < activeButtons.length; j++) {
const activeButtons = document.querySelectorAll(container + ' .btn-' + pageType + '.active');
for (let j = 0; j < activeButtons.length; j++) {
activeButtons[j].classList.remove('active');
}
this.classList.add('active');

var pages = document.querySelectorAll(container + ' .page-' + pageType);
for (var j = 0; j < pages.length; j++) {
const pages = document.querySelectorAll(container + ' .page-' + pageType);
for (let j = 0; j < pages.length; j++) {
pages[j].classList.remove('show');
}
var targetPage = document.getElementById(this.getAttribute('data-page'));

const targetPage = document.getElementById(this.getAttribute('data-page'));
if (targetPage) {
targetPage.classList.add('show');
}
Expand All @@ -22,17 +23,17 @@ function setupPageControl(container, pageType) {
}
}

function showContent(slug) {
const showContent = (slug) => {
document.querySelector('[data-page="content-'+slug+'"]').click();
}

setupPageControl('body', 'platform');
setupPageControl('body', 'extractplatform');
setupPageControl('body', 'phase');

var platformPages = document.querySelectorAll('.page-platform');
for (var i = 0; i < platformPages.length; i++) {
var container = '#' + platformPages[i].id;
const platformPages = document.querySelectorAll('.page-platform');
for (let i = 0; i < platformPages.length; i++) {
const container = '#' + platformPages[i].id;
setupPageControl(container, 'distro');
}

Expand Down
33 changes: 18 additions & 15 deletions assets/js/home.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// http://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
function formatBytes (bytes, decimals) {
if(bytes == 0) return '0 Byte';
var k = 1000;
var dm = decimals + 1 || 3;
var sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
// https://stackoverflow.com/questions/15900485/correct-way-to-convert-size-in-bytes-to-kb-mb-gb-in-javascript
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use HTTPS

const formatBytes = (bytes, decimals) => {
if (bytes == 0) {
return '0 Byte';
}
const k = 1000;
const dm = decimals + 1 || 3;
const sizes = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));

return (bytes / Math.pow(k, i)).toPrecision(dm) + ' ' + sizes[i];
}

document.addEventListener('DOMContentLoaded', function () {
var link = document.getElementsByClassName('link')[0];
var size = document.getElementsByClassName('size')[0];
var version = document.getElementsByClassName('version')[0];
var platform = document.getElementsByClassName('platform')[0];
document.addEventListener('DOMContentLoaded', () => {
const link = document.getElementsByClassName('link')[0];
const size = document.getElementsByClassName('size')[0];
const version = document.getElementsByClassName('version')[0];
const platform = document.getElementsByClassName('platform')[0];

if (openrct2.currentPlatform !== openrct2.Platform.UNKNOWN) {
link.href = openrct2.currentPlatform.link;
Expand All @@ -21,12 +24,12 @@ document.addEventListener('DOMContentLoaded', function () {
version.innerHTML = openrct2.currentPlatform.version;
}

platform.addEventListener('click', function (e) {
platform.addEventListener('click', (e) => {
e.preventDefault();

var keys = Object.keys(openrct2.Platform);
const keys = Object.keys(openrct2.Platform);

for (var i = 0; i <= keys.length; i++) {
for (let i = 0; i <= keys.length; i++) {
if (openrct2.Platform[keys[i]].name === platform.innerHTML) {
if (i + 1 >= keys.length) {
i = 1;
Expand Down
14 changes: 8 additions & 6 deletions assets/js/openrct2.website.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var openrct2 = {};
let openrct2 = {};

openrct2.Platform = Object.freeze({
UNKNOWN: {},
Expand Down Expand Up @@ -28,16 +28,18 @@ openrct2.Platform = Object.freeze({
}
}); // Object.freeze() prevents this from being futzed with

function getPlatform(){
if (navigator.platform.indexOf('Win') >= 0){
if (navigator.userAgent.indexOf("WOW64") === -1 && navigator.userAgent.indexOf("Win64") === -1 ){
const getPlatform = () => {
const { platform, userAgent } = navigator;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (platform.includes('Win')) {
const win64UserAgents = ["WOW64", "Win64"];
if (!win64UserAgents.includes(userAgent)) {
return openrct2.Platform.WINDOWS32;
} else {
return openrct2.Platform.WINDOWS64; // 64-bit is the default as it is by far the most common these days
}
} else if (navigator.platform.indexOf('Linux') >= 0){
} else if (platform.includes('Linux')) {
return openrct2.Platform.LINUX;
} else if (navigator.platform === 'MacIntel'){
} else if (platform.includes('MacIntel')) {
return openrct2.Platform.MACOS;
} else {
return openrct2.Platform.UNKNOWN;
Expand Down