This commit is contained in:
parent
c33a997dc5
commit
57507756ec
14 changed files with 864 additions and 97 deletions
139
static/css/style-instantanswer.css
Normal file
139
static/css/style-instantanswer.css
Normal file
|
@ -0,0 +1,139 @@
|
|||
.instant-container {
|
||||
position: absolute;
|
||||
top: 140px;
|
||||
right: 175px;
|
||||
width: 500px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.instant-box {
|
||||
border: 1px solid var(--snip-border);
|
||||
background-color: var(--snip-background);
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.instant-box h3 {
|
||||
margin-top: 0;
|
||||
color: var(--highlight);
|
||||
font-size: 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding-bottom: 10px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.instant-result {
|
||||
margin: 15px 0;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.calc-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.calc-input {
|
||||
padding: 10px;
|
||||
width: 95%;
|
||||
font-size: 18px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
background-color: var(--search-bg);
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.calc-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.calc-buttons button {
|
||||
padding: 10px;
|
||||
font-size: 18px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
background-color: var(--button);
|
||||
color: var(--fg);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.calc-buttons button:hover {
|
||||
background-color: var(--search-select);
|
||||
}
|
||||
|
||||
.calc-result {
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
font-size: 20px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 4px;
|
||||
background-color: var(--snip-background);
|
||||
}
|
||||
|
||||
.calc-history {
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
font-family: monospace;
|
||||
font-size: 16px;
|
||||
color: var(--fg);
|
||||
background-color: var(--search-bg);
|
||||
border: 1px solid var(--border);
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
height: 120px;
|
||||
overflow-y: auto;
|
||||
white-space: pre-line;
|
||||
overflow-anchor: none;
|
||||
}
|
||||
|
||||
.calc-buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.calc-buttons button {
|
||||
padding: 20px;
|
||||
font-size: 20px;
|
||||
border-radius: 6px;
|
||||
background-color: var(--search-bg);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.calc-buttons .equals {
|
||||
background-color: #2ecc71;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.calc-buttons .equals:hover {
|
||||
background-color: #27ae60;
|
||||
}
|
||||
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media only screen and (max-width: 1220px) {
|
||||
.instant-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin-left: 175px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 880px) {
|
||||
.instant-container {
|
||||
width: 90%;
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
|
@ -123,93 +123,6 @@ html {
|
|||
font-size: 15px;
|
||||
}
|
||||
|
||||
.calc {
|
||||
height: fit-content;
|
||||
width: fit-content;
|
||||
position: relative;
|
||||
left: 175px;
|
||||
border: 1px solid var(--snip-border);
|
||||
background-color: var(--snip-background);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.calc-btn-style {
|
||||
background-color: var(--html-bg) !important;
|
||||
}
|
||||
|
||||
.calc-input {
|
||||
width: 90%;
|
||||
height: 10%;
|
||||
background-color: var(--search-bg);
|
||||
border: 1px solid var(--snip-border);
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
margin-top: 8px;
|
||||
text-align: right;
|
||||
max-width: 48em;
|
||||
line-height: 1.58;
|
||||
font-size: 22px;
|
||||
color: var(--fg);
|
||||
letter-spacing: normal;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.calc-btn {
|
||||
max-width: 48em;
|
||||
line-height: 50px;
|
||||
font-size: 22px;
|
||||
color: var(--fg);
|
||||
letter-spacing: normal;
|
||||
border-radius: 8px;
|
||||
background-color: var(--search-bg);
|
||||
border: 1px solid var(--snip-border);
|
||||
height: 50px;
|
||||
margin: auto;
|
||||
margin: 4px;
|
||||
width: 80px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.calc-btn-2 {
|
||||
max-width: 48em;
|
||||
line-height: 50px;
|
||||
font-size: 22px;
|
||||
color: var(--fff);
|
||||
letter-spacing: normal;
|
||||
border-radius: 8px;
|
||||
background-color: var(--font-fg);
|
||||
height: 50px;
|
||||
margin: auto;
|
||||
margin: 4px;
|
||||
width: 80px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.calc-btns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 90px);
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.calc-pos-absolute {
|
||||
position: absolute;
|
||||
margin-top: 60px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.prev_calculation {
|
||||
opacity: 0.5;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.emoji-code {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
@ -978,6 +891,7 @@ p {
|
|||
max-width: 600px;
|
||||
word-wrap: break-word;
|
||||
margin-bottom: 35px;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.result_sublink {
|
||||
|
@ -1518,6 +1432,10 @@ button {
|
|||
|
||||
@media only screen and (max-width: 1220px) {
|
||||
|
||||
.results {
|
||||
padding-right: 340px;
|
||||
}
|
||||
|
||||
.snip {
|
||||
position: relative;
|
||||
float: none;
|
||||
|
@ -1541,10 +1459,6 @@ button {
|
|||
font-size: 13px;
|
||||
}
|
||||
|
||||
.calc {
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.results h3,
|
||||
.result_sublink h3 {
|
||||
font-size: 16px;
|
||||
|
|
47
static/js/calculator.js
Normal file
47
static/js/calculator.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const calcContainer = document.getElementById('dynamic-calc');
|
||||
const staticCalc = document.getElementById('static-calc');
|
||||
|
||||
if (calcContainer) {
|
||||
calcContainer.style.display = 'block';
|
||||
if (staticCalc) staticCalc.style.display = 'none';
|
||||
|
||||
const input = document.getElementById('calc-input');
|
||||
const result = document.getElementById('calc-result');
|
||||
const history = document.getElementById('calc-history');
|
||||
const buttons = document.querySelectorAll('.calc-buttons button');
|
||||
|
||||
let currentInput = '';
|
||||
let historyLog = [];
|
||||
|
||||
const updateUI = () => {
|
||||
input.value = currentInput;
|
||||
history.innerHTML = historyLog.map(entry => `<div>${entry}</div>`).join('');
|
||||
};
|
||||
|
||||
buttons.forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
const val = button.getAttribute('data-value');
|
||||
|
||||
if (val === 'C') {
|
||||
currentInput = '';
|
||||
} else if (val === '=') {
|
||||
try {
|
||||
const res = eval(currentInput);
|
||||
historyLog.push(`${currentInput} = ${res}`);
|
||||
if (historyLog.length > 30) historyLog.shift(); // Remove oldest
|
||||
currentInput = res.toString();
|
||||
} catch (e) {
|
||||
currentInput = 'Error';
|
||||
}
|
||||
} else {
|
||||
currentInput += val;
|
||||
}
|
||||
|
||||
updateUI();
|
||||
});
|
||||
});
|
||||
|
||||
updateUI();
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue