Skip to content
This repository has been archived by the owner on Jun 8, 2018. It is now read-only.

Commit

Permalink
Remember password used when posting
Browse files Browse the repository at this point in the history
  • Loading branch information
tslocum committed Oct 28, 2014
1 parent 8848022 commit 16a87d6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions inc/html.php
Expand Up @@ -304,7 +304,7 @@ function buildPage($htmlposts, $parent, $pages = 0, $thispage = 0) {
Password
</td>
<td>
<input type="password" name="password" size="8" accesskey="p">&nbsp;(for post and file deletion)
<input type="password" name="password" id="newpostpassword" size="8" accesskey="p">&nbsp;(for post and file deletion)
</td>
</tr>
<tr>
Expand Down Expand Up @@ -332,7 +332,7 @@ function buildPage($htmlposts, $parent, $pages = 0, $thispage = 0) {
<tbody>
<tr>
<td>
Delete Post <input type="password" name="password" size="8" placeholder="Password">&nbsp;<input name="deletepost" value="Delete" type="submit">
Delete Post <input type="password" name="password" id="deletepostpassword" size="8" placeholder="Password">&nbsp;<input name="deletepost" value="Delete" type="submit">
</td>
</tr>
</tbody>
Expand Down
44 changes: 38 additions & 6 deletions js/tinyib.js
@@ -1,18 +1,50 @@
function quotePost(postID){
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}

function storePassword() {
var newpostpassword = document.getElementById("newpostpassword");
if (newpostpassword) {
var expiration_date = new Date();
expiration_date.setFullYear(expiration_date.getFullYear() + 7);
document.cookie = "tinyib_password=" + encodeURIComponent(newpostpassword.value) + "; path=/; expires=" + expiration_date.toGMTString();
}
}

function quotePost(postID) {
var message_element = document.getElementById("message");
if (message_element){
if (message_element) {
message_element.focus();
message_element.value += '>>' + postID + "\n";
}

return false;
}

document.addEventListener('DOMContentLoaded', function() {
if(window.location.hash){
if(window.location.hash.match(/^#q[0-9]+$/i) !== null){
document.addEventListener('DOMContentLoaded', function () {
var newpostpassword = document.getElementById("newpostpassword");
if (newpostpassword) {
newpostpassword.addEventListener("change", storePassword);
}

var password = getCookie("tinyib_password");
if (password && password != "") {
if (newpostpassword) {
newpostpassword.value = password;
}

var deletepostpassword = document.getElementById("deletepostpassword");
if (deletepostpassword) {
deletepostpassword.value = password;
}
}

if (window.location.hash) {
if (window.location.hash.match(/^#q[0-9]+$/i) !== null) {
var quotePostID = window.location.hash.match(/^#q[0-9]+$/i)[0].substr(2);
if (quotePostID != ''){
if (quotePostID != '') {
quotePost(quotePostID);
}
}
Expand Down

0 comments on commit 16a87d6

Please sign in to comment.