Skip to content

Commit

Permalink
Merge branch 'dev' into refactor-builtin-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMayfield authored Jul 8, 2024
2 parents 79f27cd + 582d0f3 commit 1d5c165
Show file tree
Hide file tree
Showing 20 changed files with 1,105 additions and 1,028 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1>Welcome to Praxly 🍂</h1>
</div>

<iframe
src="embed.html?button=both&result=both#code=%2F%2F%20Function%20to%20calculate%20change%0Avoid%20calculateChange(int%20paidAmount%2C%20int%20itemCost)%0A%20%20%20%20int%20change%20%E2%86%90%20paidAmount%20-%20itemCost%0A%20%20%20%20int%20cents%20%E2%86%90%20change%0A%0A%20%20%20%20int%20quarters%20%E2%86%90%20cents%20%2F%2025%0A%20%20%20%20cents%20%E2%86%90%20cents%20%25%2025%0A%20%20%20%20int%20dimes%20%E2%86%90%20cents%20%2F%2010%0A%20%20%20%20cents%20%E2%86%90%20cents%20%25%2010%0A%20%20%20%20int%20nickels%20%E2%86%90%20cents%20%2F%205%0A%20%20%20%20int%20pennies%20%E2%86%90%20cents%20%25%205%0A%0A%20%20%20%20%2F%2F%20Print%20change%20breakdown%0A%20%20%20%20println%20%22Change%20to%20be%20given%3A%22%0A%20%20%20%20println%20%22Quarters%3A%20%22%20%2B%20quarters%0A%20%20%20%20println%20%22Dimes%3A%20%22%20%2B%20dimes%0A%20%20%20%20println%20%22Nickels%3A%20%22%20%2B%20nickels%0A%20%20%20%20println%20%22Pennies%3A%20%22%20%2B%20pennies%0Aend%20calculateChange%0A%0A%2F%2F%20Main%20function%0Avoid%20main()%0A%20%20%20%20int%20itemCost%20%E2%86%90%201789%0A%20%20%20%20int%20paidAmount%20%E2%86%90%202000%0A%0A%20%20%20%20%2F%2F%20Check%20if%20paid%20amount%20is%20sufficient%0A%20%20%20%20if%20(paidAmount%20%3C%20itemCost)%0A%20%20%20%20%20%20%20%20println%20%22Insufficient%20amount%20paid.%22%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%2F%2F%20Calculate%20and%20print%20change%0A%20%20%20%20%20%20%20%20calculateChange(paidAmount%2C%20itemCost)%0A%20%20%20%20end%20if%0Aend%20main%0A%0A%2F%2F%20Run%20the%20main%20function%0Amain()%0A"
src="embed.html?button=both&result=both#code=%2F%2F%20Function%20to%20calculate%20change%0Avoid%20calculateChange(int%20paidAmount%2C%20int%20itemCost)%0A%20%20%20%20int%20change%20%E2%86%90%20paidAmount%20-%20itemCost%0A%20%20%20%20int%20cents%20%E2%86%90%20change%0A%0A%20%20%20%20int%20quarters%20%E2%86%90%20cents%20%2F%2025%0A%20%20%20%20cents%20%E2%86%90%20cents%20%25%2025%0A%20%20%20%20int%20dimes%20%E2%86%90%20cents%20%2F%2010%0A%20%20%20%20cents%20%E2%86%90%20cents%20%25%2010%0A%20%20%20%20int%20nickels%20%E2%86%90%20cents%20%2F%205%0A%20%20%20%20int%20pennies%20%E2%86%90%20cents%20%25%205%0A%0A%20%20%20%20%2F%2F%20Print%20change%20breakdown%0A%20%20%20%20print%20%22Change%20to%20be%20given%3A%22%0A%20%20%20%20print%20%22Quarters%3A%20%22%20%2B%20quarters%0A%20%20%20%20print%20%22Dimes%3A%20%22%20%2B%20dimes%0A%20%20%20%20print%20%22Nickels%3A%20%22%20%2B%20nickels%0A%20%20%20%20print%20%22Pennies%3A%20%22%20%2B%20pennies%0Aend%20calculateChange%0A%0A%2F%2F%20Main%20function%0Avoid%20main()%0A%20%20%20%20int%20itemCost%20%E2%86%90%201789%0A%20%20%20%20int%20paidAmount%20%E2%86%90%202000%0A%0A%20%20%20%20%2F%2F%20Check%20if%20paid%20amount%20is%20sufficient%0A%20%20%20%20if%20(paidAmount%20%3C%20itemCost)%0A%20%20%20%20%20%20%20%20print%20%22Insufficient%20amount%20paid.%22%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%2F%2F%20Calculate%20and%20print%20change%0A%20%20%20%20%20%20%20%20calculateChange(paidAmount%2C%20itemCost)%0A%20%20%20%20end%20if%0Aend%20main%0A%0A%2F%2F%20Run%20the%20main%20function%0Amain()%0A"
width="100%" height="600" allow="fullscreen" frameborder="0">
</iframe>

