Skip to content

Commit

Permalink
Deploying to gh-pages from @ e5f278c 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
coatless committed Jan 30, 2024
1 parent aab631e commit ba80bd9
Show file tree
Hide file tree
Showing 69 changed files with 3,854 additions and 1,139 deletions.
129 changes: 100 additions & 29 deletions demos/qwebr-custom-repository.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.4">
<meta name="generator" content="quarto-1.5.5">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

Expand Down Expand Up @@ -117,6 +117,12 @@
background-color: unset !important;
}

.qwebr-editor-toolbar {
width: 100%;
display: flex;
justify-content: space-between;
}

.qwebr-non-interactive-loading-container.qwebr-cell-needs-evaluation, .qwebr-non-interactive-loading-container.qwebr-cell-evaluated {
justify-content: center;
display: flex;
Expand Down Expand Up @@ -151,42 +157,47 @@
border: 1px solid #EEEEEE;
}

.qwebr-button-run {
.qwebr-editor-toolbar {
background-color: #EEEEEE;
padding: 0.2rem 0.5rem;
}

.qwebr-button {
background-color: #EEEEEE;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0; /* Extra styling for consistency */
display: inline-block;
font-weight: 400;
line-height: 1.5;
color: #000;
text-align: center;
line-height: 1;
text-decoration: none;
-webkit-text-decoration: none;
-moz-text-decoration: none;
-ms-text-decoration: none;
-o-text-decoration: none;
/* vertical-align: middle; */ /* Prevents a space from appearing between the code cell and button */
-webkit-user-select: none;
text-align: center;
color: #000;
border-color: #dee2e6;
border: 1px solid rgba(0,0,0,0);
padding: 0.375rem 0.75rem;
font-size: 1rem;
border-top-right-radius: 0.25rem;
border-top-left-radius: 0.25rem;
font-size: .9rem;
border-radius: 0.25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}

.qwebr-button-run:hover {
.qwebr-button:hover {
color: #000;
background-color: #e3e6ea;
border-color: #e1e5e9;
background-color: #d9dce0;
border-color: #c8ccd0;
}

.qwebr-button-run:disabled,.qwebr-button-run.disabled,fieldset:disabled .qwebr-button-run {
.qwebr-button:disabled,.qwebr-button.disabled,fieldset:disabled .qwebr-button {
pointer-events: none;
opacity: .65
}

.qwebr-button-reset {
color: #696969; /*#4682b4;*/
}

.qwebr-button-copy {
color: #696969;
}


/* Custom styling for RevealJS Presentations*/

/* Reset the style of the interactive area */
Expand Down Expand Up @@ -259,7 +270,7 @@
};

// Store cell data
globalThis.qwebrCellDetails = [{"code":"# Check to see if the function works\ndemorwasmbinary::in_webr()\n\n# View help documentation\n?demorwasmbinary::in_webr","id":1,"options":{"context":"interactive"}}];
globalThis.qwebrCellDetails = [{"options":{"context":"interactive"},"id":1,"code":"# Check to see if the function works\ndemorwasmbinary::in_webr()\n\n# View help documentation\n?demorwasmbinary::in_webr"}];

</script>
<script type="module">
Expand Down Expand Up @@ -406,13 +417,50 @@
mainDiv.id = 'qwebr-interactive-area-' + qwebrCounter;
mainDiv.className = 'qwebr-interactive-area';

// Create button element
var button = document.createElement('button');
button.className = 'btn btn-default qwebr-button-run';
button.disabled = true;
button.type = 'button';
button.id = 'qwebr-button-run-' + qwebrCounter;
button.textContent = '🟡 Loading webR...';
// Create toolbar div
var toolbarDiv = document.createElement('div');
toolbarDiv.className = 'qwebr-editor-toolbar';
toolbarDiv.id = 'qwebr-editor-toolbar-' + qwebrCounter;

// Create a div to hold the left buttons
var leftButtonsDiv = document.createElement('div');
leftButtonsDiv.className = 'qwebr-editor-toolbar-left-buttons';

// Create a div to hold the right buttons
var rightButtonsDiv = document.createElement('div');
rightButtonsDiv.className = 'qwebr-editor-toolbar-right-buttons';

// Create Run Code button
var runCodeButton = document.createElement('button');
runCodeButton.className = 'btn btn-default qwebr-button qwebr-button-run';
runCodeButton.disabled = true;
runCodeButton.type = 'button';
runCodeButton.id = 'qwebr-button-run-' + qwebrCounter;
runCodeButton.textContent = '🟡 Loading webR...';
runCodeButton.title = `Run code (Shift + Enter)`;

// Append buttons to the leftButtonsDiv
leftButtonsDiv.appendChild(runCodeButton);

// Create Reset button
var resetButton = document.createElement('button');
resetButton.className = 'btn btn-light btn-xs qwebr-button qwebr-button-reset';
resetButton.type = 'button';
resetButton.id = 'qwebr-button-reset-' + qwebrCounter;
resetButton.title = 'Start over';
resetButton.innerHTML = '<i class="fa-solid fa-arrows-rotate"></i>';

// Create Copy button
var copyButton = document.createElement('button');
copyButton.className = 'btn btn-light btn-xs qwebr-button qwebr-button-copy';
copyButton.type = 'button';
copyButton.id = 'qwebr-button-copy-' + qwebrCounter;
copyButton.title = 'Copy code';
copyButton.innerHTML = '<i class="fa-regular fa-copy"></i>';

// Append buttons to the rightButtonsDiv
rightButtonsDiv.appendChild(resetButton);
rightButtonsDiv.appendChild(copyButton);

// Create console area div
var consoleAreaDiv = document.createElement('div');
Expand Down Expand Up @@ -440,8 +488,12 @@
outputGraphAreaDiv.id = 'qwebr-output-graph-area-' + qwebrCounter;
outputGraphAreaDiv.className = 'qwebr-output-graph-area';

// Append buttons to the toolbar
toolbarDiv.appendChild(leftButtonsDiv);
toolbarDiv.appendChild(rightButtonsDiv);

// Append all elements to the main div
mainDiv.appendChild(button);
mainDiv.appendChild(toolbarDiv);
consoleAreaDiv.appendChild(editorDiv);
consoleAreaDiv.appendChild(outputCodeAreaDiv);
mainDiv.appendChild(consoleAreaDiv);
Expand Down Expand Up @@ -1111,6 +1163,8 @@ <h2 id="toc-title">On this page</h2>

// Retrieve the previously created document elements
let runButton = document.getElementById(`qwebr-button-run-${qwebrCounter}`);
let resetButton = document.getElementById(`qwebr-button-reset-${qwebrCounter}`);
let copyButton = document.getElementById(`qwebr-button-copy-${qwebrCounter}`);
let editorDiv = document.getElementById(`qwebr-editor-${qwebrCounter}`);

// Load the Monaco Editor and create an instance
Expand Down Expand Up @@ -1243,6 +1297,23 @@ <h2 id="toc-title">On this page</h2>
qwebrExecuteCode(editor.getValue(), editor.__qwebrCounter, EvalTypes.Interactive);
};

// Add a click event listener to the reset button
copyButton.onclick = function () {
// Ensure the editor is in focus
editor.focus();

// Retrieve data
const data = editor.getValue();

// Set the clipboard contents.
navigator.clipboard.writeText(data || "");
};

// Add a click event listener to the copy button
resetButton.onclick = function () {
editor.setValue(editor.__qwebrinitialCode);
};

}
</script>

Expand Down
2 changes: 1 addition & 1 deletion demos/qwebr-feature-demos.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.5.4">
<meta name="generator" content="quarto-1.5.5">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

Expand Down
Loading

0 comments on commit ba80bd9

Please sign in to comment.