Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

DU2 Bug Fix

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
Home » Discuss » General Discussion Donate to DU
 
Leopolds Ghost Donating Member (1000+ posts) Send PM | Profile | Ignore Fri Dec-21-12 08:04 AM
Original message
DU2 Bug Fix
Note: this is for display purposes. DU post contains extra characters, so cutting and pasting won't work.

I can post the raw .js file if someone has a place to put it.

This script works...

Getting duboard.php to display remote links to avatars and signature lines
via userscript is just a little beyond my skill set.





*/ remove this line

// written by Leopolds Ghost January 2012

// eliminates "an error occurred" screen and redirects to the correct thread

// ==UserScript==
// @name ......... DU2 Bug Fix
// @namespace .... democraticunderground.com
// @description .. bug fix
// @include ...... http://www.democraticunderground.com/ discuss/duboard.php
// @include ...... http://www.democraticunderground.com/ discuss/duboard.php?az=post*
// ==/UserScript==

function checkCurrTags() {

var currURL = location.href;
var oldURL = document.referrer;


//is it an az=post page?

if ( currURL.indexOf("az=post") != -1 ) {

//if yes:

//debug-- alert("az=post");

var redirectTags;
var azN, frN, tpN, mgN;
var azName = document.getElementsByName("az");
var frName = document.getElementsByName("forum");
var tpName = document.getElementsByName("topic_id");
var mgName = document.getElementsByName("mesg_id");

azN = azName<0>.value;
frN = frName<0>.value;
tpN = tpName<0>.value;
mgN = mgName<0>.value;

if ( typeof azName<0> === 'undefined' ) { azN = ""; }
.. else { azN = azName<0>.value; }
if ( typeof frName<0> === 'undefined' ) { frN = ""; }
.. else { frN = frName<0>.value; }
if ( typeof tpName<0> === 'undefined' ) { tpN = ""; }
.. else { tpN = tpName<0>.value; }
if ( typeof mgName<0> === 'undefined' ) { mgN = ""; }
.. else { mgN = mgName<0>.value; }

// is it a new thread, then redirect to forum top

if ( azN == "post" && tpN == "" ) {

redirectTags = "az=show_topics&forum="+frN; } else {

redirectTags = "az=view_all&address="+frN+"x"+tpN+"#"+mgN; }

// . set cookie (az, post info)

bakeCupcake("occupyDU2",redirectTags);

}

//if no:

else { checkErrMsg(oldURL); }

}

// ----

function checkErrMsg(lastURL) {

var returnThread;
var containsTags;
var noTags;

containsTags = document.getElementsByTagName("table");

if ( typeof containsTags<0> === 'undefined' || containsTags == -1 ) { noTags = -1; }
.... else { noTags = 1; }

//debug-- alert("Document contains tags = "+noTags);

returnThread = location.href;

// . does it contain error message and no html?

if ( retrieveErrorMsg() != -1 && noTags == -1 ) {

// . if yes:

// . is previous page an az=post page?

.... if ( lastURL.indexOf("az=post") != -1 ) {

// .... if yes:

....... returnThread = redirFromPrev(lastURL);

// ....... construct redirect link from az=post

....... } else {

// .... if no:

....... returnThread = redirFromCookie();

// ....... construct redirect link from cookie (post info)

...... }

// ... erase cookie (az, post info)

...... eraseCupcake("occupyDU2");

// ... return redirect

..... if (returnThread != location.href) {

//debug-- ..... alert("return to... "+returnThread);

...... backtoThread(returnThread); }

//debug-- .. } else { alert("not an error page");

} }

// -------------------

checkCurrTags();

// call entire script

// -------------------

// Sub routines:

// External untyped page content into a layer

function retrieveErrorMsg() {

.var srcContent, errorMsg;
.srcContent = document.getElementsByTagName("BODY")<0>.innerHTML;
.errorMsg = srcContent.indexOf("An error occurred");
.//debug-- alert("Error Message From Source = "+errorMsg);
.return errorMsg;

}

// ------

function redirFromPrev(anyURL) {

// ....... construct redirect link from az=post

//debug--. alert("post page URL = "+anyURL);

if ( anyURL.indexOf("az=post") != -1 && anyURL.indexOf("topic_id=") != -1) {

.. anyURL = anyURL.replace("az=post", "az=view_all");
.. anyURL = anyURL.replace("forum=", "address=");
.. anyURL = anyURL.replace("&topic_id=", "x");
.. anyURL = anyURL.replace("mesg_id=", "#");

} else if ( anyURL.indexOf("az=post") != -1 && anyURL.indexOf("topic_id=") == -1) {

.. anyURL = anyURL.replace("az=post", "az=show_topics");

} else {

.. anyURL = "http://www.democraticunderground.com/ discuss/duboard.php"

.. alert("Error: forum syntax not specified");
}

// ....... return redirect link

//debug--. alert("new URL = "+anyURL);

.. return anyURL;

}

