Note Box
|
Attaches an extra box on the current web page for you to take notes
conveniently. The code is copied verbatim below for easily seeing what happens:
(function(){
var d = document.createElement('div');
d.setAttribute('id', 'sorno-extra-box');
d.innerHTML = '<textarea cols=50 rows=10 id="sorno-extra-box-textarea"></textarea><br /><button id="sorno-extra-box-button" style="float:right">Remove</button>';
d.style.position = 'fixed';
d.style.right = 0;
d.style.top = 0;
d.style.border = '1px solid black';
d.style.zIndex = '999';
document.body.appendChild(d);
var sorno_extra_box_destroy = function() {d.parentElement.removeChild(d);};
document.getElementById('sorno-extra-box-button').onclick=sorno_extra_box_destroy;
var sorno_extra_box_textarea = document.getElementById('sorno-extra-box-textarea');
sorno_extra_box_textarea.onkeyup = function(e) {
if (e.target.value) {
localStorage.setItem('sorno-extra-box-stored-text', e.target.value);
} else {
localStorage.removeItem('sorno-extra-box-stored-text');
}
};
var stored_text = localStorage.getItem('sorno-extra-box-stored-text');
if (stored_text) {
sorno_extra_box_textarea.appendChild(document.createTextNode(stored_text));
} else {
sorno_extra_box_textarea.placeholder = "Enter your notes"
}
sorno_extra_box_textarea.focus();
})()
|
Date appender
|
Append a date to your text
var text = prompt("Put your text here to be appended by a date like: " + new Date().toLocaleString());
var d = new Date().toLocaleString();
var appended = text + ' ' + d;
var d = document.createElement('div');
d.setAttribute('id', 'sorno-appended-output');
var textarea_html = '<textarea cols=40 rows=3 id="sorno-appended-output-textarea"></textarea>';
var remove_button_html = '<button id="sorno-appended-output-remove-button" style="float:right">Remove</button>';
d.innerHTML = textarea_html + "<br />" + remove_button_html;
d.style.position = 'fixed';
d.style.right = 0;
d.style.top = 0;
d.style.border = '1px solid black';
d.style.zIndex = '999';
document.body.appendChild(d);
var sorno_appended_output_destroy = function() {d.parentElement.removeChild(d);};
document.getElementById('sorno-appended-output-remove-button').onclick = sorno_appended_output_destroy;
var sorno_appended_output_textarea = document.getElementById('sorno-appended-output-textarea');
sorno_appended_output_textarea.value = appended + " (Click anywhere in this box to copy the text, and this will disappear)";
var copy_on_click = function(e) {
e.preventDefault();
if (!e.clipboardData) {
alert('e.clipboardData is not present, copy this yourself!');
return;
}
e.clipboardData.setData('text/plain', appended);
sorno_appended_output_destroy();
};
sorno_appended_output_textarea.onclick = function() {;document.execCommand('copy');};
sorno_appended_output_textarea.addEventListener('copy', copy_on_click);
|