Expand Down
28 changes: 26 additions & 2 deletions main.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,30 @@ <h1 id="titleRefresh">Praxly 🍂</h1>

<div id="secondary_bar">
<!-- Example programs -->
<select id="exampleTable"></select>
<button id="examplesButton">Example Programs</button>
<div class="exampleModal">
<div class="exampleModalContent">
<span class="material-symbols-rounded close">close</span>

<div class="exampleModalText">
<h3>Here are some example programs to practice with!</h2>
<p>Click on the blue links to browse and try out some sample code.</p>
</div>

<!-- This div is just to separate things-->
<div class="examples-outer">
<table class="examplesTable">
<tr>
<th>Example Name</th>
<th>Difficulty</th>
<th>Topics</th>
</tr>
</table>
</div>


</div>
</div>
</div>
</div>

Expand Down Expand Up @@ -86,7 +109,8 @@ <h1 id="titleRefresh">Praxly 🍂</h1>
<button id="reference" class="MainMenu-button" title="reference">
<span class="material-symbols-rounded manual">book_2</span>
<span class="button-text">Manual</span>
</button></li>
</button>
</li>
<li class="settingsOptions">
<button id="darkMode" class="MainMenu-button" title="Dark Mode">
<span class="button-text">Dark Mode</span>
Expand Down
3 changes: 1 addition & 2 deletions public/pseudocode.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ <h2>Pseudocode Notation</h2>
to the argument.</td>
<td><b>print</b> <i>arg</i></td>
<td>
With <b>print</b>, no line feed or blank space is appended by Praxly.<br>
With <b>print</b>, there will be line feed or blank space appended by Praxly.
<br>
Praxly also provides <b>println</b> which always appends a line feed.
</td>
</tr>
<tr>
Expand Down
132 changes: 77 additions & 55 deletions public/themes.css
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,71 @@ h1 {
color: #ffffff;
}

#exampleTable {
/* #exampleTable {
color: #2196f3;
background-color: var(--example-table-bg-color);
display: flex;
} */

/* button */
#examplesButton {
border-radius: 5px;
border: none;
/* border: 1px solid var(--text-color); */
background-color: rgb(25, 25, 25);
color: var(--text-color);
transition: 0.2s background-color;
}

#examplesButton:hover {
background-color: #000;
}

.exampleModal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: auto;
justify-content: center;
align-items: center;
z-index: 99;
background-color: rgba(0, 0, 0, 0.5);
}

.exampleModalContent {
background-color: #ffffff;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-width: 900px;
padding: 50px;
color: black;
border-radius: 10px;
}

.exampleModalText h3 {
margin-bottom: 0;
}

.exampleModalText p {
margin-top: 5px;
}

.examplesTable {
border-collapse: collapse;
width: 100%;
}

.examplesTable th {
border: 1px solid black;
border-spacing: 5px;
padding: 5px;
}

.examplesTable td {
border: 1px solid black;
padding: 5px;
}

.example_links {
Expand All @@ -369,8 +430,6 @@ h1 {
margin: 10px;
cursor: pointer;
/* Optional: add a pointer cursor to indicate interactivity */
color: inherit;
/* Inherit the text color from its parent element */
text-decoration: underline;
}

Expand Down Expand Up @@ -438,57 +497,12 @@ h1 {

#secondary_bar {
display: flex;
background-color: #e7e5e5;
border: 1px solid #aaa;
/* background-color: #e7e5e5; */
/* border: 1px solid #aaa; */
margin-top: 20px;
height: 40px;
}

/* Style the tab */
.tab {
overflow: hidden;
border: 1px solid var(--tab-border-color);
/* change might be necessary */
background-color: var(--tab-bg-color);
}

#tab1_button,
#tab2_button,
#tab3_button {
color: var(--tab-text-color);
}

