Skip to content

Commit

Permalink
Add BBCode and post submission keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Merrell committed Oct 24, 2018
1 parent e98e290 commit d6be485
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion html/error/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<h1>404: File not found</h1>
<img src="/error/lol 404.gif" border="0" alt="">
<p>The requested file could not be found on this server. Are you just typing random stuff in the address bar? If you followed a link from this site here, then post <a href="/site">here</a></p>
<hr><address>http://gochan.org powered by Gochan v2.0.0</address>
<hr><address>http://gochan.org powered by Gochan v2.2.0</address>
</body>
</html>
2 changes: 1 addition & 1 deletion html/error/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<h1>500: Internal Server error</h1>
<img src="/error/derpy server.gif" border="0" alt="">
<p>The server encountered an error while trying to serve the page, and we apologize for the inconvenience. The <a href="https://en.wikipedia.org/wiki/Idiot">system administrator</a> will try to fix things as soon has he/she/it can.</p>
<hr><address>http://gochan.org powered by Gochan v2.0.0</address>
<hr><address>http://gochan.org powered by Gochan v2.2.0</address>
</body>
</html>
42 changes: 42 additions & 0 deletions html/javascript/gochan.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,48 @@ function reportPost(id) {
var reason = prompt("Reason (this doesn't do anything yet)");
}

$jq(document).keydown(function(e) {
var tag;
if(e.ctrlKey) {
switch(e.keyCode) {
case 10: // Enter key
if(e.target.nodeName == "TEXTAREA")
document.getElementById("postform").submit();
break;
case 13: // Enter key in Chrome/IE
if(e.target.nodeName == "TEXTAREA")
document.getElementById("postform").submit();
break;
case 66: // B
tag = "b"; // bold
break;
case 73: // I
tag = "i"; // italics
break;
case 82: // R
tag = "s"; // strikethrough
break;
case 83:
tag = "?"; // spoiler (not yet implemented)
break;
case 85: // U
tag = "u"; // underlinee
break;
}
}

if (tag != null && e.target.nodeName == "TEXTAREA") {
e.preventDefault();
var ta = e.target;
var val = ta.value;
var ss = ta.selectionStart;
var se = ta.selectionEnd;
var r = se + 2 + tag.length;
ta.value = val.slice(0, ss) + ("[" + tag + "]") + val.slice(ss, se) + ("[/" + tag + "]") + val.slice(se);
ta.setSelectionRange(r, r);
}
});

$jq(document).ready(function() {
board = location.pathname.substring(1,location.pathname.indexOf("/",1))
current_staff = getStaff()
Expand Down
2 changes: 1 addition & 1 deletion templates/postbox.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{define "postbox.html"}}
<div id="postbox-area">
<form name="postform" action="/post" method="POST" enctype="multipart/form-data">
<form id="postform" name="postform" action="/post" method="POST" enctype="multipart/form-data">
{{with .op}}<input type="hidden" name="threadid" value="{{$.op.ID}}" />
<input type="hidden" name="boardid" value="{{$.board.ID}}" />
{{else}}<input type="hidden" name="threadid" value="0" />
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0

0 comments on commit d6be485

Please sign in to comment.