Skip to content

Commit

Permalink
Merge pull request #21 from etrusci-org/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
etrusci-org authored Nov 22, 2022
2 parents 173512d + 57918f1 commit 3fef94e
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Webserver with [PHP](https://php.net) 8 support.

## Install

Simply upload the contents of `olay/app/` into a directory of your webserver.
Simply upload the contents of `olay/app/` into a directory on your webserver.

---

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you prefer to host it yourself and/or create your own modules, see [DEVELOPME

---

## Basic Usage
## Usage

**Add a Browser-Source to your Scene:**

Expand Down Expand Up @@ -72,7 +72,7 @@ But you can also only change the `body` style to start. The wrappers are really
Here are two examples to copy&paste into the Browser-Source's CSS field.

```css
/* Styles for the whole module page */
/* Styles for the whole module page - this is most probably what you want */
body {
font-family: "Times New Roman", serif;
font-size: 32px;
Expand Down
9 changes: 9 additions & 0 deletions app/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ <h2>Clock</h2>

<code>mod=clock&format={hour}:{minute}:{second}</code>
<iframe loading="lazy" src="./?mod=clock&format={hour}:{minute}:{second}"></iframe>

<code>mod=clock&rep=true</code>
<iframe loading="lazy" src="./?mod=clock&rep=true"></iframe>

<code>mod=clock&rep=true&repMap=4</code>
<iframe loading="lazy" src="./?mod=clock&rep=true&repMap=4"></iframe>
</div>

<div class="mod kraken">
Expand Down Expand Up @@ -142,6 +148,9 @@ <h2>Quotes</h2>
<code>mod=quotes&updateRate=30000</code>
<iframe loading="lazy" src="./?mod=quotes&updateRate=10000"></iframe>

<code>mod=quotes&typingSpeed=50</code>
<iframe loading="lazy" src="./?mod=quotes&typingSpeed=50"></iframe>

<code>mod=quotes&source=https://cdn.jsdelivr.net/gh/etrusci-org/quotes@main/js/quotes-s9.min.js</code>
<iframe loading="lazy" src="./?mod=quotes&source=https://cdn.jsdelivr.net/gh/etrusci-org/quotes@main/js/quotes-s9.min.js"></iframe>
</div>
Expand Down
29 changes: 29 additions & 0 deletions app/lib/helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: move these functions to nifty repo


function fys(arr) {
for (let x = arr.length - 1; x > 0; x--) {
const y = Math.floor(Math.random() * x);
Expand All @@ -7,3 +10,29 @@ function fys(arr) {
}
return arr;
}


function replaceNumbers(num, mapKey) {
if (mapKey === undefined) {
mapKey = 1;
}

const map = {
1: { '0': 'A', '1': 'B', '2': 'C', '3': 'D', '4': 'E', '5': 'F', '6': 'G', '7': 'H', '8': 'I', '9': 'J' },
2: { '0': 'Z', '1': 'Y', '2': 'X', '3': 'W', '4': 'V', '5': 'U', '6': 'T', '7': 'S', '8': 'R', '9': 'Q' },
3: { '0': '9', '1': '8', '2': '7', '3': '6', '4': '5', '5': '4', '6': '3', '7': '2', '8': '1', '9': '0' },
4: { '0': '●', '1': '□', '2': '◆', '3': '■', '4': '○', '5': '▶', '6': '◁', '7': '▲', '8': '◇', '9': '▼' },
5: { '0': '٠', '1': '١', '2': '٢', '3': '٣', '4': '٤', '5': '٥', '6': '٦', '7': '٧', '8': '٨', '9': '٩' },
};

let chars = '';
for (const x of String(num).split('')) {
if (map[mapKey][x]) {
chars += map[mapKey][x];
} else {
chars += x;
}
}

return chars;
}
5 changes: 5 additions & 0 deletions app/lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ function boo(string $message = 'something went wrong', int $code = 1): void {
$MODCONFJSON = file_get_contents($MODCONFFILE);
$MODCONF = json_decode($MODCONFJSON, true, JSON_THROW_ON_ERROR);

// loop tru params the client wants to overwrite
foreach ($_GET as $k => $v) {
// silently skip unknown params
if (!array_key_exists($k, $MODCONF)) {
continue;
}

// get original/desired param value type from mod conf
$origType = get_debug_type($MODCONF[$k]);

// overwrite mod conf parameters depending on type and validity
switch ($origType) {
case 'string':
if (filter_var($v, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/./']])) {
Expand Down Expand Up @@ -95,6 +99,7 @@ function boo(string $message = 'something went wrong', int $code = 1): void {
}
}

// store mod conf as json for mod page scripts
$MODCONFJSON = json_encode($MODCONF, JSON_THROW_ON_ERROR);

// output
Expand Down
4 changes: 4 additions & 0 deletions app/mod/clock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Display date and time.
| `pad` | `true`, `false` | `true` |
| `padChar` | Any character except linebreaks | `0` |
| `format` | Template markup | `{year}-{month}-{day} {hour}:{minute}:{second}` |
| `rep` | `true`, `false` | `false` |
| `repMap` | `1`, `2`, `3`, `4`, `5` | `1` |

### Notes

Expand All @@ -32,3 +34,5 @@ Display date and time.
- [mod=clock&pad=false](https://etrusci.org/tool/olay/?mod=clock&pad=false)
- [mod=clock&padChar=X](https://etrusci.org/tool/olay/?mod=clock&padChar=X)
- [mod=clock&format={hour}:{minute}:{second}](https://etrusci.org/tool/olay/?mod=clock&format={hour}:{minute}:{second})
- [mod=clock&rep=true](https://etrusci.org/tool/olay/?mod=clock&rep=true)
- [mod=clock&rep=true&repMap=4](https://etrusci.org/tool/olay/?mod=clock&rep=true&repMap=4)
4 changes: 3 additions & 1 deletion app/mod/clock/conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"type": "human",
"pad": true,
"padChar": "0",
"format": "{year}-{month}-{day} {hour}:{minute}:{second}"
"format": "{year}-{month}-{day} {hour}:{minute}:{second}",
"rep": false,
"repMap": 1
}
19 changes: 17 additions & 2 deletions app/mod/clock/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,30 @@ function update() {
t = t.replace('{hour}', (MODCONF.pad) ? padNum(now.getHours(), 2, MODCONF.padChar) : now.getHours());
t = t.replace('{minute}', (MODCONF.pad) ? padNum(now.getMinutes(), 2, MODCONF.padChar) : now.getMinutes());
t = t.replace('{second}', (MODCONF.pad) ? padNum(now.getSeconds(), 2, MODCONF.padChar) : now.getSeconds());
if (MODCONF.rep) {
t = replaceNumbers(t, MODCONF.repMap);
}
MODOUTPUT.innerHTML = t;
}
if (MODCONF.type == 'unix') {
MODOUTPUT.innerHTML = `${Math.round(Date.now() / 1000)}`;
let t = Math.round(Date.now() / 1000);
if (!MODCONF.rep) {
MODOUTPUT.innerHTML = t;
}
else {
MODOUTPUT.innerHTML = replaceNumbers(t, MODCONF.repMap);
}
}
if (MODCONF.type == 'unixms') {
MODOUTPUT.innerHTML = `${Date.now()}`;
let t = Date.now();
if (!MODCONF.rep) {
MODOUTPUT.innerHTML = t;
}
else {
MODOUTPUT.innerHTML = replaceNumbers(t, MODCONF.repMap);
}
}
}
</script>
2 changes: 1 addition & 1 deletion app/mod/kraken/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Olay Kraken

Display Kraken Ticker data.
Display [Kraken](https://kraken.com) Ticker data.

**Module Handle:** `kraken`

Expand Down
2 changes: 1 addition & 1 deletion app/mod/numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Display numbers. Because.
| `rangeEnd` | Any integer | `100000` |
| `pad` | `true`, `false` | `false` |
| `padChar` | Any character except linebreaks | `0` |
| `labelType` | `true`, `false` | `false` |
| `labelType` | `true`, `false` | `false` |
| `labelNatural` | Any character except linebreaks | `=N` |
| `labelPrime` | Any character except linebreaks | `=P` |

Expand Down
1 change: 0 additions & 1 deletion app/mod/numbers/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
function update() {
if (MODCONF.type == 'random') {
let n = getRandomInteger(MODCONF.rangeStart, MODCONF.rangeEnd);
let labelTypeStr = '';
Expand Down
1 change: 1 addition & 0 deletions app/mod/quotes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ Display random quotes.

- [mod=quotes](https://etrusci.org/tool/olay/?mod=quotes)
- [mod=quotes&updateRate=10000](https://etrusci.org/tool/olay/?mod=quotes&updateRate=10000)
- [mod=quotes&typingSpeed=500](https://etrusci.org/tool/olay/?mod=quotes&typingSpeed=500)
- [mod=quotes&source=https://yourwebsite.org/quotes.js](https://etrusci.org/tool/olay/?mod=quotes&source=https://yourwebsite.org/quotes.js) *(will obviously not work with this example source url)*
2 changes: 1 addition & 1 deletion app/mod/rotator/conf.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"updateRate": 3000,
"updateRate": 10000,
"items": "a|b|c",
"shuffle": false
}
1 change: 1 addition & 0 deletions app/mod/uptime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Display time passed since this module was loaded.

- `format` template markup understands the following placeholders: `{days}`, `{hours}`, `{minutes}`, `{seconds}`. They are all optional.
- Use `%20` or `+` if you want spaces in `format`.
- You may want to disable the Browser-Source setting "Shutdown source when not visible" in OBS or the time will be reset when the page gets reloaded.

---

Expand Down
2 changes: 1 addition & 1 deletion app/tpl/header.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en-US">
<html lang="en-US" dir="ltr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand Down

0 comments on commit 3fef94e

Please sign in to comment.