Skip to content

Instantly share code, notes, and snippets.

@leevigraham
Created February 27, 2009 23:22
Show Gist options
  • Save leevigraham/71768 to your computer and use it in GitHub Desktop.
Save leevigraham/71768 to your computer and use it in GitHub Desktop.
msg_regexp = new RegExp("<div class=['\"]message['\"]>[\\s\\S]+<\/div>", "m")
ee_ajax_response_marker_reg_exp = new RegExp("<!-- EE_ajax_response(?: -->([\\s\\S]+)<!-- )?End EE_ajax_response -->");
function parse_interstitial_response(str)
{
if((response = str.match(ee_ajax_response_marker_reg_exp)) && (message = response[1].match(msg_regexp)))
{
error = (str.match(/Error<\/title>/)) ? true : false;
link = response[1].match(/href=["'](.*)["']/) || false;
message = message[0].replace(/(class=['"]message)/gi, ( error ? "$1 error" : "$1 success") );
return {
error: error,
text: message,
link: link,
klass: (error) ? "error" : "success"
};
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment