Skip to content

Commit b5f4b6c

Browse files
Prettifying and adding Codacy
Also, badges.
1 parent 01a7c99 commit b5f4b6c

File tree

4 files changed

+81
-12
lines changed

4 files changed

+81
-12
lines changed

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ trim_trailing_whitespace = false
2222
indent_style = space
2323
indent_size = 2
2424

25+
[*.yml]
26+
indent_style = space
27+
indent_size = 2
28+
2529
# Linden Scripting Language abhors tabs
2630
[*.lsl]
2731
max_line_length = 108

.github/workflows/codacy.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
15

6+
# This workflow checks out code, performs a Codacy security scan
7+
# and integrates the results with the
8+
# GitHub Advanced Security code scanning feature. For more information on
9+
# the Codacy security scan action usage and parameters, see
10+
# https://github.com/codacy/codacy-analysis-cli-action.
11+
# For more information on Codacy Analysis CLI in general, see
12+
# https://github.com/codacy/codacy-analysis-cli.
13+
14+
name: Codacy Security Scan
15+
16+
on:
17+
push:
18+
branches: [ "master" ]
19+
pull_request:
20+
# The branches below must be a subset of the branches above
21+
branches: [ "master" ]
22+
schedule:
23+
- cron: '31 3 * * 1'
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
codacy-security-scan:
30+
permissions:
31+
contents: read # for actions/checkout to fetch code
32+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
33+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
34+
name: Codacy Security Scan
35+
runs-on: ubuntu-latest
36+
steps:
37+
# Checkout the repository to the GitHub Actions runner
38+
- name: Checkout code
39+
uses: actions/checkout@v3
40+
41+
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
42+
- name: Run Codacy Analysis CLI
43+
uses: codacy/codacy-analysis-cli-action@d840f886c4bd4edc059706d09c6a1586111c540b
44+
with:
45+
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
46+
# You can also omit the token and run the tools that support default configurations
47+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
48+
verbose: true
49+
output: results.sarif
50+
format: sarif
51+
# Adjust severity of non-security issues
52+
gh-code-scanning-compat: true
53+
# Force 0 exit code to allow SARIF file generation
54+
# This will handover control about PR rejection to the GitHub side
55+
max-allowed-issues: 2147483647
56+
57+
# Upload the SARIF file generated in the previous step
58+
- name: Upload SARIF results file
59+
uses: github/codeql-action/upload-sarif@v2
60+
with:
61+
sarif_file: results.sarif

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33

44
A very simple phpBB3 extension to locally store the content of a post being written, to avoid losing everything after a crash or session expiration.
55

6-
Logo designed by DALL·E 2.
6+
Logo designed by [DALL·E 2](https://openai.com/product/dall-e-2).
77

8+
![phpBB3 Logo](https://img.shields.io/badge/phpBB-3.3-blue) [![CodeQL](https://github.com/GwynethLlewelyn/post-local-storage/actions/workflows/codeql.yml/badge.svg)](https://github.com/GwynethLlewelyn/post-local-storage/actions/workflows/codeql.yml) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/83a20d04433341baa65c78d29fc3410a)](https://www.codacy.com/gh/GwynethLlewelyn/post-local-storage/dashboard?utm_source=github.com&utm_medium=referral&utm_content=GwynethLlewelyn/post-local-storage&utm_campaign=Badge_Grade)

gwynethllewelyn/postlocalstorage/styles/prosilver/template/custom_functions.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
// Cut the mustard.
33
if (!message.localStorage) return;
44
// You should probably use a more specific selector than this.
5-
var textarea = doc.querySelector('textarea');
5+
var textarea = doc.querySelector("textarea");
66
// The key for the key/value pair in localStorage is the current URL.
77
var key = message.location.href;
88
var item = null;
99
// Use the 'pagehide' event in modern browsers or 'beforeunload' in older browsers.
1010
var unloadEvent;
11-
if ('onpagehide' in message) {
12-
unloadEvent = 'pagehide';
11+
if ("onpagehide" in message) {
12+
unloadEvent = "pagehide";
1313
} else {
14-
unloadEvent = 'beforeunload';
14+
unloadEvent = "beforeunload";
1515
}
1616
// If there's a localStorage entry for the current URL, update the textarea with the saved value.
1717
item = message.localStorage.getItem(key);
@@ -22,7 +22,7 @@
2222
// This function will store the current value of the textarea in localStorage (or delete it if the textarea is blank).
2323
function updateStorage() {
2424
if (textarea.value) {
25-
item = JSON.stringify({'content': textarea.value});
25+
item = JSON.stringify({ content: textarea.value });
2626
message.localStorage.setItem(key, item);
2727
} else {
2828
message.localStorage.removeItem(key);
@@ -31,13 +31,17 @@
3131
message.removeEventListener(unloadEvent, updateStorage);
3232
}
3333
// When the user presses a key just *once* inside the textarea, run the storage function when the page is unloaded.
34-
textarea.addEventListener('keyup', function() {
35-
message.addEventListener(unloadEvent, updateStorage);
36-
message.setInterval(updateStorage, 10000);
37-
}, {'once': true});
34+
textarea.addEventListener(
35+
"keyup",
36+
function () {
37+
message.addEventListener(unloadEvent, updateStorage);
38+
message.setInterval(updateStorage, 10000);
39+
},
40+
{ once: true }
41+
);
3842
// When the form is submitted, delete the localStorage key/value pair.
39-
textarea.form.addEventListener('submit', function() {
43+
textarea.form.addEventListener("submit", function () {
4044
message.localStorage.removeItem(key);
4145
message.removeEventListener(unloadEvent, updateStorage);
4246
});
43-
}(this, this.document));
47+
})(this, this.document);

0 commit comments

Comments
 (0)