From a3fe970e7cde5731070a51d2f7c0a6c5f0d01f88 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Thu, 21 Jul 2011 20:16:52 -0500 Subject: [PATCH] moved formData.append calls BEFORE sending formData.... doh! --- js/common.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/js/common.js b/js/common.js index a95b759..23d544f 100644 --- a/js/common.js +++ b/js/common.js @@ -464,15 +464,12 @@ RedditAPI.prototype.voteUpPost = function (e) { function success () { if (voteWas === '1') { - formData.append('dir','0'); listItem.setAttribute('data-dir','0'); oldCache.posts[fullName].data.likes = null; } else if (voteWas === '0') { - formData.append('dir','1'); listItem.setAttribute('data-dir','1'); oldCache.posts[fullName].data.likes = true; } else if (voteWas === '-1') { - formData.append('dir','1'); listItem.setAttribute('data-dir','1'); oldCache.posts[fullName].data.likes = true; } @@ -489,6 +486,15 @@ RedditAPI.prototype.voteUpPost = function (e) { formData = new FormData(); formData.append('id', fullName); formData.append('uh', cache.get('modhash')); + + if (voteWas === '1') { + formData.append('dir','0'); + } else if (voteWas === '0') { + formData.append('dir','1'); + } else if (voteWas === '-1') { + formData.append('dir','1'); + } + this.apiTransmit('POST', reqUrl, formData, success); }; @@ -504,15 +510,12 @@ RedditAPI.prototype.voteDownPost = function (e) { function success () { if (voteWas === '1') { - formData.append('dir','-1'); listItem.setAttribute('data-dir','-1'); oldCache.posts[fullName].data.likes = false; } else if (voteWas === '0') { - formData.append('dir','-1'); listItem.setAttribute('data-dir','-1'); oldCache.posts[fullName].data.likes = false; } else if (voteWas === '-1') { - formData.append('dir','0'); listItem.setAttribute('data-dir','0'); oldCache.posts[fullName].data.likes = null; } @@ -529,6 +532,15 @@ RedditAPI.prototype.voteDownPost = function (e) { formData = new FormData(); formData.append('id', fullName); formData.append('uh', cache.get('modhash')); + + if (voteWas === '1') { + formData.append('dir','-1'); + } else if (voteWas === '0') { + formData.append('dir','-1'); + } else if (voteWas === '-1') { + formData.append('dir','0'); + } + this.apiTransmit('POST', reqUrl, formData, success); };