diff --git a/css/popup.css b/css/popup.css
index b242558..ff47904 100644
--- a/css/popup.css
+++ b/css/popup.css
@@ -129,6 +129,18 @@ li[data-dir='-1'] .downmod {
#posts li[data-hidestatus="true"] .actions a.hide {
color: #000;
}
+#posts li[data-reportstatus="true"] {
+ opacity: 0.25;
+ background: rgba(255, 0, 0, 0.25);
+}
+.actions .report-confirm {
+ font-weight:normal;
+ color:#f00;
+}
+.actions .report-confirm:hover {
+ text-decoration:none;
+ cursor: default;
+}
.morelink {
display:block;
text-align:center;
diff --git a/js/common.js b/js/common.js
index f928ae3..1c3677b 100644
--- a/js/common.js
+++ b/js/common.js
@@ -479,6 +479,62 @@ RedditAPI.prototype.unhidePost = function (e) {
this.apiTransmit('POST', reqUrl, false, formData);
};
+/**
+ * Brings up the report confirmation dialog.
+ * @alias RedditAPI.confirmReport(event)
+ * @param {Object} event The event object.
+ * @return {Boolean} Returns true.
+ * @method
+ */
+RedditAPI.prototype.confirmReport = function (e) {
+ e.srcElement.className = 'report-confirm';
+ e.srcElement.removeAttribute('onclick');
+ e.srcElement.innerHTML = 'are you sure? yes/no';
+ return true;
+};
+
+/**
+ * Resets the report link.
+ * @alias RedditAPI.denyReport(event)
+ * @param {Object} event The event object.
+ * @return {Boolean} Returns true.
+ * @method
+ */
+RedditAPI.prototype.denyReport = function (e) {
+ e.srcElement.parentNode.className = 'report';
+ e.srcElement.parentNode.setAttribute('onclick', 'reddit.confirmReport(event)');
+ e.srcElement.parentNode.innerHTML = 'report';
+ return true;
+};
+
+/**
+ * Reports a post.
+ * @alias RedditAPI.reportPost(event)
+ * @param {Object} event The event object.
+ * @return {Boolean} Returns true.
+ * @method
+ */
+RedditAPI.prototype.reportPost = function (e) {
+ var listItem, fullName, url, reqUrl, oldCache, formData;
+
+ listItem = e.srcElement.parentNode.parentNode.parentNode.parentNode;
+ fullName = listItem.id;
+ url = listItem.parentNode.getAttribute('data-url');
+ reqUrl = 'http://' + this.domain + '/api/report';
+ oldCache = cache.get(url);
+ formData = new FormData();
+ formData.append('id', fullName);
+ formData.append('uh', cache.get('modhash'));
+ this.apiTransmit('POST', reqUrl, false, formData);
+ listItem.setAttribute('data-hidestatus', 'true');
+ e.srcElement.parentNode.parentNode.childNodes[3].innerHTML = 'unhide';
+ e.srcElement.parentNode.parentNode.childNodes[3].onclick = function (event) {reddit.unhidePost(event)};
+ oldCache.posts[fullName].data.hidden = true;
+ cache.set(url, oldCache);
+ listItem.setAttribute('data-reportstatus', 'true');
+ e.srcElement.parentNode.innerHTML = 'reported!';
+};
+
reddit = new RedditAPI('www.reddit.com');
/**
@@ -586,7 +642,7 @@ Popup.prototype.createListHTML = function (url) {
listHTML += 'share';
listHTML += '' + saveText + '';
listHTML += '' + hiddenText + '';
- listHTML += 'report';
+ listHTML += 'report';
listHTML += '';
listHTML += ''
listHTML += '';
@@ -601,3 +657,14 @@ Popup.prototype.createListHTML = function (url) {
return listHTML;
};
+
+/**
+ * Create the HTML for a submission form.
+ * @alias Popup.createSubmitForm(url)
+ * @param {String} url The URL of the page to create the HTML for.
+ * @return {String} Returns the generated Form.
+ * @method
+ */
+Popup.prototype.createSubmitForm = function (url) {
+ return 'Submit form not yet programmed.';
+}