/* Style the buttons that are used to open the tab content */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
}

/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}

/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
}

/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
animation: fadeEffect 1s;
/* Fading effect takes 1 second */
}

/* main blockly and ace editor */

main {
Expand Down Expand Up @@ -650,7 +664,8 @@ body:not(.embed) #bottom-part {
padding: 10px;
/* border-radius: 10px; */
overflow: auto;
background-color: var(--output-bg-color); /* #ffffff */
background-color: var(--output-bg-color);
/* #ffffff */
height: 100%;
}

Expand All @@ -663,15 +678,17 @@ body:not(.embed) #bottom-part {
/* Style for table headers */
#Variable-table-outer th {
background-color: var(--table-row-color);
border: 1px solid var(--text-color); /* 000000 */
border: 1px solid var(--text-color);
/* 000000 */
color: var(--text-color);
padding: 1ex;
text-align: left;
}

/* Style for table cells */
#Variable-table-outer td {
border: 1px solid var(--text-color); /* 000000 */
border: 1px solid var(--text-color);
/* 000000 */
color: var(--text-color);
padding: 1ex;
}
Expand Down Expand Up @@ -853,8 +870,10 @@ body:not(.embed)>#embed-toolbar {
flex-wrap: nowrap;
align-items: center;
justify-content: space-evenly;
width: 60px; /* 6em */
height: 30px; /* 4em */
width: 60px;
/* 6em */
height: 30px;
/* 4em */
/* line-height: 0; */
position: relative;
border: none;
Expand Down Expand Up @@ -903,12 +922,15 @@ body:not(.embed)>#embed-toolbar {
0% {
transform: rotate(0deg);
}

25% {
transform: rotate(-3deg);
}

75% {
transform: rotate(3deg);
}

100% {
transform: rotate(0deg);
}
Expand Down
19 changes: 1 addition & 18 deletions src/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ export function createExecutable(tree) {
case NODETYPES.PRINT:
return new Praxly_print(createExecutable(tree.value), tree);

case NODETYPES.PRINTLN:
return new Praxly_println(createExecutable(tree.value), tree);

case NODETYPES.INPUT:
return new Praxly_input(tree);

Expand Down Expand Up @@ -530,26 +527,12 @@ class Praxly_print {
async evaluate(environment) {
var child = await (this.expression.evaluate(environment));
var result = valueToString(child, this.json);
addToPrintBuffer(result);
return null;
}
}

class Praxly_println {

constructor(value, node) {
this.json = node;
this.expression = value;
}

async evaluate(environment) {
var child = await this.expression.evaluate(environment);
var result = valueToString(child, this.json);
addToPrintBuffer(result + '<br>');
return null;
}
}


class Praxly_input {

constructor(node) {
Expand Down
9 changes: 0 additions & 9 deletions src/blocks2tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ export const makeGenerator = () => {
}
}

praxlyGenerator['praxly_println_block'] = (block) => {
const expression = block.getInputTargetBlock('EXPRESSION');
return {
blockID: block.id,
type: NODETYPES.PRINTLN,
value: praxlyGenerator[expression.type](expression),
}
}

praxlyGenerator['praxly_random_block'] = (block) => {
return {
name: 'random',
Expand Down
5 changes: 2 additions & 3 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const NODETYPES = {
...OP,
...TYPES,
PRINT: "PRINT",
PRINTLN: "PRINTLN",
BUILTIN_FUNCTION_CALL: "BUILTIN_FUNCTION_CALL",
INPUT: "INPUT",
CODEBLOCK: "CODEBLOCK",
Expand Down Expand Up @@ -140,7 +139,7 @@ export function consoleInput() {
});

const clickListener = () => {
inputElement.classList.add('attract');
inputElement.classList.add('attract');
inputElement.focus();
};
blocker.addEventListener('click', clickListener);
Expand All @@ -154,7 +153,7 @@ export function consoleInput() {
inputElement.classList.remove('prompt');
blocker.style.display = 'none';
} else if (event.key === 'Escape') {
// TODO: what should we do on escape?
// TODO: what should we do on escape?
}
};
inputElement.addEventListener('keyup', listener);
Expand Down
Loading

0 comments on commit 1d5c165

Please sign in to comment.