more efficient javascript remembering system
This commit is contained in:
parent
25e77ae425
commit
c4913ab883
61
main.js
61
main.js
|
@ -51,7 +51,7 @@ function citeReply(id) {
|
||||||
document.getElementById('body').value += '>>' + id + '\n';
|
document.getElementById('body').value += '>>' + id + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedstyle = 'Yotsuba';
|
var selectedstyle = 'Yotsuba B';
|
||||||
var styles = [
|
var styles = [
|
||||||
['Yotsuba B', '/board/default.css'],
|
['Yotsuba B', '/board/default.css'],
|
||||||
['Yotsuba', '/board/yotsuba.css']
|
['Yotsuba', '/board/yotsuba.css']
|
||||||
|
@ -73,37 +73,16 @@ if(localStorage.stylesheet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init()
|
function rememberStuff() {
|
||||||
{
|
if(document.forms.post) {
|
||||||
newElement = document.createElement('div');
|
|
||||||
newElement.className = 'styles';
|
|
||||||
|
|
||||||
for(x=0;x<styles.length;x++) {
|
|
||||||
style = document.createElement('a');
|
|
||||||
style.innerHTML = '[' + styles[x][0] + ']';
|
|
||||||
style.href = 'javascript:changeStyle(' + x + ');';
|
|
||||||
if(selectedstyle == styles[x][0])
|
|
||||||
style.className = 'selected';
|
|
||||||
newElement.appendChild(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild)
|
|
||||||
|
|
||||||
if(!localStorage.password)
|
if(!localStorage.password)
|
||||||
localStorage.password = generatePassword();
|
localStorage.password = generatePassword();
|
||||||
if(document.forms.delete) {
|
document.forms.post.password.value = localStorage.password;
|
||||||
document.forms.delete.password.value = localStorage.password;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.location.hash.indexOf('q') == 1)
|
|
||||||
citeReply(window.location.hash.substring(2));
|
|
||||||
else if (window.location.hash.substring(1))
|
|
||||||
highlightReply(window.location.hash.substring(1));
|
|
||||||
if(localStorage.name)
|
if(localStorage.name)
|
||||||
document.getElementsByTagName('form')[0].name.value = localStorage.name;
|
document.forms.post.name.value = localStorage.name;
|
||||||
if(localStorage.email)
|
if(localStorage.email)
|
||||||
document.getElementsByTagName('form')[0].email.value = localStorage.email;
|
document.forms.post.email.value = localStorage.email;
|
||||||
|
|
||||||
|
|
||||||
if(sessionStorage.body) {
|
if(sessionStorage.body) {
|
||||||
saved = JSON.parse(sessionStorage.body);
|
saved = JSON.parse(sessionStorage.body);
|
||||||
|
@ -126,6 +105,34 @@ function init()
|
||||||
document.getElementsByTagName('form')[0].body.value = localStorage.body;
|
document.getElementsByTagName('form')[0].body.value = localStorage.body;
|
||||||
localStorage.body = '';
|
localStorage.body = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init()
|
||||||
|
{
|
||||||
|
newElement = document.createElement('div');
|
||||||
|
newElement.className = 'styles';
|
||||||
|
|
||||||
|
for(x=0;x<styles.length;x++) {
|
||||||
|
style = document.createElement('a');
|
||||||
|
style.innerHTML = '[' + styles[x][0] + ']';
|
||||||
|
style.href = 'javascript:changeStyle(' + x + ');';
|
||||||
|
if(selectedstyle == styles[x][0])
|
||||||
|
style.className = 'selected';
|
||||||
|
newElement.appendChild(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild)
|
||||||
|
|
||||||
|
if(document.forms.delete) {
|
||||||
|
document.forms.delete.password.value = localStorage.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.location.hash.indexOf('q') == 1)
|
||||||
|
citeReply(window.location.hash.substring(2));
|
||||||
|
else if (window.location.hash.substring(1))
|
||||||
|
highlightReply(window.location.hash.substring(1));
|
||||||
|
|
||||||
link = document.getElementsByTagName('a');
|
link = document.getElementsByTagName('a');
|
||||||
for ( i in link ) {
|
for ( i in link ) {
|
||||||
if(typeof link[i] == "object" && link[i].childNodes[0].src) {
|
if(typeof link[i] == "object" && link[i].childNodes[0].src) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="title">{board[title]?{board[title]}}<p>{mod?<a href="?/">Return to dashboard</a>}</p></div>
|
<div class="title">{board[title]?{board[title]}}<p>{mod?<a href="?/">Return to dashboard</a>}</p></div>
|
||||||
|
|
||||||
|
|
||||||
<form onsubmit="return dopost(this);" enctype="multipart/form-data" action="{config[post_url]}" method="post">
|
<form name="post" onsubmit="return dopost(this);" enctype="multipart/form-data" action="{config[post_url]}" method="post">
|
||||||
{hidden_inputs}
|
{hidden_inputs}
|
||||||
<input type="hidden" name="board" value="{board[uri]}" />
|
<input type="hidden" name="board" value="{board[uri]}" />
|
||||||
{mod?<input type="hidden" name="mod" value="1" />}
|
{mod?<input type="hidden" name="mod" value="1" />}
|
||||||
|
@ -96,6 +96,9 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
<script type="text/javascript">
|
||||||
|
rememberStuff();
|
||||||
|
</script>
|
||||||
<hr/>
|
<hr/>
|
||||||
<form name="delete" action="{post_url}" method="post">
|
<form name="delete" action="{post_url}" method="post">
|
||||||
<input type="hidden" name="board" value="{board[uri]}" />
|
<input type="hidden" name="board" value="{board[uri]}" />
|
||||||
|
|
|
@ -73,37 +73,16 @@ if(localStorage.stylesheet) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init()
|
function rememberStuff() {
|
||||||
{
|
if(document.forms.post) {
|
||||||
newElement = document.createElement('div');
|
|
||||||
newElement.className = 'styles';
|
|
||||||
|
|
||||||
for(x=0;x<styles.length;x++) {
|
|
||||||
style = document.createElement('a');
|
|
||||||
style.innerHTML = '[' + styles[x][0] + ']';
|
|
||||||
style.href = 'javascript:changeStyle(' + x + ');';
|
|
||||||
if(selectedstyle == styles[x][0])
|
|
||||||
style.className = 'selected';
|
|
||||||
newElement.appendChild(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild)
|
|
||||||
|
|
||||||
if(!localStorage.password)
|
if(!localStorage.password)
|
||||||
localStorage.password = generatePassword();
|
localStorage.password = generatePassword();
|
||||||
if(document.forms.delete) {
|
document.forms.post.password.value = localStorage.password;
|
||||||
document.forms.delete.password.value = localStorage.password;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.location.hash.indexOf('q') == 1)
|
|
||||||
citeReply(window.location.hash.substring(2));
|
|
||||||
else if (window.location.hash.substring(1))
|
|
||||||
highlightReply(window.location.hash.substring(1));
|
|
||||||
if(localStorage.name)
|
if(localStorage.name)
|
||||||
document.getElementsByTagName('form')[0].name.value = localStorage.name;
|
document.forms.post.name.value = localStorage.name;
|
||||||
if(localStorage.email)
|
if(localStorage.email)
|
||||||
document.getElementsByTagName('form')[0].email.value = localStorage.email;
|
document.forms.post.email.value = localStorage.email;
|
||||||
|
|
||||||
|
|
||||||
if(sessionStorage.body) {
|
if(sessionStorage.body) {
|
||||||
saved = JSON.parse(sessionStorage.body);
|
saved = JSON.parse(sessionStorage.body);
|
||||||
|
@ -126,6 +105,34 @@ function init()
|
||||||
document.getElementsByTagName('form')[0].body.value = localStorage.body;
|
document.getElementsByTagName('form')[0].body.value = localStorage.body;
|
||||||
localStorage.body = '';
|
localStorage.body = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init()
|
||||||
|
{
|
||||||
|
newElement = document.createElement('div');
|
||||||
|
newElement.className = 'styles';
|
||||||
|
|
||||||
|
for(x=0;x<styles.length;x++) {
|
||||||
|
style = document.createElement('a');
|
||||||
|
style.innerHTML = '[' + styles[x][0] + ']';
|
||||||
|
style.href = 'javascript:changeStyle(' + x + ');';
|
||||||
|
if(selectedstyle == styles[x][0])
|
||||||
|
style.className = 'selected';
|
||||||
|
newElement.appendChild(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild)
|
||||||
|
|
||||||
|
if(document.forms.delete) {
|
||||||
|
document.forms.delete.password.value = localStorage.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.location.hash.indexOf('q') == 1)
|
||||||
|
citeReply(window.location.hash.substring(2));
|
||||||
|
else if (window.location.hash.substring(1))
|
||||||
|
highlightReply(window.location.hash.substring(1));
|
||||||
|
|
||||||
link = document.getElementsByTagName('a');
|
link = document.getElementsByTagName('a');
|
||||||
for ( i in link ) {
|
for ( i in link ) {
|
||||||
if(typeof link[i] == "object" && link[i].childNodes[0].src) {
|
if(typeof link[i] == "object" && link[i].childNodes[0].src) {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<div class="title">{board[title]?{board[title]}}<p>{mod?<a href="?/">Return to dashboard</a>}</p></div>
|
<div class="title">{board[title]?{board[title]}}<p>{mod?<a href="?/">Return to dashboard</a>}</p></div>
|
||||||
|
|
||||||
<div class="banner">Posting mode: Reply <a class="unimportant" href="{return}">[Return.]</a></div>
|
<div class="banner">Posting mode: Reply <a class="unimportant" href="{return}">[Return.]</a></div>
|
||||||
<form onsubmit="return dopost(this);" enctype="multipart/form-data" action="{config[post_url]}" method="post">{hidden_inputs}
|
<form name="post" onsubmit="return dopost(this);" enctype="multipart/form-data" action="{config[post_url]}" method="post">{hidden_inputs}
|
||||||
<input type="hidden" name="thread" value="{id}" />
|
<input type="hidden" name="thread" value="{id}" />
|
||||||
<input type="hidden" name="board" value="{board[uri]}" />
|
<input type="hidden" name="board" value="{board[uri]}" />
|
||||||
{mod?<input type="hidden" name="mod" value="1" />}
|
{mod?<input type="hidden" name="mod" value="1" />}
|
||||||
|
@ -87,6 +87,9 @@
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
<script type="text/javascript">
|
||||||
|
rememberStuff();
|
||||||
|
</script>
|
||||||
<hr/>
|
<hr/>
|
||||||
<form name="delete" action="{config[post_url]}" method="post">
|
<form name="delete" action="{config[post_url]}" method="post">
|
||||||
<input type="hidden" name="board" value="{board[uri]}" />
|
<input type="hidden" name="board" value="{board[uri]}" />
|
||||||
|
|
Loading…
Reference in New Issue