Created
February 27, 2009 23:22
-
-
Save leevigraham/71768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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