SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "index.html")
31 STORE("descrHdr", "calculator index.html")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "calculator.doc")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "15010253ebeb9f9293aa558b7f57417697ae95ed376827d930cf8ab808fa4657")
37 STORE("fileCheckS", "37303b417c7801531dbdccc58bc2fd16694f7f4216dac897a2252c7a45b7274")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/calculator.svg" type="image/svg">
<title>Calculator</title>
<style>
@media (prefers-color-scheme: dark) {
body {
background: #2c3e50 !important;
color: white !important;
}
.display {
background: black !important;
color: white !important;
}
}
html,
body {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
background: #2c3e50;
font-family: Arial, sans-serif;
margin: 0;
overflow: hidden;
}
.calculator {
width: 320px;
background: #1e272e;
padding: 20px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
border-radius: 15px;
display: flex;
flex-direction: column;
align-items: center;
}
.display {
box-sizing: border-box;
width: 100%;
height: 60px;
font-size: 2em;
text-align: right;
padding: 10px;
margin-bottom: 10px;
border: none;
background: white;
color: black;
border-radius: 8px;
cursor: pointer;
user-select: none;
transition: all 0.5s ease;
}
.copied-message {
display: none;
position: absolute;
top: 70px;
font-size: 1.2em;
color: white;
background-color: #7bed9f;
padding: 5px 15px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: opacity 0.5s ease;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(5, 60px);
gap: 10px;
width: 100%;
}
button {
width: 100%;
height: 100%;
font-size: 1.5em;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
filter: brightness(90%);
}
button.operator {
background: #1abc9c;
color: white;
}
button.clear {
background: #e74c3c;
color: white;
}
button.equal {
background: #f39c12;
color: white;
grid-row: span 2;
height: 130px;
}
button.number {
background: #3498db;
color: white;
}
button#zero {
grid-column: span 2;
}
</style>
</head>
<body>
<div class="calculator">
<div class="display-container">
<input type="text" class="display" id="display" readonly>
</div>
<div class="buttons">
<button onclick="clearDisplay(this)" class="clear">C</button>
<button onclick="appendValue(this, '/')" class="operator">/</button>
<button onclick="appendValue(this, '*')" class="operator">*</button>
<button onclick="deleteLast(this)">⌫</button>
<button onclick="appendValue(this, '7')">7</button>
<button onclick="appendValue(this, '8')">8</button>
<button onclick="appendValue(this, '9')">9</button>
<button onclick="appendValue(this, '-')" class="operator">-</button>
<button onclick="appendValue(this, '4')">4</button>
<button onclick="appendValue(this, '5')">5</button>
<button onclick="appendValue(this, '6')">6</button>
<button onclick="appendValue(this, '+')" class="operator">+</button>
<button onclick="appendValue(this, '1')">1</button>
<button onclick="appendValue(this, '2')">2</button>
<button onclick="appendValue(this, '3')">3</button>
<button onclick="calculateResult(this)" class="equal">=</button>
<button id="zero" onclick="appendValue(this, '0')">0</button>
<button onclick="appendValue(this, '.')">.</button>
</div>
</div>
<div class="copied-message" id="copiedMessage">Copied!</div>
<script>
const atomic_units = 5;
const one_deri = 0.00001;
function appendValue(button, value) {
document.getElementById("display").value += value;
if (button) button.blur(); // Remove focus from the button if it exists
}
function clearDisplay(button) {
document.getElementById("display").value = "";
if (button) button.blur(); // Remove focus from the button if it exists
}
function deleteLast(button) {
let display = document.getElementById("display");
display.value = display.value.slice(0, -1);
if (button) button.blur(); // Remove focus from the button if it exists
}
function calculateResult(button) {
try {
let expression = document.getElementById("display").value;
let result = eval(expression);
if (Math.abs(result) < one_deri) {
result = 0; // Use atomic_units decimal places in scientific notation
}
document.getElementById("display").value = parseFloat(result.toFixed(atomic_units));
} catch (error) {
console.log("Error:", error);
document.getElementById("display").value = "Error";
}
if (button) button.blur(); // Remove focus from the equal button if it exists
}
// Event listener for copying the result to the clipboard with enhanced visual feedback
document.getElementById("display").addEventListener("click", function () {
const result = document.getElementById("display").value;
if (result !== "Error" && result !== "") {
navigator.clipboard.writeText(result)
.then(() => {
// Visual feedback
const display = document.getElementById("display");
display.style.backgroundColor = "#7bed9f"; // Light green
display.style.transform = "scale(1.05)"; // Scale up
display.style.color = "#2d3436"; // Darker text
// Show the "Copied!" message
const copiedMessage = document.getElementById("copiedMessage");
copiedMessage.style.display = "block"; // Show the message
copiedMessage.style.opacity = "1"; // Ensure it's visible
// Reset after the animation
setTimeout(() => {
display.style.backgroundColor = "white"; // Reset background
display.style.transform = "scale(1)"; // Reset scale
display.style.color = "black"; // Reset text color
copiedMessage.style.opacity = "0"; // Fade out the "Copied!" message
}, 300);
})
.catch((err) => console.log("Error copying text: ", err));
}
});
// Keyboard shortcuts for calculator
document.addEventListener("keydown", function (event) {
const display = document.getElementById("display");
if (event.key >= '0' && event.key <= '9') {
appendValue(null, event.key); // Append the number
} else if (["+", "-", "*", "/", "."].includes(event.key)) {
appendValue(null, event.key); // Append the operator or decimal
} else if (event.key === 'Backspace') {
deleteLast(); // Delete the last character
} else if (event.key === 'Enter') {
calculateResult(); // Trigger result calculation
} else if (event.key.toLowerCase() === 'c') {
clearDisplay(); // Clear the display
}
});
</script>
</body>
</html>
*/ |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "index.html")
31 STORE("descrHdr", "calculator index.html")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "calculator.doc")
34 STORE("docType", "TELA-HTML-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "15010253ebeb9f9293aa558b7f57417697ae95ed376827d930cf8ab808fa4657")
37 STORE("fileCheckS", "37303b417c7801531dbdccc58bc2fd16694f7f4216dac897a2252c7a45b7274")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/calculator.svg" type="image/svg">
<title>Calculator</title>
<style>
@media (prefers-color-scheme: dark) {
body {
background: #2c3e50 !important;
color: white !important;
}
.display {
background: black !important;
color: white !important;
}
}
html,
body {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
background: #2c3e50;
font-family: Arial, sans-serif;
margin: 0;
overflow: hidden;
}
.calculator {
width: 320px;
background: #1e272e;
padding: 20px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
border-radius: 15px;
display: flex;
flex-direction: column;
align-items: center;
}
.display {
box-sizing: border-box;
width: 100%;
height: 60px;
font-size: 2em;
text-align: right;
padding: 10px;
margin-bottom: 10px;
border: none;
background: white;
color: black;
border-radius: 8px;
cursor: pointer;
user-select: none;
transition: all 0.5s ease;
}
.copied-message {
display: none;
position: absolute;
top: 70px;
font-size: 1.2em;
color: white;
background-color: #7bed9f;
padding: 5px 15px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: opacity 0.5s ease;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(5, 60px);
gap: 10px;
width: 100%;
}
button {
width: 100%;
height: 100%;
font-size: 1.5em;
border: none;
border-radius: 8px;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
filter: brightness(90%);
}
button.operator {
background: #1abc9c;
color: white;
}
button.clear {
background: #e74c3c;
color: white;
}
button.equal {
background: #f39c12;
color: white;
grid-row: span 2;
height: 130px;
}
button.number {
background: #3498db;
color: white;
}
button#zero {
grid-column: span 2;
}
</style>
</head>
<body>
<div class="calculator">
<div class="display-container">
<input type="text" class="display" id="display" readonly>
</div>
<div class="buttons">
<button onclick="clearDisplay(this)" class="clear">C</button>
<button onclick="appendValue(this, '/')" class="operator">/</button>
<button onclick="appendValue(this, '*')" class="operator">*</button>
<button onclick="deleteLast(this)">⌫</button>
<button onclick="appendValue(this, '7')">7</button>
<button onclick="appendValue(this, '8')">8</button>
<button onclick="appendValue(this, '9')">9</button>
<button onclick="appendValue(this, '-')" class="operator">-</button>
<button onclick="appendValue(this, '4')">4</button>
<button onclick="appendValue(this, '5')">5</button>
<button onclick="appendValue(this, '6')">6</button>
<button onclick="appendValue(this, '+')" class="operator">+</button>
<button onclick="appendValue(this, '1')">1</button>
<button onclick="appendValue(this, '2')">2</button>
<button onclick="appendValue(this, '3')">3</button>
<button onclick="calculateResult(this)" class="equal">=</button>
<button id="zero" onclick="appendValue(this, '0')">0</button>
<button onclick="appendValue(this, '.')">.</button>
</div>
</div>
<div class="copied-message" id="copiedMessage">Copied!</div>
<script>
const atomic_units = 5;
const one_deri = 0.00001;
function appendValue(button, value) {
document.getElementById("display").value += value;
if (button) button.blur(); // Remove focus from the button if it exists
}
function clearDisplay(button) {
document.getElementById("display").value = "";
if (button) button.blur(); // Remove focus from the button if it exists
}
function deleteLast(button) {
let display = document.getElementById("display");
display.value = display.value.slice(0, -1);
if (button) button.blur(); // Remove focus from the button if it exists
}
function calculateResult(button) {
try {
let expression = document.getElementById("display").value;
let result = eval(expression);
if (Math.abs(result) < one_deri) {
result = 0; // Use atomic_units decimal places in scientific notation
}
document.getElementById("display").value = parseFloat(result.toFixed(atomic_units));
} catch (error) {
console.log("Error:", error);
document.getElementById("display").value = "Error";
}
if (button) button.blur(); // Remove focus from the equal button if it exists
}
// Event listener for copying the result to the clipboard with enhanced visual feedback
document.getElementById("display").addEventListener("click", function () {
const result = document.getElementById("display").value;
if (result !== "Error" && result !== "") {
navigator.clipboard.writeText(result)
.then(() => {
// Visual feedback
const display = document.getElementById("display");
display.style.backgroundColor = "#7bed9f"; // Light green
display.style.transform = "scale(1.05)"; // Scale up
display.style.color = "#2d3436"; // Darker text
// Show the "Copied!" message
const copiedMessage = document.getElementById("copiedMessage");
copiedMessage.style.display = "block"; // Show the message
copiedMessage.style.opacity = "1"; // Ensure it's visible
// Reset after the animation
setTimeout(() => {
display.style.backgroundColor = "white"; // Reset background
display.style.transform = "scale(1)"; // Reset scale
display.style.color = "black"; // Reset text color
copiedMessage.style.opacity = "0"; // Fade out the "Copied!" message
}, 300);
})
.catch((err) => console.log("Error copying text: ", err));
}
});
// Keyboard shortcuts for calculator
document.addEventListener("keydown", function (event) {
const display = document.getElementById("display");
if (event.key >= '0' && event.key <= '9') {
appendValue(null, event.key); // Append the number
} else if (["+", "-", "*", "/", "."].includes(event.key)) {
appendValue(null, event.key); // Append the operator or decimal
} else if (event.key === 'Backspace') {
deleteLast(); // Delete the last character
} else if (event.key === 'Enter') {
calculateResult(); // Trigger result calculation
} else if (event.key.toLowerCase() === 'c') {
clearDisplay(); // Clear the display
}
});
</script>
</body>
</html>
*/'] |