Jump to content

Add instant quest hiding on click for Quests List page.


GrandZephyr

Recommended Posts

May I suggest functionality for the quests page similar to what is achieved using this Greasemonkey script?

 

This way as soon as a player checkmarks a quest as done, it is hidden and the questid is added to the quests_completed cookie.

 

// ==UserScript==
// @name           TIPQ
// @namespace      TIPQ
// @description    TIPQ Hider
// @include        http://open.tip.it/quests
// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// ==/UserScript==

//Add the functions for cookie handling
function setQuestCookie(questid,action)
{
var index,key,contents,exists=0
var cookies=document.cookie.split(";");
for (index=0; index<cookies.length; index++)
{
	key=cookies[index].substr(0,cookies[index].indexOf("="));
	key=key.replace(/^\s+|\s+$/g,"");
	contents=cookies[index].substring(cookies[index].indexOf("=")+1,cookies[index].length);
	if (key=="quests_completed")
	{
		exists = 1; //cookie exists, we found it
		contents = unescape(unescape(contents));
		//When a quest is checked, we will add that questid to the cookie
		if(action == "add")
		{
			contents=contents.concat(questid+";");
		}
		//When a quest is unchecked, we will remove that questid from the cookie
		if(action == "remove")
		{
			contents=contents.replace(questid+";","");
		}
	}
}
if(exists == 0) // we did not find the cookie
{
	contents=questid+";";
}

//Check if there are any quests hidden, if not remove the cookie
if(contents != "")
{
	var expiration=new Date();
	expiration.setDate(expiration.getDate() + 31536000);
	contents = escape(escape(contents)) + "; expires="+expiration.toUTCString();
} else {
	contents = "; expires=-1";
}
document.cookie="quests_completed=" + contents;
}


// Initialize our jQuery once the page is ready
$(document).ready(function()
{
// When a checkbox is changed, hide it if it was checked, or unhide it if it was unchecked.
$(':checkbox').change(function()
{
	if(this.checked){
		$(this).parent().parent().addClass("members");
		$(this).parent().parent().hide();
		setQuestCookie(this.value,"add");
	} else {
		$(this).parent().parent().removeClass("members");
		$(this).parent().parent().show();
		setQuestCookie(this.value,"remove");
	}
});
});

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.