// ------

function redirFromCookie() {

var redirLink;

// ....... retrieve cookie (post info)

var cupcake = findCupcake("occupyDU2");

// ....... construct redirect link

if ( typeof cupcake === 'undefined' || cupcake == -1 ) {
.... alert("Error: Occupy DU2 bug fix cookie is undefined");
.... redirLink = "http://www.democraticunderground.com/ discuss/duboard.php"
.... } else {

//debug-- alert("Cookie data = "+cupcake);

redirLink = "http://www.democraticunderground.com/ discuss/duboard.php?"+cupcake; }

// ....... return redirect link

return redirLink;

}

// ------

function backtoThread(lastThread) {

window.location = lastThread;

// complete script objective

}

// --------------

// Occupy DU2 Last Thread Cookie

function bakeCupcake(name,value) {
....... document.cookie = name+"="+value+"; domain=democraticunderground.com; path=/discuss/duboard.php";
}

function findCupcake(name) {
....... var nameEQ = name + "=";
....... var cb, cd, c;
....... cd = "";
....... var ca = document.cookie.split(';');
....... for(var i=0;i < ca.length;i++) {
............... c = ca< i>;
............... while (c.charAt(0)==' ') c = c.substring(1,c.length);
............... if (c.indexOf(nameEQ) == 0) { cd = c.substring(nameEQ.length,c.length);

//debug-- alert("cookie data = "+cd);

............... }
....... }

if ( cd == "" ) { alert("Occupy DU2 cookie lookup error"); return cd; } else { return cd; }

}

function eraseCupcake(name) {
......... bakeCupcake(name,"",-1);
}

// -------------- end of user script

/* remove this line
Refresh | +1 Recommendations Printer Friendly | Permalink | Reply | Top
No Elephants Donating Member (1000+ posts) Send PM | Profile | Ignore Fri Dec-21-12 11:03 AM
Response to Original message
1. Thanks, Leo
Nice to see you!
Printer Friendly | Permalink | Reply | Top
 
Leopolds Ghost Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Dec-22-12 04:41 AM
Response to Original message
2. You guys need it? Or is the posting mechanism working for you?
Without the bug fix I get "an error occurred and your post did not go thru." Even though it did. So all the userscript does is redirect you back to the appropriate thread.

If any of you are having problems with that I can PM you a link to the script as a text .js file and tell you how to install it on your browser.
Printer Friendly | Permalink | Reply | Top
 
Leopolds Ghost Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Dec-29-12 07:17 AM
Response to Original message
3. Can somebody (preferably more than one) reply and say whether the posting mechanism is working?
For you?

Or is it delivering an error when you post?

And if so do you want this patch? :think:
Printer Friendly | Permalink | Reply | Top
 
No Elephants Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Dec-29-12 09:44 AM
Response to Reply #3
4. Leo, thanks for your efforts. Your skill set in this is way above mine.
I am lucky if I can type a legible post. Even if the stuff in the OP were a copy and paste, I'd still have no idea where to paste it.

For me, it is okay, though. I just backspace a couple of times after I post. I don't find that a huge deal.


I hope someone else can use your fix, though.

Whether they can or not, I am sure everyone appreciates your giving it to us.
Printer Friendly | Permalink | Reply | Top
 
No Elephants Donating Member (1000+ posts) Send PM | Profile | Ignore Sat Dec-29-12 09:46 AM
Response to Reply #3
5. Test
Printer Friendly | Permalink | Reply | Top
 
Leopolds Ghost Donating Member (1000+ posts) Send PM | Profile | Ignore Sun Dec-30-12 05:38 AM
Response to Original message
6. No Elephants, others -- I will post the file and give the link to anyone who requests it.
Edited on Sun Dec-30-12 05:39 AM by Leopolds Ghost
1. Go to http://pastebin.com/raw.php?i=k2dkseMN

2. Right-click on the page (or the following link) and "Save as"

du2_bug_fix.user.js

3. Under the help section of your browser, search for "user scripts". If that fails,
google how do I user scripts + the name of your browser

4. If your browser has a Preferences Panel set up to allow user scripts,
then you should be able to take the file and install it by dragging it into the panel.

5. If your browser is Firefox and you have no user scripts built-in panel,
you can install the greasemonkey plugin.

6. More information

downloaded userscripts allow you to tailor the appearance of specific websites

http://userscripts.org/about/installing

http://www.greasespot.net/

User scripts and add-ons (browser plugins) also allow you to
adblock, etc. Be careful, though: only install trusted addons.
Printer Friendly | Permalink | Reply | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Sun May 26th 2024, 01:45 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » General Discussion Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC