Last active
August 29, 2015 14:23
-
-
Save IOZ/6c72738dc53333cf88e2 to your computer and use it in GitHub Desktop.
Content Parse for Landing Pages
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
/** | |
* Content Parser | |
*/ | |
function parseContent2() { | |
var imgPath = 'http://images.menswearhouse.com/is/image/JosBank/'; | |
var $content = $('.additionalInfos').clone(); | |
var output = '<div class="contentSectionArea" dir="ltr" id="main"><div><div class="landingPageContent">{{content}}</div></div></div>'; | |
var rePath1 = /\/wps\/wcm\/[a-z]*\/[a-z0-9]*\//g; | |
var rePath2 = /\.(gif|jpg)\?[A-Z]*\=[A-Z]*/g; | |
/* remove styles */ | |
$content.find('style').remove(); | |
$content.find('.addLineItem').removeClass('addLineItem').addClass('addlineitm'); | |
/* | |
Remove extra spaces and display content. | |
After that copy text from console and put them into http://jsbeautifier.org/ | |
*/ | |
output = output.replace('{{content}}', $content.html()) | |
.replace(/<!--[\s\S]*?-->/g, '') | |
.replace(/(\r\n|\n|\r)/gm, '').replace(/\s+/g," ") | |
.replace(rePath1, imgPath) | |
.replace(rePath2, ""); | |
console.log(output); | |
} | |
parseContent2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment