Skip to content

Commit 0889715

Browse files
committed
Moved all necessary tweakable variables into data.js
1 parent baf6a32 commit 0889715

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ I wanted a [web page](https://www.rokcoder.com/scratch) to showcase selected Scr
44

55
Although my site now incorporates a lot of PHP, this version is made entirely with JavaScript and HTML to make it easier to understand and host - I thought it was a landing page that others might enjoy using for their own projects.
66

7-
There are a few image files but the main body of code is contained in `index.html`, `rokcoder.css` (which contains a lot of garbage and a handful of useful stuff), `projectViewer.js` and `data.js`. To adapt this for your own website you only need to modify `data.js`. I think the format of that file is pretty self-evident.
7+
There are a few image files but the main body of code is contained in `index.html`, `rokcoder.css` (which contains a lot of garbage and a handful of useful stuff), `projectViewer.js` and `data.js`. To adapt this for your own website you only need to modify `data.js`.

data.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
// Modify these lines to make the website your own
2+
const header = 'RokCoder Scratch Projects';
3+
const footer = 'All projects on this site were created in Scratch by <a href="https://scratch.mit.edu/users/RokCoder/">RokCoder</a>';
4+
const logo = 'img/rokcoder.gif';
5+
6+
// TurboWarp is a branch of Scratch (by @GarboMuffin) with many speed and operational improvements
7+
const useTurboWarp = false;
8+
9+
// The projects can be broken up into genres - by default I'm using Ports, Arcade, Games, Multiplayer and Other
10+
// Each project can have any accompanying informational tabs as shown below - for example, the Tyrian game will present tabs for overview, credits, instructions and controls
111
const gameList = new Map([
212
[
313
'Ports', new Map([

index.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<head>
1010

11-
<title>RokCoder Scratch Projects</title>
11+
<title>Scratch Showcase</title>
1212
<link rel="icon" type="image/x-icon" href="img/favicon.ico">
1313

1414
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
@@ -22,8 +22,8 @@
2222

2323
<!-- Header line - title and RokCoder -->
2424
<div style="text-align: center; margin-bottom: 50px">
25-
<a href="../index.html"><img class='rokcoder' style='position:absolute; right:6px' src="img/rokcoder.gif"></a>
26-
<div class='shadow-text' style="font-size:54px; padding-top: 30px;">RokCoder's Scratch Projects</div>
25+
<a href="../index.html"><img class='rokcoder' id='logo' style='position:absolute; right:6px'></a>
26+
<div class='shadow-text' id="'header" style="font-size:54px; padding-top: 30px;">RokCoder's Scratch Projects</div>
2727
</div>
2828

2929
<!-- Thumbnails -->
@@ -62,8 +62,7 @@
6262

6363
<!-- Footer -->
6464
<div style="margin: auto; margin-top: 40px; padding: 8px; width: 60%; border-radius: 12px; background-color:cadetblue; font-size: 20px; color: black; border: solid black 4px; text-align: center;">
65-
<p>All projects on this site were created in Scratch by <a href="https://scratch.mit.edu/users/RokCoder/">RokCoder</a></p>
66-
<div>Note that this site uses TurboWarp to play the games. This does mean that multiplayer features and cloud high score tables will not work. To use those you can play any of <a href="https://scratch.mit.edu/users/RokCoder/projects/">RokCoder's shared projects</a> via the Scratch website</div>
65+
<div id='footer'></div>
6766
</div>
6867

6968
<script src="data.js"></script>

projectViewer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ var previewData;
2121

2222
$(document).ready(function () {
2323

24+
$('#header').html(header);
25+
$('#footer').html(footer);
26+
$('#logo').attr('src', logo);
27+
2428
// Set to use first tabbed genre, preview image of first game in that genre and first tabbed details view for that game
2529
genre = gameList.keys().next().value;
2630
let firstThumbId = gameList.get(genre).keys().next().value;
@@ -225,6 +229,9 @@ function playGame() {
225229
previewImage.fadeOut('fast', function () {
226230

227231
// Fire up the game
228-
turboWarp.append('<iframe id="test" src="https://turbowarp.org/' + thumbId + '/embed" width="499" height="416" allowtransparency="true" frameborder="0" scrolling="no" allowfullscreen></iframe>');
232+
if (useTurboWarp)
233+
turboWarp.append('<iframe id="test" src="https://turbowarp.org/' + thumbId + '/embed" width="499" height="416" allowtransparency="true" frameborder="0" scrolling="no" allowfullscreen></iframe>');
234+
else
235+
turboWarp.append('<iframe src="https://scratch.mit.edu/projects/' + thumbId + '/embed" allowtransparency="true" width="499" height="416" frameborder="0" scrolling="no" allowfullscreen></iframe>');
229236
});
230237
}

0 commit comments

Comments
 (0)