From 26e8981ebe893784e3559b164edad48832ae500a Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Tue, 24 Jun 2025 09:48:53 +0100
Subject: [PATCH 1/8] Add docker configuration files Similar to cc/search repo
---
config/site.conf | 38 ++++++++++++++++++++++++++++++++++++++
dev/node/Dockerfile | 6 ++++++
dev/web/Dockerfile | 19 +++++++++++++++++++
docker-compose.yml | 39 +++++++++++++++++++++++++++++++++++++++
4 files changed, 102 insertions(+)
create mode 100644 config/site.conf
create mode 100644 dev/node/Dockerfile
create mode 100644 dev/web/Dockerfile
create mode 100644 docker-compose.yml
diff --git a/config/site.conf b/config/site.conf
new file mode 100644
index 00000000..e468ef07
--- /dev/null
+++ b/config/site.conf
@@ -0,0 +1,38 @@
+
+ RewriteEngine On
+
+ # Set conservative/secure defaults
+
+ AllowOverride None
+ DirectoryIndex index.html
+ Options -Indexes
+
+ # Git
+
+ Require all denied
+
+ # Subversion
+
+ Require all denied
+
+ # Deny access to accidental uploads of macOS-specific directories and files
+ # .DS_Store
+
+ Require all denied
+
+ # resource forks
+
+ Require all denied
+
+
+ DocumentRoot /usr/local/apache2/htdocs
+
+ # Also serve HTML files without .html extension
+ RewriteCond %{REQUEST_FILENAME}.html -f
+ RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
+
+
+ ErrorDocument 404 /404.html
+
+
+# vim: ft=apache ts=4 sw=4 sts=4 sr noet
diff --git a/dev/node/Dockerfile b/dev/node/Dockerfile
new file mode 100644
index 00000000..06c29e81
--- /dev/null
+++ b/dev/node/Dockerfile
@@ -0,0 +1,6 @@
+# https://docs.docker.com/engine/reference/builder/
+
+# https://hub.docker.com/_/node
+FROM node:bookworm-slim
+
+RUN npm install --global prettier
diff --git a/dev/web/Dockerfile b/dev/web/Dockerfile
new file mode 100644
index 00000000..89c79dfb
--- /dev/null
+++ b/dev/web/Dockerfile
@@ -0,0 +1,19 @@
+# https://docs.docker.com/engine/reference/builder/
+
+# https://hub.docker.com/_/httpd
+FROM httpd:2.4
+
+# Update Apache2 configuration
+
+# Set ServerName to prevent warning
+RUN sed -e's/^#ServerName.*/ServerName static/' -i'' \
+ /usr/local/apache2/conf/httpd.conf
+
+# Enable mod_rewrite
+# https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
+RUN sed -e's/^#LoadModule rewrite/LoadModule rewrite/' -i'' \
+ /usr/local/apache2/conf/httpd.conf
+
+# Include site configuration
+RUN echo 'Include conf/config/site.conf' \
+ | tee -a /usr/local/apache2/conf/httpd.conf
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..1dbfa392
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,39 @@
+name: chooser
+services:
+ web:
+ build:
+ context: .
+ dockerfile: dev/web/Dockerfile
+ # Use Bash instad of sh (Dash) for improved signal handling
+ command: /bin/bash -c "
+ echo 'Starting static webserver at http://127.0.0.1:8080/';
+ /usr/local/bin/httpd-foreground
+ "
+ container_name: cc-chooser-web
+ ports:
+ - "8080:80"
+ restart: on-failure
+ volumes:
+ # Mount site configuration directory
+ - "./config:/usr/local/apache2/conf/config:ro"
+ # Mount website directory
+ - "./src:/usr/local/apache2/htdocs:ro"
+
+ node:
+ build:
+ context: .
+ dockerfile: dev/node/Dockerfile
+ # Continue running until shutdown (this allows docker compose exec which is
+ # much faster than docker compose run)
+ # Thank you: https://serverfault.com/a/1084975
+ command: /bin/sh -c "
+ trap 'exit' TERM;
+ echo 'Run the following command to format files with Prettier:';
+ echo ' docker compose exec node prettier --write src/';
+ while true; do sleep 1; done
+ "
+ container_name: cc-chooser-node
+ volumes:
+ # Mount repository to working directory
+ - "./:/opt"
+ working_dir: /opt
From 7335757735d5caefa71cee1ed139a4974746282d Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Tue, 24 Jun 2025 09:49:40 +0100
Subject: [PATCH 2/8] Add prettier configuration to match search repo Ignore
vocabulary directory from upstream
---
.prettierignore | 4 ++++
.prettierrc.yaml | 8 ++++++++
2 files changed, 12 insertions(+)
create mode 100644 .prettierignore
create mode 100644 .prettierrc.yaml
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000..d42a10c5
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,4 @@
+# https://prettier.io/docs/en/ignore.html
+
+# Ignore Vocabulary files (formatting handled upstream)
+src/vocabulary/
diff --git a/.prettierrc.yaml b/.prettierrc.yaml
new file mode 100644
index 00000000..8637e4ec
--- /dev/null
+++ b/.prettierrc.yaml
@@ -0,0 +1,8 @@
+# https://prettier.io/docs/en/options.html#print-width
+printWidth: 79
+
+# https://prettier.io/docs/en/options.html#bracket-line
+bracketSameLine: true
+
+# https://prettier.io/docs/en/options.html#single-attribute-per-line
+singleAttributePerLine: true
From be52872233ae0e873cd0cc88b5d53ba23dd5a646 Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Tue, 24 Jun 2025 09:55:49 +0100
Subject: [PATCH 3/8] Update README with docker-compose details
---
README.md | 48 +++++++++++++++++++++++++++++++++++++++---------
1 file changed, 39 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index ac1c123b..1be45e92 100644
--- a/README.md
+++ b/README.md
@@ -54,22 +54,52 @@ Once changes are implemented here, they need to be updated within the `/chooser`
Final production changes are deployed within vocabulary-theme Releases, updated within [`index-dev-env`][index-dev-env], and finally deployed to `index__stage` and then `index__prod` environments; going LIVE at `https://creativecommons.org/chooser`.
-## Setup
-1. open the `src/index.html` file within a browser to view the Chooser.
+### Setting up the Project
-[cc-legal-tools-app]: https://github.com/creativecommons/cc-legal-tools-app
-[cc-legal-tools-data]: https://github.com/creativecommons/cc-legal-tools-data
-[index-dev-env]: https://github.com/creativecommons/index-dev-env
-[index-prototype]: https://github.com/creativecommons/index-prototype
-[vocabulary]: https://github.com/creativecommons/vocabulary
-[vocabulary-theme]: https://github.com/creativecommons/vocabulary-theme
+For information on learning and installing the prerequisite technologies for this project, please see [Foundational technologies — Creative Commons Open Source][found-tech].
+[found-tech]: https://opensource.creativecommons.org/contributing-code/foundational-tech/
+
+### Docker Compose Setup
+
+Use the following instructions to start the Project with docker compose.
+
+1. Navigate to the creativecommons/chooser Project that you have cloned
+2. **Run the containers**
+
+ ```shell
+ docker compose up
+ ```
+
+3. After running the above command, Docker will use the `docker-compose.yml` file and Build a local environment for you
+4. Navigate to http://localhost:8080 in your browser and the app would be running.
+5. **stop the containers**
+
+ To stop the app from running, simply open an another instance of terminal and type:
+
+ ```shell
+ docker compose down
+ ```
+
+ or
+
+ You can simply revisit the existing terminal which is running the container
+ and type `CTRL + C`
+
+
+### Format with Prettier
+
+Run the following command to format files with Prettier:
+
+```shell
+docker compose exec node prettier --write src/
+```
## Structure
The initial markup is rendered via the `index.html` file. Visual display is derived from the `style.css` rules. Styles extend from `src/vocabulary`.
-On initlialization the `scripts.js` functions set the correct fieldsets to default display; based on user provided actions through the stepper fieldsets will display or hide, exposing the relevant pathways to getting a `tool` recommendation. Correct pathways are located within the `rawStatePathRoutes` array. When a correct pathway matches the current `state`, the appropriate `tool` is matched and recommended, if the current state is not a known pathway the `tool` is set to `unknown` until the required input is given.
+On initialization the `scripts.js` functions set the correct fieldsets to default display; based on user provided actions through the stepper fieldsets will display or hide, exposing the relevant pathways to getting a `tool` recommendation. Correct pathways are located within the `rawStatePathRoutes` array. When a correct pathway matches the current `state`, the appropriate `tool` is matched and recommended, if the current state is not a known pathway the `tool` is set to `unknown` until the required input is given.
The main `tool` recommendation content is pulled via the appropriate `` markup located within HTML. Additional information for the marking formats is also sourced from these `` elements and the contents of the `Attribution Details` fields.
From dd86dab3174bf89c04bcf2bbcd6395145eb6bc93 Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Tue, 24 Jun 2025 09:56:21 +0100
Subject: [PATCH 4/8] Format with prettier
---
src/index.html | 1674 ++++++++++++++++++++++++++++++------------------
src/scripts.js | 954 ++++++++++++++-------------
src/style.css | 327 +++++-----
3 files changed, 1722 insertions(+), 1233 deletions(-)
diff --git a/src/index.html b/src/index.html
index 3ca47d84..eae9478c 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,122 +1,172 @@
-
+
-
-Chooser
+
+ Chooser
+
+
+
+
+
+
+
+
+
+
+
+
+ Skip to content
-
-
-
-
-
-
-
-
-
-
-
-
-Skip to content
-
-
-
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
+
+
CC0 1.0
-
-
-
-
-
-
+
+
+
+
+
+
CC0 1.0 Universal
-
-
-
-
By marking the work with a CC0 public domain dedication, the creator is giving up their copyright and allowing reusers to distribute, remix, adapt, and build upon the material in any medium or format, even for commercial purposes.
-
-
-
+
+
+
+
+ By marking the work with a CC0 public domain dedication, the creator
+ is giving up their copyright and allowing reusers to distribute,
+ remix, adapt, and build upon the material in any medium or format,
+ even for commercial purposes.
+
+
+
+
-
CC0
- This work has been marked as dedicated to the public domain.
+ CC0
+ This work has been marked as dedicated to the public domain.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC-BY 4.0
-
-
-
-
-
-
+
+
+
+
+
+
Creative Commons Attribution 4.0 International
-
+
-
-
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, even for commercial purposes.
-
+
+
+ This license requires that reusers give credit to the creator. It
+ allows reusers to distribute, remix, adapt, and build upon the
+ material in any medium or format, even for commercial purposes.
+
+
-
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-SA 4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Creative Commons Attribution-ShareAlike 4.0 International
-
-
-
-
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, even for commercial purposes. If others remix, adapt, or build upon the material, they must license the modified material under identical terms.
-
-
-
+
+
+
+
+ This license requires that reusers give credit to the creator. It
+ allows reusers to distribute, remix, adapt, and build upon the
+ material in any medium or format, even for commercial purposes. If
+ others remix, adapt, or build upon the material, they must license
+ the modified material under identical terms.
+
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
SA
- Adaptations must be shared under the same terms.
+ SA
+ Adaptations must be shared under the same terms.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-ND 4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Creative Commons Attribution-NoDerivatives 4.0 International
-
-
-
-
This license requires that reusers give credit to the creator. It allows reusers to copy and distribute the material in any medium or format in unadapted form only, even for commercial purposes.
-
+
-
+
+
+ This license requires that reusers give credit to the creator. It
+ allows reusers to copy and distribute the material in any medium or
+ format in unadapted form only, even for commercial purposes.
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
ND
- No derivatives or adaptations of your work are permitted.
+ ND
+ No derivatives or adaptations of your work are permitted.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-NC 4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Creative Commons Attribution-NonCommercial 4.0 International
-
+
-
-
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only.
-
+
+
+ This license requires that reusers give credit to the creator. It
+ allows reusers to distribute, remix, adapt, and build upon the
+ material in any medium or format, for noncommercial purposes only.
+
+
-
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
NC
-
- Only noncommercial use of your work is permitted.
- Noncommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
-
+ NC
+
+ Only noncommercial use of your work is permitted.
+ Noncommercial means not primarily intended for or directed
+ towards commercial advantage or monetary compensation.
+
+
+ See the License Deed
+
-
-
- See the License Deed
-
-
-
-
+
+
CC BY-NC-SA 4.0
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
- Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
-
-
-
-
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. If others modify or adapt the material, they must license the modified material under identical terms.
-
-
-
+
+ Creative Commons Attribution-NonCommercial-ShareAlike 4.0
+ International
+
+
+
+
+
+ This license requires that reusers give credit to the creator. It
+ allows reusers to distribute, remix, adapt, and build upon the
+ material in any medium or format, for noncommercial purposes only. If
+ others modify or adapt the material, they must license the modified
+ material under identical terms.
+
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
NC
-
- Only noncommercial use of your work is permitted.
- Noncommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
-
+ NC
+
+ Only noncommercial use of your work is permitted.
+ Noncommercial means not primarily intended for or directed
+ towards commercial advantage or monetary compensation.
+
-
SA
- Adaptations must be shared under the same terms.
+ SA
+ Adaptations must be shared under the same terms.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-NC-ND 4.0
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
- Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
-
-
-
-
This license requires that reusers give credit to the creator. It allows reusers to copy and distribute the material in any medium or format in unadapted form and for noncommercial purposes only.
-
-
-
+
+ Creative Commons Attribution-NonCommercial-NoDerivatives 4.0
+ International
+
+
+
+
+
+ This license requires that reusers give credit to the creator. It
+ allows reusers to copy and distribute the material in any medium or
+ format in unadapted form and for noncommercial purposes only.
+
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
NC
-
- Only noncommercial use of your work is permitted.
- Noncommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
-
+ NC
+
+ Only noncommercial use of your work is permitted.
+ Noncommercial means not primarily intended for or directed
+ towards commercial advantage or monetary compensation.
+
-
ND
- No derivatives or adaptations of your work are permitted.
+ ND
+ No derivatives or adaptations of your work are permitted.
-
-
- See the License Deed
-
-
-
- {{title}} {{copyright}} by {{creator}} is {{typeAsVerb}} {{toolName}}. To view a copy of this {{type}}, visit {{toolURL}}
-
-
-
+
+
+ See the License Deed
+
+
+
+
+ {{title}} {{copyright}} by {{creator}} is {{typeAsVerb}} {{toolName}}.
+ To view a copy of this {{type}}, visit {{toolURL}}
+
+
+
diff --git a/src/scripts.js b/src/scripts.js
index 6675d72a..8cea38ad 100644
--- a/src/scripts.js
+++ b/src/scripts.js
@@ -1,34 +1,33 @@
-
// all possible State Path Routes
let rawStatePathRoutes = [
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0',
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/(attribution-details)&tool=cc-by',
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/(attribution-details)&tool=cc-by-sa',
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/(attribution-details)&tool=cc-by-nd',
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/(attribution-details)&tool=cc-by-nc',
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/(attribution-details)&tool=cc-by-nc-sa',
- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/(attribution-details)&tool=cc-by-nc-nd',
-
- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by',
- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-sa',
- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nd',
- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc',
- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-sa',
- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-nd',
- 'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0'
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0",
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/(attribution-details)&tool=cc-by",
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/(attribution-details)&tool=cc-by-sa",
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/(attribution-details)&tool=cc-by-nd",
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/(attribution-details)&tool=cc-by-nc",
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/(attribution-details)&tool=cc-by-nc-sa",
+ "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/(attribution-details)&tool=cc-by-nc-nd",
+
+ "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by",
+ "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-sa",
+ "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nd",
+ "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc",
+ "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-sa",
+ "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-nd",
+ "do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0",
];
// empty state obj
let state = {};
// all found fieldsets
-const fieldsets = document.querySelectorAll('fieldset');
+const fieldsets = document.querySelectorAll("fieldset");
// all found toggles
-const toggles = document.querySelectorAll('#mark-your-work footer input');
+const toggles = document.querySelectorAll("#mark-your-work footer input");
// all found copiers
-const copiers = document.querySelectorAll('#mark-your-work footer button');
+const copiers = document.querySelectorAll("#mark-your-work footer button");
// empty defaults obj
let applyDefaults = {};
@@ -36,359 +35,421 @@ let applyDefaults = {};
// set elemnts which need defaults
// on initial page load
applyDefaults.elements = [
- '#require-attribution',
- '#allow-commercial-use',
- '#allow-derivatives',
- '#share-alike',
- '#waive-your-copyright',
- '#confirmation'
+ "#require-attribution",
+ "#allow-commercial-use",
+ "#allow-derivatives",
+ "#share-alike",
+ "#waive-your-copyright",
+ "#confirmation",
];
// function to parse and build state.possibilities
// from rawStatePathRoutes
function setStatePossibilities(state) {
+ // create state possibilities from possible tools with adjoining statePaths
+ state.possibilities = [];
+ rawStatePathRoutes.forEach((path, index) => {
+ statePath = path.split("&");
+ statepath = statePath;
+ tool = statePath[statePath.length - 1].split("=");
+ tool = tool[1];
+
+ regEx = /\(([^)]+)\)/g;
+ optionals = statePath[0].match(regEx);
+
+ optionals.forEach((optional) => {
+ noOptionalsPath = statePath[0].replace(optional, "");
+ });
- // create state possibilities from possible tools with adjoining statePaths
- state.possibilities = [];
- rawStatePathRoutes.forEach((path, index) => {
-
- statePath = path.split("&");
- statepath = statePath;
- tool = statePath[statePath.length - 1].split("=");
- tool = tool[1];
-
- regEx = /\(([^)]+)\)/g;
- optionals = statePath[0].match(regEx);
-
- optionals.forEach ((optional) => {
-
- noOptionalsPath = statePath[0].replace(optional,'');
-
- });
+ fullPath = statePath[0].replace(/[{()}]/g, "") + "/";
- fullPath = statePath[0].replace(/[{()}]/g, '') + '/';
-
- if (state.possibilities[tool] == undefined) {
- state.possibilities[tool] = [];
- }
- state.possibilities[tool].push(fullPath);
- state.possibilities[tool].push(noOptionalsPath);
-
- });
+ if (state.possibilities[tool] == undefined) {
+ state.possibilities[tool] = [];
+ }
+ state.possibilities[tool].push(fullPath);
+ state.possibilities[tool].push(noOptionalsPath);
+ });
}
// function to establish state.parts
function setStateParts(state) {
- state.parts = [];
+ state.parts = [];
- // temp defaults
- state.parts[0] = 'do-you-know-which-license-you-need/yes/';
- state.parts[8] = 'attribution-details/';
+ // temp defaults
+ state.parts[0] = "do-you-know-which-license-you-need/yes/";
+ state.parts[8] = "attribution-details/";
}
// function to update state.parts
function updateStateParts(element, index, event, state) {
+ state.parts[index] = element.id + "/" + event.target.value + "/";
+
+ // check if checkbox, with siblings
+ if (event.target.getAttribute("type") == "checkbox") {
+ let checkboxElements = element.querySelectorAll('input[type="checkbox"]');
+ let checkboxes = [];
+ checkboxElements.forEach((checkbox, index) => {
+ if (checkbox.checked) {
+ checkboxes[index] = checkbox.value;
+ }
+ });
- state.parts[index] = element.id + '/' + event.target.value + '/';
-
- // check if checkbox, with siblings
- if (event.target.getAttribute('type') == 'checkbox') {
- let checkboxElements = element.querySelectorAll('input[type="checkbox"]');
- let checkboxes = [];
- checkboxElements.forEach((checkbox, index) => {
- if (checkbox.checked) {
- checkboxes[index] = checkbox.value;
- }
- });
-
-
- let joinedCheckboxes = checkboxes.filter(Boolean).join('+');
-
- state.parts[index] = element.id + '+' + joinedCheckboxes + '/';;
- }
-
- // check if text input
- if (event.target.getAttribute('type') == 'text') {
+ let joinedCheckboxes = checkboxes.filter(Boolean).join("+");
- state.parts[index] = element.id + '/';
+ state.parts[index] = element.id + "+" + joinedCheckboxes + "/";
+ }
- }
+ // check if text input
+ if (event.target.getAttribute("type") == "text") {
+ state.parts[index] = element.id + "/";
+ }
}
-// function to combine current tracked
+// function to combine current tracked
// state.parts into state.current
-function setStateCurrent(element, index, state) {
- state.parts.forEach((element, i) => {
- if (i > index) {
- state.parts.splice(i);
- }
- });
-
- state.current = state.parts.join('') //.slice(0, -1);
+function setStateCurrent(element, index, state) {
+ state.parts.forEach((element, i) => {
+ if (i > index) {
+ state.parts.splice(i);
+ }
+ });
+
+ state.current = state.parts.join(""); //.slice(0, -1);
}
// function to set state.props
// including setting state.props.tool (if valid)
// or error
function setStateProps(index, state) {
+ state.props = {};
+ state.props.tool = "unknown";
- state.props = {};
- state.props.tool = 'unknown';
-
- // check and match possibilities
- Object.keys(state.possibilities).forEach((possibility) => {
- if(state.possibilities[possibility].includes(state.current)) {
- state.props.tool = possibility;
- }
- });
+ // check and match possibilities
+ Object.keys(state.possibilities).forEach((possibility) => {
+ if (state.possibilities[possibility].includes(state.current)) {
+ state.props.tool = possibility;
+ }
+ });
- // set toolFull, toolShort, toolURL
- if (state.props.tool != 'unknown' && state.props.tool != 'cc-0' ) { // was OR, changes to AND
+ // set toolFull, toolShort, toolURL
+ if (state.props.tool != "unknown" && state.props.tool != "cc-0") {
+ // was OR, changes to AND
- formattedTool = state.props.tool.replace(/-/, ' ').toUpperCase();
- state.props.toolShort = formattedTool + ' 4.0';
+ formattedTool = state.props.tool.replace(/-/, " ").toUpperCase();
+ state.props.toolShort = formattedTool + " 4.0";
- // set shortName
- shortName = state.props.tool.replace(/cc-/, '');
- state.props.toolURL = 'https://creativecommons.org/licenses/'+ shortName +'/4.0/';
- }
+ // set shortName
+ shortName = state.props.tool.replace(/cc-/, "");
+ state.props.toolURL =
+ "https://creativecommons.org/licenses/" + shortName + "/4.0/";
+ }
- if (state.props.tool != 'unknown' ) {
- //set longName
- let tool = state.props.tool;
- let template = document.getElementById(tool);
- let templateContent = template.content.cloneNode(true);
- state.props.toolLong = templateContent.querySelector('header h4').textContent;
- }
-
- if (state.props.tool == 'cc-0') {
+ if (state.props.tool != "unknown") {
+ //set longName
+ let tool = state.props.tool;
+ let template = document.getElementById(tool);
+ let templateContent = template.content.cloneNode(true);
+ state.props.toolLong =
+ templateContent.querySelector("header h4").textContent;
+ }
- state.props.toolShort = 'CC0 1.0';
+ if (state.props.tool == "cc-0") {
+ state.props.toolShort = "CC0 1.0";
- // set toolFull
- state.props.toolURL = 'https://creativecommons.org/publicdomain/zero/1.0/';
- }
+ // set toolFull
+ state.props.toolURL = "https://creativecommons.org/publicdomain/zero/1.0/";
+ }
- state.props.cursor = index;
+ state.props.cursor = index;
- state.props.attribution = [];
- setStatePropsAttribution(state);
+ state.props.attribution = [];
+ setStatePropsAttribution(state);
}
-// function to just set the attribution
+// function to just set the attribution
// subset of state.props (for use other places)
function setStatePropsAttribution(state) {
-
- if (document.querySelector('#attribution-details #title').value == '') {
- state.props.attribution.title = document.querySelector('#attribution-details #title').placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.title = document.querySelector('#attribution-details #title').value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (document.querySelector('#attribution-details #creator').value == '') {
- state.props.attribution.creator = document.querySelector('#attribution-details #creator').placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.creator = document.querySelector('#attribution-details #creator').value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (document.querySelector('#attribution-details #work-link').value == '') {
- state.props.attribution.workLink = document.querySelector('#attribution-details #work-link').placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.workLink = document.querySelector('#attribution-details #work-link').value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (document.querySelector('#attribution-details #creator-link').value == '') {
- state.props.attribution.creatorLink = document.querySelector('#attribution-details #creator-link').placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.creatorLink = document.querySelector('#attribution-details #creator-link').value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (document.querySelector('#attribution-details #work-creation-year').value == '') {
- state.props.attribution.workCreationYear = document.querySelector('#attribution-details #work-creation-year').placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.workCreationYear = document.querySelector('#attribution-details #work-creation-year').value.replace(/(<([^>]+)>)/gi, "");
- }
+ if (document.querySelector("#attribution-details #title").value == "") {
+ state.props.attribution.title = document
+ .querySelector("#attribution-details #title")
+ .placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.title = document
+ .querySelector("#attribution-details #title")
+ .value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (document.querySelector("#attribution-details #creator").value == "") {
+ state.props.attribution.creator = document
+ .querySelector("#attribution-details #creator")
+ .placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.creator = document
+ .querySelector("#attribution-details #creator")
+ .value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (document.querySelector("#attribution-details #work-link").value == "") {
+ state.props.attribution.workLink = document
+ .querySelector("#attribution-details #work-link")
+ .placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.workLink = document
+ .querySelector("#attribution-details #work-link")
+ .value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (
+ document.querySelector("#attribution-details #creator-link").value == ""
+ ) {
+ state.props.attribution.creatorLink = document
+ .querySelector("#attribution-details #creator-link")
+ .placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.creatorLink = document
+ .querySelector("#attribution-details #creator-link")
+ .value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (
+ document.querySelector("#attribution-details #work-creation-year").value ==
+ ""
+ ) {
+ state.props.attribution.workCreationYear = document
+ .querySelector("#attribution-details #work-creation-year")
+ .placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.workCreationYear = document
+ .querySelector("#attribution-details #work-creation-year")
+ .value.replace(/(<([^>]+)>)/gi, "");
+ }
}
// function to reset values beyond current fieldset
// [T]: this could potentially do with a refactor
-// check for input type, and them perform
+// check for input type, and them perform
// contextual resets to universal defaults
-// unchecked for radio/checkbox, noselect for
+// unchecked for radio/checkbox, noselect for
// selection dropdown, etc.
function clearStepsAfterCursor(fieldsets, state) {
- fieldsets.forEach((element, index) => {
- if (index > state.props.cursor) {
-
- if (index == 1) {
- element.querySelector("#tool").value = "noselect";
- }
-
- if (index != 1 | index != 8) {
-
- let inputs = element.querySelectorAll('input');
- inputs.forEach((input, i) => {
- input.checked = false;
- });
- }
- }
- });
+ fieldsets.forEach((element, index) => {
+ if (index > state.props.cursor) {
+ if (index == 1) {
+ element.querySelector("#tool").value = "noselect";
+ }
+
+ if ((index != 1) | (index != 8)) {
+ let inputs = element.querySelectorAll("input");
+ inputs.forEach((input, i) => {
+ input.checked = false;
+ });
+ }
+ }
+ });
}
// function to render "tool recommendation",
// if valid tool from state.parts and/or state.current
function renderToolRec(state) {
+ if (state.props.tool != "unknown") {
+ document.querySelector("#tool-recommendation").classList.remove("disable");
- if (state.props.tool != 'unknown' ) {
- document.querySelector('#tool-recommendation').classList.remove('disable');
-
- let tool = state.props.tool;
- let template = document.getElementById(tool);
- let templateContent = template.content.cloneNode(true);
- document.querySelector('#tool-recommendation .tool').textContent = '';
- document.querySelector('#tool-recommendation .tool').appendChild(templateContent);
- }
- else if (state.props.tool == 'unknown') {
- document.querySelector('#tool-recommendation').classList.add('disable');
- document.querySelector('#tool-recommendation .tool').textContent = '';
- }
-
+ let tool = state.props.tool;
+ let template = document.getElementById(tool);
+ let templateContent = template.content.cloneNode(true);
+ document.querySelector("#tool-recommendation .tool").textContent = "";
+ document
+ .querySelector("#tool-recommendation .tool")
+ .appendChild(templateContent);
+ } else if (state.props.tool == "unknown") {
+ document.querySelector("#tool-recommendation").classList.add("disable");
+ document.querySelector("#tool-recommendation .tool").textContent = "";
+ }
}
// render specifically the mark formats subsections
function renderMarkingFormats(state) {
-
- if (state.props.tool != 'unknown' ) {}
-
- setStatePropsAttribution(state);
-
- let attribution = state.props.attribution;
-
- let type = "license";
- let typeAsVerb = "licensed under";
- let copyright = ' © ' + attribution.workCreationYear;
- if (state.props.tool == 'cc-0') {
- type = "mark";
- typeAsVerb = "marked";
- copyright = '';
- }
-
- // set contents of plain text mark
- // [T]: reverse use of since it has limits on tokenization capacity, even if
- // it allows more dev readability.
- let template = document.getElementById('plain-text');
- let templateContent = template.content.cloneNode(true);
- document.querySelector('#mark-your-work .plain-text.mark').textContent = '';
-
- function parseTokens(name, value, str){
- return str.replaceAll("{{"+name+"}}", value);
- }
-
- let markProps = {};
- markProps.title = attribution.title;
- markProps.year = attribution.workCreationYear;
- markProps.creator = attribution.creator;
- markProps.type = type;
- markProps.typeAsVerb = typeAsVerb;
- markProps.toolShort = state.props.toolShort;
- markProps.toolLong = state.props.toolLong;
- markProps.toolURL = state.props.toolURL;
- markProps.copyright = copyright;
-
- // set contents of plain text mark
- plainTextFullName = document.querySelector('#plain-text-full-name').checked;
-
- if (plainTextFullName == true) {
- markProps.toolName = state.props.toolLong;
-
- } else {
- markProps.toolName = state.props.toolShort;
- }
-
- // [T]: could carve out separate sections for different mark formats here
- // only handles plain text at the moment
- for (const [key, value] of Object.entries(markProps)) {
- templateContent.textContent = parseTokens(key, value, templateContent.textContent);
- }
- document.querySelector('#mark-your-work .plain-text.mark').appendChild(templateContent);
-
- // set contents of rich text mark
- let ccSVG = ' ';
- let bySVG = ' ';
- let saSVG = ' ';
- let ncSVG = ' ';
- let ndSVG = ' ';
- let zeroSVG = ' ';
-
- const currentTool = state.props.tool;
- switch (currentTool) {
- case 'cc-0':
- ccIconSet = ccSVG + zeroSVG;
- break;
- case 'cc-by':
- ccIconSet = ccSVG + bySVG;
- break;
- case 'cc-by-sa':
- ccIconSet = ccSVG + bySVG + saSVG;
- break;
- case 'cc-by-nd':
- ccIconSet = ccSVG + bySVG + ndSVG;
- break;
- case 'cc-by-nc':
- ccIconSet = ccSVG + bySVG + ncSVG;
- break;
- case 'cc-by-nc-sa':
- ccIconSet = ccSVG + bySVG + ncSVG + saSVG;
- break;
- case 'cc-by-nc-nd':
- ccIconSet = ccSVG + bySVG + ncSVG + ndSVG;
- break;
- default:
- currentTool = '';
- }
-
- richTextFullName = document.querySelector('#rich-text-full-name').checked;
-
- if (richTextFullName == true) {
- markProps.toolName = state.props.toolLong;
-
- } else {
- markProps.toolName = state.props.toolShort;
- }
-
- let richTextMark = '' + attribution.title + ' ' + copyright + ' by ' + '' + attribution.creator + ' ' + ' is ' + typeAsVerb + ' ' + '' + markProps.toolName + ' ' + ccIconSet;
- document.querySelector('#mark-your-work .rich-text.mark').innerHTML = richTextMark;
-
-
- // set contents of HTML mark
- htmlFullName = document.querySelector('#html-full-name').checked;
-
- if (htmlFullName == true) {
- markProps.toolName = state.props.toolLong;
-
- } else {
- markProps.toolName = state.props.toolShort;
- }
- //defaultHTML = 'This work is licensed under CC BY-SA 4.0
';
- let htmlMark = '' + attribution.title + ' ' + copyright + ' by ' + '' + attribution.creator + ' ' + ' is ' + typeAsVerb + ' ' + '' + markProps.toolName + ' ' + ccIconSet;
- document.querySelector('#mark-your-work .html.mark').innerHTML = htmlMark;
+ if (state.props.tool != "unknown") {
+ }
+
+ setStatePropsAttribution(state);
+
+ let attribution = state.props.attribution;
+
+ let type = "license";
+ let typeAsVerb = "licensed under";
+ let copyright = " © " + attribution.workCreationYear;
+ if (state.props.tool == "cc-0") {
+ type = "mark";
+ typeAsVerb = "marked";
+ copyright = "";
+ }
+
+ // set contents of plain text mark
+ // [T]: reverse use of since it has limits on tokenization capacity, even if
+ // it allows more dev readability.
+ let template = document.getElementById("plain-text");
+ let templateContent = template.content.cloneNode(true);
+ document.querySelector("#mark-your-work .plain-text.mark").textContent = "";
+
+ function parseTokens(name, value, str) {
+ return str.replaceAll("{{" + name + "}}", value);
+ }
+
+ let markProps = {};
+ markProps.title = attribution.title;
+ markProps.year = attribution.workCreationYear;
+ markProps.creator = attribution.creator;
+ markProps.type = type;
+ markProps.typeAsVerb = typeAsVerb;
+ markProps.toolShort = state.props.toolShort;
+ markProps.toolLong = state.props.toolLong;
+ markProps.toolURL = state.props.toolURL;
+ markProps.copyright = copyright;
+
+ // set contents of plain text mark
+ plainTextFullName = document.querySelector("#plain-text-full-name").checked;
+
+ if (plainTextFullName == true) {
+ markProps.toolName = state.props.toolLong;
+ } else {
+ markProps.toolName = state.props.toolShort;
+ }
+
+ // [T]: could carve out separate sections for different mark formats here
+ // only handles plain text at the moment
+ for (const [key, value] of Object.entries(markProps)) {
+ templateContent.textContent = parseTokens(
+ key,
+ value,
+ templateContent.textContent,
+ );
+ }
+ document
+ .querySelector("#mark-your-work .plain-text.mark")
+ .appendChild(templateContent);
+
+ // set contents of rich text mark
+ let ccSVG =
+ ' ';
+ let bySVG =
+ ' ';
+ let saSVG =
+ ' ';
+ let ncSVG =
+ ' ';
+ let ndSVG =
+ ' ';
+ let zeroSVG =
+ ' ';
+
+ const currentTool = state.props.tool;
+ switch (currentTool) {
+ case "cc-0":
+ ccIconSet = ccSVG + zeroSVG;
+ break;
+ case "cc-by":
+ ccIconSet = ccSVG + bySVG;
+ break;
+ case "cc-by-sa":
+ ccIconSet = ccSVG + bySVG + saSVG;
+ break;
+ case "cc-by-nd":
+ ccIconSet = ccSVG + bySVG + ndSVG;
+ break;
+ case "cc-by-nc":
+ ccIconSet = ccSVG + bySVG + ncSVG;
+ break;
+ case "cc-by-nc-sa":
+ ccIconSet = ccSVG + bySVG + ncSVG + saSVG;
+ break;
+ case "cc-by-nc-nd":
+ ccIconSet = ccSVG + bySVG + ncSVG + ndSVG;
+ break;
+ default:
+ currentTool = "";
+ }
+
+ richTextFullName = document.querySelector("#rich-text-full-name").checked;
+
+ if (richTextFullName == true) {
+ markProps.toolName = state.props.toolLong;
+ } else {
+ markProps.toolName = state.props.toolShort;
+ }
+
+ let richTextMark =
+ '' +
+ attribution.title +
+ " " +
+ copyright +
+ " by " +
+ '' +
+ attribution.creator +
+ " " +
+ " is " +
+ typeAsVerb +
+ " " +
+ '' +
+ markProps.toolName +
+ " " +
+ ccIconSet;
+ document.querySelector("#mark-your-work .rich-text.mark").innerHTML =
+ richTextMark;
+
+ // set contents of HTML mark
+ htmlFullName = document.querySelector("#html-full-name").checked;
+
+ if (htmlFullName == true) {
+ markProps.toolName = state.props.toolLong;
+ } else {
+ markProps.toolName = state.props.toolShort;
+ }
+ //defaultHTML = 'This work is licensed under CC BY-SA 4.0
';
+ let htmlMark =
+ '' +
+ attribution.title +
+ " " +
+ copyright +
+ " by " +
+ '' +
+ attribution.creator +
+ " " +
+ " is " +
+ typeAsVerb +
+ " " +
+ '' +
+ markProps.toolName +
+ " " +
+ ccIconSet;
+ document.querySelector("#mark-your-work .html.mark").innerHTML = htmlMark;
}
-
-// function to replace placeholders with values
+// function to replace placeholders with values
// for mark format constriction
// lots of TODOs here (just for testing)
// can use this to build out string replacement when
// swapping in html from a element
// this will enable, controlling the markup, in markup
// and then JS is only having to do logic replacement
-// of the token placeholders, rather than storing strings
+// of the token placeholders, rather than storing strings
// within the JS unnecessarily.
-
// function parseTokens(name, value, str){
// return str.replaceAll("{{"+name+"}}", value);
// }
-
+
// const mark = 'test {{title}} {{year}} by {{author}}';
// parsedMark = parseTokens("year", "2025", mark);
@@ -396,226 +457,205 @@ function renderMarkingFormats(state) {
// parsedMark = parseTokens("author", "jane mayer", parsedMark);
// console.log(parsedMark);
-
-
// function to render "empty area"
// if no valid tool from state.parts and/or state/current
-function renderEmptyPlaceholder(state) {
-
- if (state.props.tool == 'unknown' ) {
- document.querySelector('#empty').classList.remove('disable');
- }
-
- else if (state.props.tool != 'unknown') {
- document.querySelector('#empty').classList.add('disable');
- }
-
+function renderEmptyPlaceholder(state) {
+ if (state.props.tool == "unknown") {
+ document.querySelector("#empty").classList.remove("disable");
+ } else if (state.props.tool != "unknown") {
+ document.querySelector("#empty").classList.add("disable");
+ }
}
// function to render "mark your work",
// if valid tool from state.parts and/or state.current
// if attribution details input(s) filled out
function renderMarkYourWork(state) {
- if (state.props.tool != 'unknown' ) {
- // load attribution details template,
- // populate from attribution text values
- document.querySelector('#mark-your-work').classList.remove('disable');
-
- renderMarkingFormats(state);
-
- }
-
- else if (state.props.tool == 'unknown') {
- document.querySelector('#mark-your-work').classList.add('disable');
- }
-
+ if (state.props.tool != "unknown") {
+ // load attribution details template,
+ // populate from attribution text values
+ document.querySelector("#mark-your-work").classList.remove("disable");
+
+ renderMarkingFormats(state);
+ } else if (state.props.tool == "unknown") {
+ document.querySelector("#mark-your-work").classList.add("disable");
+ }
}
// function to set default UX states on Steps
// set default visibly disabled pathways
function setDefaults(applyDefaults) {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.toggle("disable");
+ });
+ if (state.parts[0] == "do-you-know-which-license-you-need/yes/") {
applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.toggle('disable');
+ document.querySelector(element).classList.add("disable");
});
+ }
- if (state.parts[0] == 'do-you-know-which-license-you-need/yes/' ) {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.add('disable');
- });
- }
-
- document.querySelector('#tool-recommendation').classList.add('disable');
- document.querySelector('#mark-your-work').classList.add('disable');
- document.querySelector('#tool-rec-details').classList.add('hide');
+ document.querySelector("#tool-recommendation").classList.add("disable");
+ document.querySelector("#mark-your-work").classList.add("disable");
+ document.querySelector("#tool-rec-details").classList.add("hide");
}
-// stepper logic here for what parts of form are
-// displayed/hidden, as state.parts and state.current
+// stepper logic here for what parts of form are
+// displayed/hidden, as state.parts and state.current
// are updated
function renderSteps(applyDefaults, state) {
+ // check if visitor needs help, start help pathways
+ if (state.current == "do-you-know-which-license-you-need/no/") {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.remove("disable");
+ });
+ document
+ .querySelector("#which-license-do-you-need")
+ .classList.toggle("disable");
+ document.querySelector("#waive-your-copyright").classList.add("disable");
+ }
+
+ // if visitor doesn't need help
+ if (state.current == "do-you-know-which-license-you-need/yes/") {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.add("disable");
+ });
+ document
+ .querySelector("#which-license-do-you-need")
+ .classList.toggle("disable");
+ document.querySelector("#waive-your-copyright").classList.add("disable");
+ }
+
+ // check if cc0
+ if (
+ state.parts[2] == "require-attribution/no/" ||
+ state.parts[1] == "which-license-do-you-need/cc-0/"
+ ) {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.add("disable");
+ });
- // check if visitor needs help, start help pathways
- if (state.current == 'do-you-know-which-license-you-need/no/' ) {
-
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.remove('disable');
- });
- document.querySelector('#which-license-do-you-need').classList.toggle('disable');
- document.querySelector('#waive-your-copyright').classList.add('disable');
-
- }
-
- // if visitor doesn't need help
- if (state.current == 'do-you-know-which-license-you-need/yes/' ) {
-
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.add('disable');
- });
- document.querySelector('#which-license-do-you-need').classList.toggle('disable');
- document.querySelector('#waive-your-copyright').classList.add('disable');
-
- }
-
- // check if cc0
- if (state.parts[2] == 'require-attribution/no/' || state.parts[1] == 'which-license-do-you-need/cc-0/' ) {
-
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.add('disable');
- });
-
- document.querySelector('#waive-your-copyright').classList.remove('disable');
-
- } else {
- document.querySelector('#waive-your-copyright').classList.add('disable');
- }
- if (state.parts[2] == 'require-attribution/no/') {
- document.querySelector('#require-attribution').classList.remove('disable');
- }
-
- // walk away from cc-0, reset attribution choice point
- if (state.parts[2] == 'require-attribution/yes/') {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.remove('disable');
- });
- document.querySelector('#require-attribution').classList.remove('disable');
- document.querySelector('#waive-your-copyright').classList.add('disable');
- }
-
- // tie SA to ND choice
- if (state.parts[4] == 'allow-derivatives/no/') {
- document.querySelector('#share-alike').classList.add('disable');
- }
-
+ document
+ .querySelector("#waive-your-copyright")
+ .classList.remove("disable");
+ } else {
+ document.querySelector("#waive-your-copyright").classList.add("disable");
+ }
+ if (state.parts[2] == "require-attribution/no/") {
+ document.querySelector("#require-attribution").classList.remove("disable");
+ }
+
+ // walk away from cc-0, reset attribution choice point
+ if (state.parts[2] == "require-attribution/yes/") {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.remove("disable");
+ });
+ document.querySelector("#require-attribution").classList.remove("disable");
+ document.querySelector("#waive-your-copyright").classList.add("disable");
+ }
+
+ // tie SA to ND choice
+ if (state.parts[4] == "allow-derivatives/no/") {
+ document.querySelector("#share-alike").classList.add("disable");
+ }
}
// [T]: function to handle error state
-// function to watch for fieldset changes
+// function to watch for fieldset changes
function watchFieldsets(fieldsets, state) {
- fieldsets.forEach((element, index) => {
-
- // [T]: set defaults here first in state.parts dynamically
-
- element.addEventListener("change", (event) => {
-
- updateStateParts(element, index, event, state);
-
- setStateCurrent(element, index, state);
+ fieldsets.forEach((element, index) => {
+ // [T]: set defaults here first in state.parts dynamically
- setStateProps(index, state);
+ element.addEventListener("change", (event) => {
+ updateStateParts(element, index, event, state);
- // [T]: also reset values beyond current changed fieldset to nothing each time
- clearStepsAfterCursor(fieldsets, state);
+ setStateCurrent(element, index, state);
- renderSteps(applyDefaults, state);
+ setStateProps(index, state);
- renderEmptyPlaceholder(state);
+ // [T]: also reset values beyond current changed fieldset to nothing each time
+ clearStepsAfterCursor(fieldsets, state);
- renderToolRec(state);
+ renderSteps(applyDefaults, state);
- renderMarkYourWork(state);
+ renderEmptyPlaceholder(state);
- });
+ renderToolRec(state);
+ renderMarkYourWork(state);
});
+ });
}
function watchAttributionDetails(fieldsets, state) {
+ let textFields = fieldsets[8].querySelectorAll("input");
- let textFields = fieldsets[8].querySelectorAll('input');
-
- textFields.forEach((element, index) => {
-
- element.addEventListener("keyup", (event) => {
- renderMarkingFormats(state);
- });
-
+ textFields.forEach((element, index) => {
+ element.addEventListener("keyup", (event) => {
+ renderMarkingFormats(state);
});
+ });
}
function watchMarkToggles(toggles, state) {
-
- toggles.forEach((element, index) => {
-
- element.addEventListener("click", (event) => {
- renderMarkingFormats(state);
- });
-
+ toggles.forEach((element, index) => {
+ element.addEventListener("click", (event) => {
+ renderMarkingFormats(state);
});
+ });
}
function watchMarkCopiers(copiers, state) {
-
- function copyToClipboard (text) {
- let temp = document.createElement("textarea");
- document.body.appendChild(temp);
- temp.value = text;
- temp.select();
- document.execCommand("copy");
- document.body.removeChild(temp);
- }
-
- copiers.forEach((element, index) => {
-
- element.addEventListener("click", (event) => {
-
- if (element.parentNode.parentNode.querySelector('.mark').value != null) {
- copyToClipboard(element.parentNode.parentNode.querySelector('.mark').value);
- } else {
- copyToClipboard(element.parentNode.parentNode.querySelector('.mark').innerHTML);
- }
- });
-
+ function copyToClipboard(text) {
+ let temp = document.createElement("textarea");
+ document.body.appendChild(temp);
+ temp.value = text;
+ temp.select();
+ document.execCommand("copy");
+ document.body.removeChild(temp);
+ }
+
+ copiers.forEach((element, index) => {
+ element.addEventListener("click", (event) => {
+ if (element.parentNode.parentNode.querySelector(".mark").value != null) {
+ copyToClipboard(
+ element.parentNode.parentNode.querySelector(".mark").value,
+ );
+ } else {
+ copyToClipboard(
+ element.parentNode.parentNode.querySelector(".mark").innerHTML,
+ );
+ }
});
+ });
}
document.addEventListener("DOMContentLoaded", (event) => {
- // full flow logic
- setStateParts(state);
+ // full flow logic
+ setStateParts(state);
- setStatePossibilities(state);
+ setStatePossibilities(state);
- setDefaults(applyDefaults);
+ setDefaults(applyDefaults);
- setStateProps(0, state);
+ setStateProps(0, state);
- watchFieldsets(fieldsets, state);
- watchAttributionDetails(fieldsets, state);
- watchMarkToggles(toggles, state);
- watchMarkCopiers(copiers, state);
+ watchFieldsets(fieldsets, state);
+ watchAttributionDetails(fieldsets, state);
+ watchMarkToggles(toggles, state);
+ watchMarkCopiers(copiers, state);
});
// rough panel expansion test
// let expandButtons = document.querySelectorAll('button.expandPanel');
-// expandButtons.forEach((element, index) => {
+// expandButtons.forEach((element, index) => {
// element.addEventListener("click", (event) => {
// parent = event.target.parentNode.parentNode;
// parent.querySelector('.panel').classList.toggle('expand');
-
+
// });
// });
-
diff --git a/src/style.css b/src/style.css
index 0ece9d72..8b69d612 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1,369 +1,368 @@
-@import 'vocabulary/css/vocabulary.css' layer(vocabulary);
+@import "vocabulary/css/vocabulary.css" layer(vocabulary);
:root {
-
- /* localized cc sprite names */
- --cc-by: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-by');
- --cc-nc: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-nc');
- --cc-nd: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-nd');
- --cc-pd: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-pd');
- --cc-pdm: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-pdm');
- --cc-sa: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-sa');
- --cc-zero: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-zero');
+ /* localized cc sprite names */
+ --cc-by: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-by");
+ --cc-nc: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-nc");
+ --cc-nd: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-nd");
+ --cc-pd: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-pd");
+ --cc-pdm: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-pdm");
+ --cc-sa: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-sa");
+ --cc-zero: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-zero");
}
.chooser-page .icon-attach.cc-by:before {
- --icon-sprite: var(--cc-by);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-by);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page .icon-attach.cc-nc:before {
- --icon-sprite: var(--cc-nc);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-nc);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page .icon-attach.cc-nd:before {
- --icon-sprite: var(--cc-nd);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-nd);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page .icon-attach.cc-pd:before {
- --icon-sprite: var(--cc-pd);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-pd);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page .icon-attach.cc-pdm:before {
- --icon-sprite: var(--cc-pdm);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-pdm);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page .icon-attach.cc-sa:before {
- --icon-sprite: var(--cc-sa);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-sa);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page .icon-attach.cc-zero:before {
- --icon-sprite: var(--cc-zero);
- margin-right: .2em;
- margin-bottom: -.125em;
+ --icon-sprite: var(--cc-zero);
+ margin-right: 0.2em;
+ margin-bottom: -0.125em;
}
.chooser-page dl div {
- margin-bottom: .8em;
+ margin-bottom: 0.8em;
}
-.chooser-page dt, .chooser-page dd {
- display: inline-block;
+.chooser-page dt,
+.chooser-page dd {
+ display: inline-block;
}
.chooser-page dt:after {
- content: ':';
+ content: ":";
}
.chooser-page dd {
- margin-left: .2em;
+ margin-left: 0.2em;
}
.chooser-page dd span {
- display: block;
+ display: block;
}
.chooser-page ol li:has(.disable) {
- display: none;
+ display: none;
}
.chooser-page .disable {
- display: none;
+ display: none;
}
.chooser-page .hide {
- display: none;
+ display: none;
}
.chooser-page .tool header {
- display: flex;
- flex-wrap: wrap;
+ display: flex;
+ flex-wrap: wrap;
}
.chooser-page .tool header > h4 {
- width: 100%;
+ width: 100%;
}
.chooser-page .tool header > .tool-icons {
- order: -1;
- margin: 0 1em 0 0;
+ order: -1;
+ margin: 0 1em 0 0;
}
.chooser-page .tool .tool-icons svg {
- display: inline;
- width: 1.9em;
- height: 1.9em;
- margin-right: .3em;
+ display: inline;
+ width: 1.9em;
+ height: 1.9em;
+ margin-right: 0.3em;
}
.chooser-page .content {
- display: grid;
- gap: 2em;
- grid-template-columns: 1fr 2fr;
+ display: grid;
+ gap: 2em;
+ grid-template-columns: 1fr 2fr;
}
.chooser-page .mark svg {
- display: inline;
- width: 1.3em;
- height: 1.3em;
+ display: inline;
+ width: 1.3em;
+ height: 1.3em;
}
.chooser-page .mark svg:first-of-type {
- margin-left: .5em;
+ margin-left: 0.5em;
}
.chooser-page .tool-rec-details input {
- color: lightgray;
+ color: lightgray;
}
.chooser-page form#chooser > ol {
- position: relative;
+ position: relative;
- list-style: none;
- counter-reset: chooser-counter;
+ list-style: none;
+ counter-reset: chooser-counter;
}
.chooser-page form#chooser > ol li {
- counter-increment: chooser-counter;
+ counter-increment: chooser-counter;
}
.chooser-page form#chooser > ol li::before {
- position: absolute;
- --size: 32px;
- left: calc(-1 * var(--size) - 25px);
- min-height: 2em;
- min-width: 2em;
- padding-top: .4em;
- box-sizing: border-box;
-
- content: counter(chooser-counter);
- font-weight: bold;
- border-radius: 200px;
- background: var(--vocabulary-neutral-color-lighter-gray);
- color: black;
- text-align: center;
- vertical-align: middle;
+ position: absolute;
+ --size: 32px;
+ left: calc(-1 * var(--size) - 25px);
+ min-height: 2em;
+ min-width: 2em;
+ padding-top: 0.4em;
+ box-sizing: border-box;
+
+ content: counter(chooser-counter);
+ font-weight: bold;
+ border-radius: 200px;
+ background: var(--vocabulary-neutral-color-lighter-gray);
+ color: black;
+ text-align: center;
+ vertical-align: middle;
}
.chooser-page form#chooser legend {
- font-weight: bold;
+ font-weight: bold;
}
.chooser-page form#chooser fieldset {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
.chooser-page form#chooser label {
- font-size: .7em;
- font-weight: 400;
+ font-size: 0.7em;
+ font-weight: 400;
}
.chooser-page form#chooser #attribution-details span {
- display: inline-block;
- padding: .7em 0;
+ display: inline-block;
+ padding: 0.7em 0;
- font-size: .8em;
- line-height: 1.3;
+ font-size: 0.8em;
+ line-height: 1.3;
}
.chooser-page form#chooser #attribution-details div {
- margin-bottom: .5em;
-}
+ margin-bottom: 0.5em;
+}
.chooser-page form#chooser #waive-your-copyright div {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
.chooser-page form#chooser #attribution-details input {
- padding: .2em .2em;
+ padding: 0.2em 0.2em;
- font-size: 1em;
+ font-size: 1em;
}
.chooser-page form#chooser #atrribution-details input::placeholder {
- opacity: .5;
+ opacity: 0.5;
}
.chooser-page aside #empty {
- min-height: 10em;
- padding: 2em;
+ min-height: 10em;
+ padding: 2em;
- background: var(--vocabulary-brand-color-soft-turquoise);
- background: var(--vocabulary-neutral-color-lighter-gray);
+ background: var(--vocabulary-brand-color-soft-turquoise);
+ background: var(--vocabulary-neutral-color-lighter-gray);
}
.chooser-page aside #empty p {
- font-size: 1.2em;
+ font-size: 1.2em;
}
.chooser-page #tool-recommendation {
- margin-bottom: 4em;
+ margin-bottom: 4em;
- font-family: 'Source Sans Pro';
+ font-family: "Source Sans Pro";
}
.chooser-page #tool-recommendation .tool {
- padding: 2em;
+ padding: 2em;
- background: var(--vocabulary-brand-color-soft-turquoise);
+ background: var(--vocabulary-brand-color-soft-turquoise);
}
.chooser-page #tool-recommendation .tool a {
- --underline-background-color: var(--vocabulary-brand-color-soft-turquoise);
+ --underline-background-color: var(--vocabulary-brand-color-soft-turquoise);
}
.chooser-page #tool-recommendation h3 {
- margin: 0;
+ margin: 0;
- font-family: 'Source Sans Pro';
- font-size: 1.4em;
+ font-family: "Source Sans Pro";
+ font-size: 1.4em;
}
.chooser-page #tool-recommendation h4 {
- margin: .2em;
+ margin: 0.2em;
- font-family: 'Source Sans Pro';
- font-size: 1.4em;
+ font-family: "Source Sans Pro";
+ font-size: 1.4em;
}
.chooser-page #tool-recommendation p {
- font-size: 1.2em;
+ font-size: 1.2em;
}
.chooser-page #tool-recommendation a {
- font-weight: 700;
+ font-weight: 700;
}
.chooser-page #tool-recommendation .conditions-definitions {
- margin-bottom: 2em;
+ margin-bottom: 2em;
- font-family: 'Source Sans Pro';
+ font-family: "Source Sans Pro";
}
.chooser-page #tool-recommendation .conditions-definitions dt {
- font-weight: 700;
+ font-weight: 700;
}
.chooser-page #mark-your-work textarea {
- min-height: 9em;
- width: 90%;
- margin: 1em;
- box-sizing: border-box;
+ min-height: 9em;
+ width: 90%;
+ margin: 1em;
+ box-sizing: border-box;
}
.chooser-page #mark-your-work p {
- font-size: 1.2em;
+ font-size: 1.2em;
}
-.chooser-page details {
- font-family: 'Source Sans Pro';
+.chooser-page details {
+ font-family: "Source Sans Pro";
- border: 2px solid var(--vocabulary-neutral-color-lighter-gray);
- border-radius: 5px;
+ border: 2px solid var(--vocabulary-neutral-color-lighter-gray);
+ border-radius: 5px;
}
.chooser-page details details {
- margin: 1em;
+ margin: 1em;
}
.chooser-page details.medium {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
-
+
.chooser-page details summary {
- padding: .2em .5em;
+ padding: 0.2em 0.5em;
- background: var(--vocabulary-neutral-color-lighter-gray);
- font-size: 1.6em;
+ background: var(--vocabulary-neutral-color-lighter-gray);
+ font-size: 1.6em;
}
.chooser-page details.format summary {
- font-size: 1.3em;
+ font-size: 1.3em;
}
.chooser-page summary:hover {
- cursor: pointer;
+ cursor: pointer;
}
-
+
.chooser-page summary::marker {
- font-size: .8em;
+ font-size: 0.8em;
}
.chooser-page details p {
- padding: 0 1em;
+ padding: 0 1em;
- font-size: 1em;
+ font-size: 1em;
}
.chooser-page details.format footer {
- display: flex;
- justify-content: space-between;
- padding: 1em;
+ display: flex;
+ justify-content: space-between;
+ padding: 1em;
}
.chooser-page details.format footer label {
- margin-left: .2em;
+ margin-left: 0.2em;
}
.chooser-page details.format footer button {
- padding: .5em 1em;
+ padding: 0.5em 1em;
- background: #324C7F;
- color: white;
- border-radius: 3px;
- border: none;
+ background: #324c7f;
+ color: white;
+ border-radius: 3px;
+ border: none;
}
.chooser-page details.format footer button:hover {
- cursor: pointer;
+ cursor: pointer;
}
.chooser-page .content {
- grid-column: 3 / 10;
+ grid-column: 3 / 10;
}
.chooser-page #help {
- margin-top: 4em;
- }
-
- .chooser-page #help details {
- margin-bottom: 1em;
- }
+ margin-top: 4em;
+}
- .chooser-page #help ul {
- font-size: 1em;
- padding: 0 1em;
- }
+.chooser-page #help details {
+ margin-bottom: 1em;
+}
- .chooser-page #help ul li {
- padding-bottom: .5em;
- }
+.chooser-page #help ul {
+ font-size: 1em;
+ padding: 0 1em;
+}
- .chooser-page #help dl {
- padding: 0 1em;
- }
+.chooser-page #help ul li {
+ padding-bottom: 0.5em;
+}
+.chooser-page #help dl {
+ padding: 0 1em;
+}
@media (max-width: 705px) {
- .chooser-page .content {
- display: block;
- }
+ .chooser-page .content {
+ display: block;
+ }
}
.chooser-page .panel {
- display: none;
+ display: none;
}
.chooser-page .panel.expand {
- display: initial;
+ display: initial;
}
From 860cc9179eaba40d073e363bd6231ed717b5d5c9 Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Tue, 24 Jun 2025 10:05:55 +0100
Subject: [PATCH 5/8] Add a file link and format keys Also re-add repo links
---
README.md | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 1be45e92..2c5709d7 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,13 @@ Once changes are implemented here, they need to be updated within the `/chooser`
Final production changes are deployed within vocabulary-theme Releases, updated within [`index-dev-env`][index-dev-env], and finally deployed to `index__stage` and then `index__prod` environments; going LIVE at `https://creativecommons.org/chooser`.
+[cc-legal-tools-app]: https://github.com/creativecommons/cc-legal-tools-app
+[cc-legal-tools-data]: https://github.com/creativecommons/cc-legal-tools-data
+[index-dev-env]: https://github.com/creativecommons/index-dev-env
+[index-prototype]: https://github.com/creativecommons/index-prototype
+[vocabulary]: https://github.com/creativecommons/vocabulary
+[vocabulary-theme]: https://github.com/creativecommons/vocabulary-theme
+
### Setting up the Project
@@ -71,7 +78,7 @@ Use the following instructions to start the Project with docker compose.
docker compose up
```
-3. After running the above command, Docker will use the `docker-compose.yml` file and Build a local environment for you
+3. After running the above command, Docker will use the [`docker-compose.yml`](docker-compose.yml) file and build a local environment for you
4. Navigate to http://localhost:8080 in your browser and the app would be running.
5. **stop the containers**
@@ -84,7 +91,7 @@ Use the following instructions to start the Project with docker compose.
or
You can simply revisit the existing terminal which is running the container
- and type `CTRL + C`
+ and type CTRL + C
### Format with Prettier
From e057ccee46e04efafed75f6d3d0264c2bc03315a Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Thu, 7 Aug 2025 14:48:43 +0100
Subject: [PATCH 6/8] Remove web server aspects of docker configuration
---
config/site.conf | 38 --------------------------------------
dev/web/Dockerfile | 19 -------------------
docker-compose.yml | 19 -------------------
3 files changed, 76 deletions(-)
delete mode 100644 config/site.conf
delete mode 100644 dev/web/Dockerfile
diff --git a/config/site.conf b/config/site.conf
deleted file mode 100644
index e468ef07..00000000
--- a/config/site.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-
- RewriteEngine On
-
- # Set conservative/secure defaults
-
- AllowOverride None
- DirectoryIndex index.html
- Options -Indexes
-
- # Git
-
- Require all denied
-
- # Subversion
-
- Require all denied
-
- # Deny access to accidental uploads of macOS-specific directories and files
- # .DS_Store
-
- Require all denied
-
- # resource forks
-
- Require all denied
-
-
- DocumentRoot /usr/local/apache2/htdocs
-
- # Also serve HTML files without .html extension
- RewriteCond %{REQUEST_FILENAME}.html -f
- RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
-
-
- ErrorDocument 404 /404.html
-
-
-# vim: ft=apache ts=4 sw=4 sts=4 sr noet
diff --git a/dev/web/Dockerfile b/dev/web/Dockerfile
deleted file mode 100644
index 89c79dfb..00000000
--- a/dev/web/Dockerfile
+++ /dev/null
@@ -1,19 +0,0 @@
-# https://docs.docker.com/engine/reference/builder/
-
-# https://hub.docker.com/_/httpd
-FROM httpd:2.4
-
-# Update Apache2 configuration
-
-# Set ServerName to prevent warning
-RUN sed -e's/^#ServerName.*/ServerName static/' -i'' \
- /usr/local/apache2/conf/httpd.conf
-
-# Enable mod_rewrite
-# https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
-RUN sed -e's/^#LoadModule rewrite/LoadModule rewrite/' -i'' \
- /usr/local/apache2/conf/httpd.conf
-
-# Include site configuration
-RUN echo 'Include conf/config/site.conf' \
- | tee -a /usr/local/apache2/conf/httpd.conf
diff --git a/docker-compose.yml b/docker-compose.yml
index 1dbfa392..33203a64 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,24 +1,5 @@
name: chooser
services:
- web:
- build:
- context: .
- dockerfile: dev/web/Dockerfile
- # Use Bash instad of sh (Dash) for improved signal handling
- command: /bin/bash -c "
- echo 'Starting static webserver at http://127.0.0.1:8080/';
- /usr/local/bin/httpd-foreground
- "
- container_name: cc-chooser-web
- ports:
- - "8080:80"
- restart: on-failure
- volumes:
- # Mount site configuration directory
- - "./config:/usr/local/apache2/conf/config:ro"
- # Mount website directory
- - "./src:/usr/local/apache2/htdocs:ro"
-
node:
build:
context: .
From f68b69b20894f7ada690048d92df5215fbd750e2 Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Thu, 7 Aug 2025 14:49:32 +0100
Subject: [PATCH 7/8] Update README for prettier/docker usage
---
README.md | 34 ++++++++--------------------------
1 file changed, 8 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index 2c5709d7..1fce4080 100644
--- a/README.md
+++ b/README.md
@@ -67,39 +67,21 @@ For information on learning and installing the prerequisite technologies for thi
[found-tech]: https://opensource.creativecommons.org/contributing-code/foundational-tech/
-### Docker Compose Setup
-
-Use the following instructions to start the Project with docker compose.
-
-1. Navigate to the creativecommons/chooser Project that you have cloned
-2. **Run the containers**
-
- ```shell
- docker compose up
- ```
-
-3. After running the above command, Docker will use the [`docker-compose.yml`](docker-compose.yml) file and build a local environment for you
-4. Navigate to http://localhost:8080 in your browser and the app would be running.
-5. **stop the containers**
-
- To stop the app from running, simply open an another instance of terminal and type:
-
- ```shell
- docker compose down
- ```
-
- or
-
- You can simply revisit the existing terminal which is running the container
- and type CTRL + C
-
+1. open the `src/index.html` file within a browser to view the Chooser.
### Format with Prettier
Run the following command to format files with Prettier:
```shell
+docker compose run node prettier --write src/
+```
+
+```shell
+## Or alternatively, if docker compose run is slow to run
+docker compose up --detach
docker compose exec node prettier --write src/
+docker compose down
```
## Structure
From af9ac2dd92659192cdede12374ec2315e054cf0e Mon Sep 17 00:00:00 2001
From: Ieuan Jenkins
Date: Fri, 8 Aug 2025 12:49:53 +0100
Subject: [PATCH 8/8] Revert "Format with prettier"
This reverts commit dd86dab3174bf89c04bcf2bbcd6395145eb6bc93.
---
src/index.html | 1674 ++++++++++++++++++------------------------------
src/scripts.js | 954 +++++++++++++--------------
src/style.css | 327 +++++-----
3 files changed, 1233 insertions(+), 1722 deletions(-)
diff --git a/src/index.html b/src/index.html
index eae9478c..3ca47d84 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,172 +1,122 @@
-
+
-
- Chooser
-
-
-
-
-
-
-
-
-
-
-
-
- Skip to content
+
+Chooser
-
+
-
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
+
CC0 1.0
-
-
-
-
-
-
+
+
+
+
+
+
CC0 1.0 Universal
-
-
-
-
- By marking the work with a CC0 public domain dedication, the creator
- is giving up their copyright and allowing reusers to distribute,
- remix, adapt, and build upon the material in any medium or format,
- even for commercial purposes.
-
-
-
-
+
+
+
+
By marking the work with a CC0 public domain dedication, the creator is giving up their copyright and allowing reusers to distribute, remix, adapt, and build upon the material in any medium or format, even for commercial purposes.
+
+
+
-
CC0
- This work has been marked as dedicated to the public domain.
+ CC0
+ This work has been marked as dedicated to the public domain.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC-BY 4.0
-
-
-
-
-
-
+
+
+
+
+
+
Creative Commons Attribution 4.0 International
-
+
-
-
- This license requires that reusers give credit to the creator. It
- allows reusers to distribute, remix, adapt, and build upon the
- material in any medium or format, even for commercial purposes.
-
-
+
+
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, even for commercial purposes.
+
-
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-SA 4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Creative Commons Attribution-ShareAlike 4.0 International
-
-
-
-
- This license requires that reusers give credit to the creator. It
- allows reusers to distribute, remix, adapt, and build upon the
- material in any medium or format, even for commercial purposes. If
- others remix, adapt, or build upon the material, they must license
- the modified material under identical terms.
-
-
-
-
+
+
+
+
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, even for commercial purposes. If others remix, adapt, or build upon the material, they must license the modified material under identical terms.
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
SA
- Adaptations must be shared under the same terms.
+ SA
+ Adaptations must be shared under the same terms.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-ND 4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Creative Commons Attribution-NoDerivatives 4.0 International
-
+
+
+
+
This license requires that reusers give credit to the creator. It allows reusers to copy and distribute the material in any medium or format in unadapted form only, even for commercial purposes.
+
-
-
- This license requires that reusers give credit to the creator. It
- allows reusers to copy and distribute the material in any medium or
- format in unadapted form only, even for commercial purposes.
-
-
+
-
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
ND
- No derivatives or adaptations of your work are permitted.
+ ND
+ No derivatives or adaptations of your work are permitted.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-NC 4.0
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Creative Commons Attribution-NonCommercial 4.0 International
-
+
-
-
- This license requires that reusers give credit to the creator. It
- allows reusers to distribute, remix, adapt, and build upon the
- material in any medium or format, for noncommercial purposes only.
-
-
+
+
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only.
+
-
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
NC
-
- Only noncommercial use of your work is permitted.
- Noncommercial means not primarily intended for or directed
- towards commercial advantage or monetary compensation.
-
+ NC
+
+ Only noncommercial use of your work is permitted.
+ Noncommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
+
-
- See the License Deed
-
-
-
+
+
+
CC BY-NC-SA 4.0
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
- Creative Commons Attribution-NonCommercial-ShareAlike 4.0
- International
-
-
-
-
-
- This license requires that reusers give credit to the creator. It
- allows reusers to distribute, remix, adapt, and build upon the
- material in any medium or format, for noncommercial purposes only. If
- others modify or adapt the material, they must license the modified
- material under identical terms.
-
-
-
-
+ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
+
+
+
+
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. If others modify or adapt the material, they must license the modified material under identical terms.
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
NC
-
- Only noncommercial use of your work is permitted.
- Noncommercial means not primarily intended for or directed
- towards commercial advantage or monetary compensation.
-
+ NC
+
+ Only noncommercial use of your work is permitted.
+ Noncommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
+
-
SA
- Adaptations must be shared under the same terms.
+ SA
+ Adaptations must be shared under the same terms.
-
+
- See the License Deed
-
+ See the License Deed
+
-
-
+
+
CC BY-NC-ND 4.0
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
- Creative Commons Attribution-NonCommercial-NoDerivatives 4.0
- International
-
-
-
-
-
- This license requires that reusers give credit to the creator. It
- allows reusers to copy and distribute the material in any medium or
- format in unadapted form and for noncommercial purposes only.
-
-
-
-
+ Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
+
+
+
+
This license requires that reusers give credit to the creator. It allows reusers to copy and distribute the material in any medium or format in unadapted form and for noncommercial purposes only.
+
+
+
-
BY
- Credit must be given to you, the creator.
+ BY
+ Credit must be given to you, the creator.
-
NC
-
- Only noncommercial use of your work is permitted.
- Noncommercial means not primarily intended for or directed
- towards commercial advantage or monetary compensation.
-
+ NC
+
+ Only noncommercial use of your work is permitted.
+ Noncommercial means not primarily intended for or directed towards commercial advantage or monetary compensation.
+
-
ND
- No derivatives or adaptations of your work are permitted.
+ ND
+ No derivatives or adaptations of your work are permitted.
-
-
- See the License Deed
-
-
-
-
- {{title}} {{copyright}} by {{creator}} is {{typeAsVerb}} {{toolName}}.
- To view a copy of this {{type}}, visit {{toolURL}}
-
-
-
+
+
+ See the License Deed
+
+
+
+ {{title}} {{copyright}} by {{creator}} is {{typeAsVerb}} {{toolName}}. To view a copy of this {{type}}, visit {{toolURL}}
+
+
+
diff --git a/src/scripts.js b/src/scripts.js
index 8cea38ad..6675d72a 100644
--- a/src/scripts.js
+++ b/src/scripts.js
@@ -1,33 +1,34 @@
+
// all possible State Path Routes
let rawStatePathRoutes = [
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0",
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/(attribution-details)&tool=cc-by",
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/(attribution-details)&tool=cc-by-sa",
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/(attribution-details)&tool=cc-by-nd",
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/(attribution-details)&tool=cc-by-nc",
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/(attribution-details)&tool=cc-by-nc-sa",
- "do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/(attribution-details)&tool=cc-by-nc-nd",
-
- "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by",
- "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-sa",
- "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nd",
- "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc",
- "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-sa",
- "do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-nd",
- "do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0",
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0',
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/(attribution-details)&tool=cc-by',
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/(attribution-details)&tool=cc-by-sa',
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/(attribution-details)&tool=cc-by-nd',
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/(attribution-details)&tool=cc-by-nc',
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/(attribution-details)&tool=cc-by-nc-sa',
+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/(attribution-details)&tool=cc-by-nc-nd',
+
+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by',
+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-sa',
+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nd',
+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc',
+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-sa',
+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-nd',
+ 'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0'
];
// empty state obj
let state = {};
// all found fieldsets
-const fieldsets = document.querySelectorAll("fieldset");
+const fieldsets = document.querySelectorAll('fieldset');
// all found toggles
-const toggles = document.querySelectorAll("#mark-your-work footer input");
+const toggles = document.querySelectorAll('#mark-your-work footer input');
// all found copiers
-const copiers = document.querySelectorAll("#mark-your-work footer button");
+const copiers = document.querySelectorAll('#mark-your-work footer button');
// empty defaults obj
let applyDefaults = {};
@@ -35,421 +36,359 @@ let applyDefaults = {};
// set elemnts which need defaults
// on initial page load
applyDefaults.elements = [
- "#require-attribution",
- "#allow-commercial-use",
- "#allow-derivatives",
- "#share-alike",
- "#waive-your-copyright",
- "#confirmation",
+ '#require-attribution',
+ '#allow-commercial-use',
+ '#allow-derivatives',
+ '#share-alike',
+ '#waive-your-copyright',
+ '#confirmation'
];
// function to parse and build state.possibilities
// from rawStatePathRoutes
function setStatePossibilities(state) {
- // create state possibilities from possible tools with adjoining statePaths
- state.possibilities = [];
- rawStatePathRoutes.forEach((path, index) => {
- statePath = path.split("&");
- statepath = statePath;
- tool = statePath[statePath.length - 1].split("=");
- tool = tool[1];
-
- regEx = /\(([^)]+)\)/g;
- optionals = statePath[0].match(regEx);
-
- optionals.forEach((optional) => {
- noOptionalsPath = statePath[0].replace(optional, "");
- });
- fullPath = statePath[0].replace(/[{()}]/g, "") + "/";
+ // create state possibilities from possible tools with adjoining statePaths
+ state.possibilities = [];
+ rawStatePathRoutes.forEach((path, index) => {
- if (state.possibilities[tool] == undefined) {
- state.possibilities[tool] = [];
- }
- state.possibilities[tool].push(fullPath);
- state.possibilities[tool].push(noOptionalsPath);
- });
+ statePath = path.split("&");
+ statepath = statePath;
+ tool = statePath[statePath.length - 1].split("=");
+ tool = tool[1];
+
+ regEx = /\(([^)]+)\)/g;
+ optionals = statePath[0].match(regEx);
+
+ optionals.forEach ((optional) => {
+
+ noOptionalsPath = statePath[0].replace(optional,'');
+
+ });
+
+ fullPath = statePath[0].replace(/[{()}]/g, '') + '/';
+
+ if (state.possibilities[tool] == undefined) {
+ state.possibilities[tool] = [];
+ }
+ state.possibilities[tool].push(fullPath);
+ state.possibilities[tool].push(noOptionalsPath);
+
+ });
}
// function to establish state.parts
function setStateParts(state) {
- state.parts = [];
+ state.parts = [];
- // temp defaults
- state.parts[0] = "do-you-know-which-license-you-need/yes/";
- state.parts[8] = "attribution-details/";
+ // temp defaults
+ state.parts[0] = 'do-you-know-which-license-you-need/yes/';
+ state.parts[8] = 'attribution-details/';
}
// function to update state.parts
function updateStateParts(element, index, event, state) {
- state.parts[index] = element.id + "/" + event.target.value + "/";
-
- // check if checkbox, with siblings
- if (event.target.getAttribute("type") == "checkbox") {
- let checkboxElements = element.querySelectorAll('input[type="checkbox"]');
- let checkboxes = [];
- checkboxElements.forEach((checkbox, index) => {
- if (checkbox.checked) {
- checkboxes[index] = checkbox.value;
- }
- });
- let joinedCheckboxes = checkboxes.filter(Boolean).join("+");
+ state.parts[index] = element.id + '/' + event.target.value + '/';
- state.parts[index] = element.id + "+" + joinedCheckboxes + "/";
- }
+ // check if checkbox, with siblings
+ if (event.target.getAttribute('type') == 'checkbox') {
+ let checkboxElements = element.querySelectorAll('input[type="checkbox"]');
+ let checkboxes = [];
+ checkboxElements.forEach((checkbox, index) => {
+ if (checkbox.checked) {
+ checkboxes[index] = checkbox.value;
+ }
+ });
- // check if text input
- if (event.target.getAttribute("type") == "text") {
- state.parts[index] = element.id + "/";
- }
-}
-// function to combine current tracked
-// state.parts into state.current
-function setStateCurrent(element, index, state) {
- state.parts.forEach((element, i) => {
- if (i > index) {
- state.parts.splice(i);
+ let joinedCheckboxes = checkboxes.filter(Boolean).join('+');
+
+ state.parts[index] = element.id + '+' + joinedCheckboxes + '/';;
}
- });
- state.current = state.parts.join(""); //.slice(0, -1);
+ // check if text input
+ if (event.target.getAttribute('type') == 'text') {
+
+ state.parts[index] = element.id + '/';
+
+ }
+}
+
+// function to combine current tracked
+// state.parts into state.current
+function setStateCurrent(element, index, state) {
+ state.parts.forEach((element, i) => {
+ if (i > index) {
+ state.parts.splice(i);
+ }
+ });
+
+ state.current = state.parts.join('') //.slice(0, -1);
}
// function to set state.props
// including setting state.props.tool (if valid)
// or error
function setStateProps(index, state) {
- state.props = {};
- state.props.tool = "unknown";
- // check and match possibilities
- Object.keys(state.possibilities).forEach((possibility) => {
- if (state.possibilities[possibility].includes(state.current)) {
- state.props.tool = possibility;
- }
- });
+ state.props = {};
+ state.props.tool = 'unknown';
- // set toolFull, toolShort, toolURL
- if (state.props.tool != "unknown" && state.props.tool != "cc-0") {
- // was OR, changes to AND
+ // check and match possibilities
+ Object.keys(state.possibilities).forEach((possibility) => {
+ if(state.possibilities[possibility].includes(state.current)) {
+ state.props.tool = possibility;
+ }
+ });
- formattedTool = state.props.tool.replace(/-/, " ").toUpperCase();
- state.props.toolShort = formattedTool + " 4.0";
+ // set toolFull, toolShort, toolURL
+ if (state.props.tool != 'unknown' && state.props.tool != 'cc-0' ) { // was OR, changes to AND
- // set shortName
- shortName = state.props.tool.replace(/cc-/, "");
- state.props.toolURL =
- "https://creativecommons.org/licenses/" + shortName + "/4.0/";
- }
+ formattedTool = state.props.tool.replace(/-/, ' ').toUpperCase();
+ state.props.toolShort = formattedTool + ' 4.0';
- if (state.props.tool != "unknown") {
- //set longName
- let tool = state.props.tool;
- let template = document.getElementById(tool);
- let templateContent = template.content.cloneNode(true);
- state.props.toolLong =
- templateContent.querySelector("header h4").textContent;
- }
+ // set shortName
+ shortName = state.props.tool.replace(/cc-/, '');
+ state.props.toolURL = 'https://creativecommons.org/licenses/'+ shortName +'/4.0/';
+ }
- if (state.props.tool == "cc-0") {
- state.props.toolShort = "CC0 1.0";
+ if (state.props.tool != 'unknown' ) {
+ //set longName
+ let tool = state.props.tool;
+ let template = document.getElementById(tool);
+ let templateContent = template.content.cloneNode(true);
+ state.props.toolLong = templateContent.querySelector('header h4').textContent;
+ }
- // set toolFull
- state.props.toolURL = "https://creativecommons.org/publicdomain/zero/1.0/";
- }
+ if (state.props.tool == 'cc-0') {
- state.props.cursor = index;
+ state.props.toolShort = 'CC0 1.0';
- state.props.attribution = [];
- setStatePropsAttribution(state);
+ // set toolFull
+ state.props.toolURL = 'https://creativecommons.org/publicdomain/zero/1.0/';
+ }
+
+ state.props.cursor = index;
+
+ state.props.attribution = [];
+ setStatePropsAttribution(state);
}
-// function to just set the attribution
+// function to just set the attribution
// subset of state.props (for use other places)
function setStatePropsAttribution(state) {
- if (document.querySelector("#attribution-details #title").value == "") {
- state.props.attribution.title = document
- .querySelector("#attribution-details #title")
- .placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.title = document
- .querySelector("#attribution-details #title")
- .value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (document.querySelector("#attribution-details #creator").value == "") {
- state.props.attribution.creator = document
- .querySelector("#attribution-details #creator")
- .placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.creator = document
- .querySelector("#attribution-details #creator")
- .value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (document.querySelector("#attribution-details #work-link").value == "") {
- state.props.attribution.workLink = document
- .querySelector("#attribution-details #work-link")
- .placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.workLink = document
- .querySelector("#attribution-details #work-link")
- .value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (
- document.querySelector("#attribution-details #creator-link").value == ""
- ) {
- state.props.attribution.creatorLink = document
- .querySelector("#attribution-details #creator-link")
- .placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.creatorLink = document
- .querySelector("#attribution-details #creator-link")
- .value.replace(/(<([^>]+)>)/gi, "");
- }
-
- if (
- document.querySelector("#attribution-details #work-creation-year").value ==
- ""
- ) {
- state.props.attribution.workCreationYear = document
- .querySelector("#attribution-details #work-creation-year")
- .placeholder.replace(/(<([^>]+)>)/gi, "");
- } else {
- state.props.attribution.workCreationYear = document
- .querySelector("#attribution-details #work-creation-year")
- .value.replace(/(<([^>]+)>)/gi, "");
- }
+
+ if (document.querySelector('#attribution-details #title').value == '') {
+ state.props.attribution.title = document.querySelector('#attribution-details #title').placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.title = document.querySelector('#attribution-details #title').value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (document.querySelector('#attribution-details #creator').value == '') {
+ state.props.attribution.creator = document.querySelector('#attribution-details #creator').placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.creator = document.querySelector('#attribution-details #creator').value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (document.querySelector('#attribution-details #work-link').value == '') {
+ state.props.attribution.workLink = document.querySelector('#attribution-details #work-link').placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.workLink = document.querySelector('#attribution-details #work-link').value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (document.querySelector('#attribution-details #creator-link').value == '') {
+ state.props.attribution.creatorLink = document.querySelector('#attribution-details #creator-link').placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.creatorLink = document.querySelector('#attribution-details #creator-link').value.replace(/(<([^>]+)>)/gi, "");
+ }
+
+ if (document.querySelector('#attribution-details #work-creation-year').value == '') {
+ state.props.attribution.workCreationYear = document.querySelector('#attribution-details #work-creation-year').placeholder.replace(/(<([^>]+)>)/gi, "");
+ } else {
+ state.props.attribution.workCreationYear = document.querySelector('#attribution-details #work-creation-year').value.replace(/(<([^>]+)>)/gi, "");
+ }
}
// function to reset values beyond current fieldset
// [T]: this could potentially do with a refactor
-// check for input type, and them perform
+// check for input type, and them perform
// contextual resets to universal defaults
-// unchecked for radio/checkbox, noselect for
+// unchecked for radio/checkbox, noselect for
// selection dropdown, etc.
function clearStepsAfterCursor(fieldsets, state) {
- fieldsets.forEach((element, index) => {
- if (index > state.props.cursor) {
- if (index == 1) {
- element.querySelector("#tool").value = "noselect";
- }
-
- if ((index != 1) | (index != 8)) {
- let inputs = element.querySelectorAll("input");
- inputs.forEach((input, i) => {
- input.checked = false;
- });
- }
- }
- });
+ fieldsets.forEach((element, index) => {
+ if (index > state.props.cursor) {
+
+ if (index == 1) {
+ element.querySelector("#tool").value = "noselect";
+ }
+
+ if (index != 1 | index != 8) {
+
+ let inputs = element.querySelectorAll('input');
+ inputs.forEach((input, i) => {
+ input.checked = false;
+ });
+ }
+ }
+ });
}
// function to render "tool recommendation",
// if valid tool from state.parts and/or state.current
function renderToolRec(state) {
- if (state.props.tool != "unknown") {
- document.querySelector("#tool-recommendation").classList.remove("disable");
- let tool = state.props.tool;
- let template = document.getElementById(tool);
- let templateContent = template.content.cloneNode(true);
- document.querySelector("#tool-recommendation .tool").textContent = "";
- document
- .querySelector("#tool-recommendation .tool")
- .appendChild(templateContent);
- } else if (state.props.tool == "unknown") {
- document.querySelector("#tool-recommendation").classList.add("disable");
- document.querySelector("#tool-recommendation .tool").textContent = "";
- }
+ if (state.props.tool != 'unknown' ) {
+ document.querySelector('#tool-recommendation').classList.remove('disable');
+
+ let tool = state.props.tool;
+ let template = document.getElementById(tool);
+ let templateContent = template.content.cloneNode(true);
+ document.querySelector('#tool-recommendation .tool').textContent = '';
+ document.querySelector('#tool-recommendation .tool').appendChild(templateContent);
+ }
+ else if (state.props.tool == 'unknown') {
+ document.querySelector('#tool-recommendation').classList.add('disable');
+ document.querySelector('#tool-recommendation .tool').textContent = '';
+ }
+
}
// render specifically the mark formats subsections
function renderMarkingFormats(state) {
- if (state.props.tool != "unknown") {
- }
-
- setStatePropsAttribution(state);
-
- let attribution = state.props.attribution;
-
- let type = "license";
- let typeAsVerb = "licensed under";
- let copyright = " © " + attribution.workCreationYear;
- if (state.props.tool == "cc-0") {
- type = "mark";
- typeAsVerb = "marked";
- copyright = "";
- }
-
- // set contents of plain text mark
- // [T]: reverse use of since it has limits on tokenization capacity, even if
- // it allows more dev readability.
- let template = document.getElementById("plain-text");
- let templateContent = template.content.cloneNode(true);
- document.querySelector("#mark-your-work .plain-text.mark").textContent = "";
-
- function parseTokens(name, value, str) {
- return str.replaceAll("{{" + name + "}}", value);
- }
-
- let markProps = {};
- markProps.title = attribution.title;
- markProps.year = attribution.workCreationYear;
- markProps.creator = attribution.creator;
- markProps.type = type;
- markProps.typeAsVerb = typeAsVerb;
- markProps.toolShort = state.props.toolShort;
- markProps.toolLong = state.props.toolLong;
- markProps.toolURL = state.props.toolURL;
- markProps.copyright = copyright;
-
- // set contents of plain text mark
- plainTextFullName = document.querySelector("#plain-text-full-name").checked;
-
- if (plainTextFullName == true) {
- markProps.toolName = state.props.toolLong;
- } else {
- markProps.toolName = state.props.toolShort;
- }
-
- // [T]: could carve out separate sections for different mark formats here
- // only handles plain text at the moment
- for (const [key, value] of Object.entries(markProps)) {
- templateContent.textContent = parseTokens(
- key,
- value,
- templateContent.textContent,
- );
- }
- document
- .querySelector("#mark-your-work .plain-text.mark")
- .appendChild(templateContent);
-
- // set contents of rich text mark
- let ccSVG =
- ' ';
- let bySVG =
- ' ';
- let saSVG =
- ' ';
- let ncSVG =
- ' ';
- let ndSVG =
- ' ';
- let zeroSVG =
- ' ';
-
- const currentTool = state.props.tool;
- switch (currentTool) {
- case "cc-0":
- ccIconSet = ccSVG + zeroSVG;
- break;
- case "cc-by":
- ccIconSet = ccSVG + bySVG;
- break;
- case "cc-by-sa":
- ccIconSet = ccSVG + bySVG + saSVG;
- break;
- case "cc-by-nd":
- ccIconSet = ccSVG + bySVG + ndSVG;
- break;
- case "cc-by-nc":
- ccIconSet = ccSVG + bySVG + ncSVG;
- break;
- case "cc-by-nc-sa":
- ccIconSet = ccSVG + bySVG + ncSVG + saSVG;
- break;
- case "cc-by-nc-nd":
- ccIconSet = ccSVG + bySVG + ncSVG + ndSVG;
- break;
- default:
- currentTool = "";
- }
-
- richTextFullName = document.querySelector("#rich-text-full-name").checked;
-
- if (richTextFullName == true) {
- markProps.toolName = state.props.toolLong;
- } else {
- markProps.toolName = state.props.toolShort;
- }
-
- let richTextMark =
- '' +
- attribution.title +
- " " +
- copyright +
- " by " +
- '' +
- attribution.creator +
- " " +
- " is " +
- typeAsVerb +
- " " +
- '' +
- markProps.toolName +
- " " +
- ccIconSet;
- document.querySelector("#mark-your-work .rich-text.mark").innerHTML =
- richTextMark;
-
- // set contents of HTML mark
- htmlFullName = document.querySelector("#html-full-name").checked;
-
- if (htmlFullName == true) {
- markProps.toolName = state.props.toolLong;
- } else {
- markProps.toolName = state.props.toolShort;
- }
- //defaultHTML = 'This work is licensed under CC BY-SA 4.0
';
- let htmlMark =
- '' +
- attribution.title +
- " " +
- copyright +
- " by " +
- '' +
- attribution.creator +
- " " +
- " is " +
- typeAsVerb +
- " " +
- '' +
- markProps.toolName +
- " " +
- ccIconSet;
- document.querySelector("#mark-your-work .html.mark").innerHTML = htmlMark;
+
+ if (state.props.tool != 'unknown' ) {}
+
+ setStatePropsAttribution(state);
+
+ let attribution = state.props.attribution;
+
+ let type = "license";
+ let typeAsVerb = "licensed under";
+ let copyright = ' © ' + attribution.workCreationYear;
+ if (state.props.tool == 'cc-0') {
+ type = "mark";
+ typeAsVerb = "marked";
+ copyright = '';
+ }
+
+ // set contents of plain text mark
+ // [T]: reverse use of since it has limits on tokenization capacity, even if
+ // it allows more dev readability.
+ let template = document.getElementById('plain-text');
+ let templateContent = template.content.cloneNode(true);
+ document.querySelector('#mark-your-work .plain-text.mark').textContent = '';
+
+ function parseTokens(name, value, str){
+ return str.replaceAll("{{"+name+"}}", value);
+ }
+
+ let markProps = {};
+ markProps.title = attribution.title;
+ markProps.year = attribution.workCreationYear;
+ markProps.creator = attribution.creator;
+ markProps.type = type;
+ markProps.typeAsVerb = typeAsVerb;
+ markProps.toolShort = state.props.toolShort;
+ markProps.toolLong = state.props.toolLong;
+ markProps.toolURL = state.props.toolURL;
+ markProps.copyright = copyright;
+
+ // set contents of plain text mark
+ plainTextFullName = document.querySelector('#plain-text-full-name').checked;
+
+ if (plainTextFullName == true) {
+ markProps.toolName = state.props.toolLong;
+
+ } else {
+ markProps.toolName = state.props.toolShort;
+ }
+
+ // [T]: could carve out separate sections for different mark formats here
+ // only handles plain text at the moment
+ for (const [key, value] of Object.entries(markProps)) {
+ templateContent.textContent = parseTokens(key, value, templateContent.textContent);
+ }
+ document.querySelector('#mark-your-work .plain-text.mark').appendChild(templateContent);
+
+ // set contents of rich text mark
+ let ccSVG = ' ';
+ let bySVG = ' ';
+ let saSVG = ' ';
+ let ncSVG = ' ';
+ let ndSVG = ' ';
+ let zeroSVG = ' ';
+
+ const currentTool = state.props.tool;
+ switch (currentTool) {
+ case 'cc-0':
+ ccIconSet = ccSVG + zeroSVG;
+ break;
+ case 'cc-by':
+ ccIconSet = ccSVG + bySVG;
+ break;
+ case 'cc-by-sa':
+ ccIconSet = ccSVG + bySVG + saSVG;
+ break;
+ case 'cc-by-nd':
+ ccIconSet = ccSVG + bySVG + ndSVG;
+ break;
+ case 'cc-by-nc':
+ ccIconSet = ccSVG + bySVG + ncSVG;
+ break;
+ case 'cc-by-nc-sa':
+ ccIconSet = ccSVG + bySVG + ncSVG + saSVG;
+ break;
+ case 'cc-by-nc-nd':
+ ccIconSet = ccSVG + bySVG + ncSVG + ndSVG;
+ break;
+ default:
+ currentTool = '';
+ }
+
+ richTextFullName = document.querySelector('#rich-text-full-name').checked;
+
+ if (richTextFullName == true) {
+ markProps.toolName = state.props.toolLong;
+
+ } else {
+ markProps.toolName = state.props.toolShort;
+ }
+
+ let richTextMark = '' + attribution.title + ' ' + copyright + ' by ' + '' + attribution.creator + ' ' + ' is ' + typeAsVerb + ' ' + '' + markProps.toolName + ' ' + ccIconSet;
+ document.querySelector('#mark-your-work .rich-text.mark').innerHTML = richTextMark;
+
+
+ // set contents of HTML mark
+ htmlFullName = document.querySelector('#html-full-name').checked;
+
+ if (htmlFullName == true) {
+ markProps.toolName = state.props.toolLong;
+
+ } else {
+ markProps.toolName = state.props.toolShort;
+ }
+ //defaultHTML = 'This work is licensed under CC BY-SA 4.0
';
+ let htmlMark = '' + attribution.title + ' ' + copyright + ' by ' + '' + attribution.creator + ' ' + ' is ' + typeAsVerb + ' ' + '' + markProps.toolName + ' ' + ccIconSet;
+ document.querySelector('#mark-your-work .html.mark').innerHTML = htmlMark;
}
-// function to replace placeholders with values
+
+// function to replace placeholders with values
// for mark format constriction
// lots of TODOs here (just for testing)
// can use this to build out string replacement when
// swapping in html from a element
// this will enable, controlling the markup, in markup
// and then JS is only having to do logic replacement
-// of the token placeholders, rather than storing strings
+// of the token placeholders, rather than storing strings
// within the JS unnecessarily.
+
// function parseTokens(name, value, str){
// return str.replaceAll("{{"+name+"}}", value);
// }
-
+
// const mark = 'test {{title}} {{year}} by {{author}}';
// parsedMark = parseTokens("year", "2025", mark);
@@ -457,205 +396,226 @@ function renderMarkingFormats(state) {
// parsedMark = parseTokens("author", "jane mayer", parsedMark);
// console.log(parsedMark);
+
+
// function to render "empty area"
// if no valid tool from state.parts and/or state/current
-function renderEmptyPlaceholder(state) {
- if (state.props.tool == "unknown") {
- document.querySelector("#empty").classList.remove("disable");
- } else if (state.props.tool != "unknown") {
- document.querySelector("#empty").classList.add("disable");
- }
+function renderEmptyPlaceholder(state) {
+
+ if (state.props.tool == 'unknown' ) {
+ document.querySelector('#empty').classList.remove('disable');
+ }
+
+ else if (state.props.tool != 'unknown') {
+ document.querySelector('#empty').classList.add('disable');
+ }
+
}
// function to render "mark your work",
// if valid tool from state.parts and/or state.current
// if attribution details input(s) filled out
function renderMarkYourWork(state) {
- if (state.props.tool != "unknown") {
- // load attribution details template,
- // populate from attribution text values
- document.querySelector("#mark-your-work").classList.remove("disable");
-
- renderMarkingFormats(state);
- } else if (state.props.tool == "unknown") {
- document.querySelector("#mark-your-work").classList.add("disable");
- }
+ if (state.props.tool != 'unknown' ) {
+ // load attribution details template,
+ // populate from attribution text values
+ document.querySelector('#mark-your-work').classList.remove('disable');
+
+ renderMarkingFormats(state);
+
+ }
+
+ else if (state.props.tool == 'unknown') {
+ document.querySelector('#mark-your-work').classList.add('disable');
+ }
+
}
// function to set default UX states on Steps
// set default visibly disabled pathways
function setDefaults(applyDefaults) {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.toggle("disable");
- });
- if (state.parts[0] == "do-you-know-which-license-you-need/yes/") {
applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.add("disable");
+ document.querySelector(element).classList.toggle('disable');
});
- }
- document.querySelector("#tool-recommendation").classList.add("disable");
- document.querySelector("#mark-your-work").classList.add("disable");
- document.querySelector("#tool-rec-details").classList.add("hide");
+ if (state.parts[0] == 'do-you-know-which-license-you-need/yes/' ) {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.add('disable');
+ });
+ }
+
+ document.querySelector('#tool-recommendation').classList.add('disable');
+ document.querySelector('#mark-your-work').classList.add('disable');
+ document.querySelector('#tool-rec-details').classList.add('hide');
}
-// stepper logic here for what parts of form are
-// displayed/hidden, as state.parts and state.current
+// stepper logic here for what parts of form are
+// displayed/hidden, as state.parts and state.current
// are updated
function renderSteps(applyDefaults, state) {
- // check if visitor needs help, start help pathways
- if (state.current == "do-you-know-which-license-you-need/no/") {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.remove("disable");
- });
- document
- .querySelector("#which-license-do-you-need")
- .classList.toggle("disable");
- document.querySelector("#waive-your-copyright").classList.add("disable");
- }
-
- // if visitor doesn't need help
- if (state.current == "do-you-know-which-license-you-need/yes/") {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.add("disable");
- });
- document
- .querySelector("#which-license-do-you-need")
- .classList.toggle("disable");
- document.querySelector("#waive-your-copyright").classList.add("disable");
- }
-
- // check if cc0
- if (
- state.parts[2] == "require-attribution/no/" ||
- state.parts[1] == "which-license-do-you-need/cc-0/"
- ) {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.add("disable");
- });
- document
- .querySelector("#waive-your-copyright")
- .classList.remove("disable");
- } else {
- document.querySelector("#waive-your-copyright").classList.add("disable");
- }
- if (state.parts[2] == "require-attribution/no/") {
- document.querySelector("#require-attribution").classList.remove("disable");
- }
-
- // walk away from cc-0, reset attribution choice point
- if (state.parts[2] == "require-attribution/yes/") {
- applyDefaults.elements.forEach((element) => {
- document.querySelector(element).classList.remove("disable");
- });
- document.querySelector("#require-attribution").classList.remove("disable");
- document.querySelector("#waive-your-copyright").classList.add("disable");
- }
-
- // tie SA to ND choice
- if (state.parts[4] == "allow-derivatives/no/") {
- document.querySelector("#share-alike").classList.add("disable");
- }
+ // check if visitor needs help, start help pathways
+ if (state.current == 'do-you-know-which-license-you-need/no/' ) {
+
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.remove('disable');
+ });
+ document.querySelector('#which-license-do-you-need').classList.toggle('disable');
+ document.querySelector('#waive-your-copyright').classList.add('disable');
+
+ }
+
+ // if visitor doesn't need help
+ if (state.current == 'do-you-know-which-license-you-need/yes/' ) {
+
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.add('disable');
+ });
+ document.querySelector('#which-license-do-you-need').classList.toggle('disable');
+ document.querySelector('#waive-your-copyright').classList.add('disable');
+
+ }
+
+ // check if cc0
+ if (state.parts[2] == 'require-attribution/no/' || state.parts[1] == 'which-license-do-you-need/cc-0/' ) {
+
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.add('disable');
+ });
+
+ document.querySelector('#waive-your-copyright').classList.remove('disable');
+
+ } else {
+ document.querySelector('#waive-your-copyright').classList.add('disable');
+ }
+ if (state.parts[2] == 'require-attribution/no/') {
+ document.querySelector('#require-attribution').classList.remove('disable');
+ }
+
+ // walk away from cc-0, reset attribution choice point
+ if (state.parts[2] == 'require-attribution/yes/') {
+ applyDefaults.elements.forEach((element) => {
+ document.querySelector(element).classList.remove('disable');
+ });
+ document.querySelector('#require-attribution').classList.remove('disable');
+ document.querySelector('#waive-your-copyright').classList.add('disable');
+ }
+
+ // tie SA to ND choice
+ if (state.parts[4] == 'allow-derivatives/no/') {
+ document.querySelector('#share-alike').classList.add('disable');
+ }
+
}
// [T]: function to handle error state
-// function to watch for fieldset changes
+// function to watch for fieldset changes
function watchFieldsets(fieldsets, state) {
- fieldsets.forEach((element, index) => {
- // [T]: set defaults here first in state.parts dynamically
+ fieldsets.forEach((element, index) => {
+
+ // [T]: set defaults here first in state.parts dynamically
+
+ element.addEventListener("change", (event) => {
+
+ updateStateParts(element, index, event, state);
+
+ setStateCurrent(element, index, state);
- element.addEventListener("change", (event) => {
- updateStateParts(element, index, event, state);
+ setStateProps(index, state);
- setStateCurrent(element, index, state);
+ // [T]: also reset values beyond current changed fieldset to nothing each time
+ clearStepsAfterCursor(fieldsets, state);
- setStateProps(index, state);
+ renderSteps(applyDefaults, state);
- // [T]: also reset values beyond current changed fieldset to nothing each time
- clearStepsAfterCursor(fieldsets, state);
+ renderEmptyPlaceholder(state);
- renderSteps(applyDefaults, state);
+ renderToolRec(state);
- renderEmptyPlaceholder(state);
+ renderMarkYourWork(state);
- renderToolRec(state);
+ });
- renderMarkYourWork(state);
});
- });
}
function watchAttributionDetails(fieldsets, state) {
- let textFields = fieldsets[8].querySelectorAll("input");
- textFields.forEach((element, index) => {
- element.addEventListener("keyup", (event) => {
- renderMarkingFormats(state);
+ let textFields = fieldsets[8].querySelectorAll('input');
+
+ textFields.forEach((element, index) => {
+
+ element.addEventListener("keyup", (event) => {
+ renderMarkingFormats(state);
+ });
+
});
- });
}
function watchMarkToggles(toggles, state) {
- toggles.forEach((element, index) => {
- element.addEventListener("click", (event) => {
- renderMarkingFormats(state);
+
+ toggles.forEach((element, index) => {
+
+ element.addEventListener("click", (event) => {
+ renderMarkingFormats(state);
+ });
+
});
- });
}
function watchMarkCopiers(copiers, state) {
- function copyToClipboard(text) {
- let temp = document.createElement("textarea");
- document.body.appendChild(temp);
- temp.value = text;
- temp.select();
- document.execCommand("copy");
- document.body.removeChild(temp);
- }
-
- copiers.forEach((element, index) => {
- element.addEventListener("click", (event) => {
- if (element.parentNode.parentNode.querySelector(".mark").value != null) {
- copyToClipboard(
- element.parentNode.parentNode.querySelector(".mark").value,
- );
- } else {
- copyToClipboard(
- element.parentNode.parentNode.querySelector(".mark").innerHTML,
- );
- }
+
+ function copyToClipboard (text) {
+ let temp = document.createElement("textarea");
+ document.body.appendChild(temp);
+ temp.value = text;
+ temp.select();
+ document.execCommand("copy");
+ document.body.removeChild(temp);
+ }
+
+ copiers.forEach((element, index) => {
+
+ element.addEventListener("click", (event) => {
+
+ if (element.parentNode.parentNode.querySelector('.mark').value != null) {
+ copyToClipboard(element.parentNode.parentNode.querySelector('.mark').value);
+ } else {
+ copyToClipboard(element.parentNode.parentNode.querySelector('.mark').innerHTML);
+ }
+ });
+
});
- });
}
document.addEventListener("DOMContentLoaded", (event) => {
- // full flow logic
- setStateParts(state);
+ // full flow logic
+ setStateParts(state);
- setStatePossibilities(state);
+ setStatePossibilities(state);
- setDefaults(applyDefaults);
+ setDefaults(applyDefaults);
- setStateProps(0, state);
+ setStateProps(0, state);
- watchFieldsets(fieldsets, state);
- watchAttributionDetails(fieldsets, state);
- watchMarkToggles(toggles, state);
- watchMarkCopiers(copiers, state);
+ watchFieldsets(fieldsets, state);
+ watchAttributionDetails(fieldsets, state);
+ watchMarkToggles(toggles, state);
+ watchMarkCopiers(copiers, state);
});
// rough panel expansion test
// let expandButtons = document.querySelectorAll('button.expandPanel');
-// expandButtons.forEach((element, index) => {
+// expandButtons.forEach((element, index) => {
// element.addEventListener("click", (event) => {
// parent = event.target.parentNode.parentNode;
// parent.querySelector('.panel').classList.toggle('expand');
-
+
// });
// });
+
diff --git a/src/style.css b/src/style.css
index 8b69d612..0ece9d72 100644
--- a/src/style.css
+++ b/src/style.css
@@ -1,368 +1,369 @@
-@import "vocabulary/css/vocabulary.css" layer(vocabulary);
+@import 'vocabulary/css/vocabulary.css' layer(vocabulary);
:root {
- /* localized cc sprite names */
- --cc-by: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-by");
- --cc-nc: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-nc");
- --cc-nd: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-nd");
- --cc-pd: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-pd");
- --cc-pdm: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-pdm");
- --cc-sa: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-sa");
- --cc-zero: url("/vocabulary/svg/cc/icons/cc-icons.svg#cc-zero");
+
+ /* localized cc sprite names */
+ --cc-by: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-by');
+ --cc-nc: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-nc');
+ --cc-nd: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-nd');
+ --cc-pd: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-pd');
+ --cc-pdm: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-pdm');
+ --cc-sa: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-sa');
+ --cc-zero: url('/vocabulary/svg/cc/icons/cc-icons.svg#cc-zero');
}
.chooser-page .icon-attach.cc-by:before {
- --icon-sprite: var(--cc-by);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-by);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page .icon-attach.cc-nc:before {
- --icon-sprite: var(--cc-nc);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-nc);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page .icon-attach.cc-nd:before {
- --icon-sprite: var(--cc-nd);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-nd);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page .icon-attach.cc-pd:before {
- --icon-sprite: var(--cc-pd);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-pd);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page .icon-attach.cc-pdm:before {
- --icon-sprite: var(--cc-pdm);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-pdm);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page .icon-attach.cc-sa:before {
- --icon-sprite: var(--cc-sa);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-sa);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page .icon-attach.cc-zero:before {
- --icon-sprite: var(--cc-zero);
- margin-right: 0.2em;
- margin-bottom: -0.125em;
+ --icon-sprite: var(--cc-zero);
+ margin-right: .2em;
+ margin-bottom: -.125em;
}
.chooser-page dl div {
- margin-bottom: 0.8em;
+ margin-bottom: .8em;
}
-.chooser-page dt,
-.chooser-page dd {
- display: inline-block;
+.chooser-page dt, .chooser-page dd {
+ display: inline-block;
}
.chooser-page dt:after {
- content: ":";
+ content: ':';
}
.chooser-page dd {
- margin-left: 0.2em;
+ margin-left: .2em;
}
.chooser-page dd span {
- display: block;
+ display: block;
}
.chooser-page ol li:has(.disable) {
- display: none;
+ display: none;
}
.chooser-page .disable {
- display: none;
+ display: none;
}
.chooser-page .hide {
- display: none;
+ display: none;
}
.chooser-page .tool header {
- display: flex;
- flex-wrap: wrap;
+ display: flex;
+ flex-wrap: wrap;
}
.chooser-page .tool header > h4 {
- width: 100%;
+ width: 100%;
}
.chooser-page .tool header > .tool-icons {
- order: -1;
- margin: 0 1em 0 0;
+ order: -1;
+ margin: 0 1em 0 0;
}
.chooser-page .tool .tool-icons svg {
- display: inline;
- width: 1.9em;
- height: 1.9em;
- margin-right: 0.3em;
+ display: inline;
+ width: 1.9em;
+ height: 1.9em;
+ margin-right: .3em;
}
.chooser-page .content {
- display: grid;
- gap: 2em;
- grid-template-columns: 1fr 2fr;
+ display: grid;
+ gap: 2em;
+ grid-template-columns: 1fr 2fr;
}
.chooser-page .mark svg {
- display: inline;
- width: 1.3em;
- height: 1.3em;
+ display: inline;
+ width: 1.3em;
+ height: 1.3em;
}
.chooser-page .mark svg:first-of-type {
- margin-left: 0.5em;
+ margin-left: .5em;
}
.chooser-page .tool-rec-details input {
- color: lightgray;
+ color: lightgray;
}
.chooser-page form#chooser > ol {
- position: relative;
+ position: relative;
- list-style: none;
- counter-reset: chooser-counter;
+ list-style: none;
+ counter-reset: chooser-counter;
}
.chooser-page form#chooser > ol li {
- counter-increment: chooser-counter;
+ counter-increment: chooser-counter;
}
.chooser-page form#chooser > ol li::before {
- position: absolute;
- --size: 32px;
- left: calc(-1 * var(--size) - 25px);
- min-height: 2em;
- min-width: 2em;
- padding-top: 0.4em;
- box-sizing: border-box;
-
- content: counter(chooser-counter);
- font-weight: bold;
- border-radius: 200px;
- background: var(--vocabulary-neutral-color-lighter-gray);
- color: black;
- text-align: center;
- vertical-align: middle;
+ position: absolute;
+ --size: 32px;
+ left: calc(-1 * var(--size) - 25px);
+ min-height: 2em;
+ min-width: 2em;
+ padding-top: .4em;
+ box-sizing: border-box;
+
+ content: counter(chooser-counter);
+ font-weight: bold;
+ border-radius: 200px;
+ background: var(--vocabulary-neutral-color-lighter-gray);
+ color: black;
+ text-align: center;
+ vertical-align: middle;
}
.chooser-page form#chooser legend {
- font-weight: bold;
+ font-weight: bold;
}
.chooser-page form#chooser fieldset {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
.chooser-page form#chooser label {
- font-size: 0.7em;
- font-weight: 400;
+ font-size: .7em;
+ font-weight: 400;
}
.chooser-page form#chooser #attribution-details span {
- display: inline-block;
- padding: 0.7em 0;
+ display: inline-block;
+ padding: .7em 0;
- font-size: 0.8em;
- line-height: 1.3;
+ font-size: .8em;
+ line-height: 1.3;
}
.chooser-page form#chooser #attribution-details div {
- margin-bottom: 0.5em;
-}
+ margin-bottom: .5em;
+}
.chooser-page form#chooser #waive-your-copyright div {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
.chooser-page form#chooser #attribution-details input {
- padding: 0.2em 0.2em;
+ padding: .2em .2em;
- font-size: 1em;
+ font-size: 1em;
}
.chooser-page form#chooser #atrribution-details input::placeholder {
- opacity: 0.5;
+ opacity: .5;
}
.chooser-page aside #empty {
- min-height: 10em;
- padding: 2em;
+ min-height: 10em;
+ padding: 2em;
- background: var(--vocabulary-brand-color-soft-turquoise);
- background: var(--vocabulary-neutral-color-lighter-gray);
+ background: var(--vocabulary-brand-color-soft-turquoise);
+ background: var(--vocabulary-neutral-color-lighter-gray);
}
.chooser-page aside #empty p {
- font-size: 1.2em;
+ font-size: 1.2em;
}
.chooser-page #tool-recommendation {
- margin-bottom: 4em;
+ margin-bottom: 4em;
- font-family: "Source Sans Pro";
+ font-family: 'Source Sans Pro';
}
.chooser-page #tool-recommendation .tool {
- padding: 2em;
+ padding: 2em;
- background: var(--vocabulary-brand-color-soft-turquoise);
+ background: var(--vocabulary-brand-color-soft-turquoise);
}
.chooser-page #tool-recommendation .tool a {
- --underline-background-color: var(--vocabulary-brand-color-soft-turquoise);
+ --underline-background-color: var(--vocabulary-brand-color-soft-turquoise);
}
.chooser-page #tool-recommendation h3 {
- margin: 0;
+ margin: 0;
- font-family: "Source Sans Pro";
- font-size: 1.4em;
+ font-family: 'Source Sans Pro';
+ font-size: 1.4em;
}
.chooser-page #tool-recommendation h4 {
- margin: 0.2em;
+ margin: .2em;
- font-family: "Source Sans Pro";
- font-size: 1.4em;
+ font-family: 'Source Sans Pro';
+ font-size: 1.4em;
}
.chooser-page #tool-recommendation p {
- font-size: 1.2em;
+ font-size: 1.2em;
}
.chooser-page #tool-recommendation a {
- font-weight: 700;
+ font-weight: 700;
}
.chooser-page #tool-recommendation .conditions-definitions {
- margin-bottom: 2em;
+ margin-bottom: 2em;
- font-family: "Source Sans Pro";
+ font-family: 'Source Sans Pro';
}
.chooser-page #tool-recommendation .conditions-definitions dt {
- font-weight: 700;
+ font-weight: 700;
}
.chooser-page #mark-your-work textarea {
- min-height: 9em;
- width: 90%;
- margin: 1em;
- box-sizing: border-box;
+ min-height: 9em;
+ width: 90%;
+ margin: 1em;
+ box-sizing: border-box;
}
.chooser-page #mark-your-work p {
- font-size: 1.2em;
+ font-size: 1.2em;
}
-.chooser-page details {
- font-family: "Source Sans Pro";
+.chooser-page details {
+ font-family: 'Source Sans Pro';
- border: 2px solid var(--vocabulary-neutral-color-lighter-gray);
- border-radius: 5px;
+ border: 2px solid var(--vocabulary-neutral-color-lighter-gray);
+ border-radius: 5px;
}
.chooser-page details details {
- margin: 1em;
+ margin: 1em;
}
.chooser-page details.medium {
- margin-bottom: 1em;
+ margin-bottom: 1em;
}
-
+
.chooser-page details summary {
- padding: 0.2em 0.5em;
+ padding: .2em .5em;
- background: var(--vocabulary-neutral-color-lighter-gray);
- font-size: 1.6em;
+ background: var(--vocabulary-neutral-color-lighter-gray);
+ font-size: 1.6em;
}
.chooser-page details.format summary {
- font-size: 1.3em;
+ font-size: 1.3em;
}
.chooser-page summary:hover {
- cursor: pointer;
+ cursor: pointer;
}
-
+
.chooser-page summary::marker {
- font-size: 0.8em;
+ font-size: .8em;
}
.chooser-page details p {
- padding: 0 1em;
+ padding: 0 1em;
- font-size: 1em;
+ font-size: 1em;
}
.chooser-page details.format footer {
- display: flex;
- justify-content: space-between;
- padding: 1em;
+ display: flex;
+ justify-content: space-between;
+ padding: 1em;
}
.chooser-page details.format footer label {
- margin-left: 0.2em;
+ margin-left: .2em;
}
.chooser-page details.format footer button {
- padding: 0.5em 1em;
+ padding: .5em 1em;
- background: #324c7f;
- color: white;
- border-radius: 3px;
- border: none;
+ background: #324C7F;
+ color: white;
+ border-radius: 3px;
+ border: none;
}
.chooser-page details.format footer button:hover {
- cursor: pointer;
+ cursor: pointer;
}
.chooser-page .content {
- grid-column: 3 / 10;
+ grid-column: 3 / 10;
}
.chooser-page #help {
- margin-top: 4em;
-}
+ margin-top: 4em;
+ }
-.chooser-page #help details {
- margin-bottom: 1em;
-}
+ .chooser-page #help details {
+ margin-bottom: 1em;
+ }
-.chooser-page #help ul {
- font-size: 1em;
- padding: 0 1em;
-}
+ .chooser-page #help ul {
+ font-size: 1em;
+ padding: 0 1em;
+ }
-.chooser-page #help ul li {
- padding-bottom: 0.5em;
-}
+ .chooser-page #help ul li {
+ padding-bottom: .5em;
+ }
+
+ .chooser-page #help dl {
+ padding: 0 1em;
+ }
-.chooser-page #help dl {
- padding: 0 1em;
-}
@media (max-width: 705px) {
- .chooser-page .content {
- display: block;
- }
+ .chooser-page .content {
+ display: block;
+ }
}
.chooser-page .panel {
- display: none;
+ display: none;
}
.chooser-page .panel.expand {
- display: initial;
+ display: initial;
}