Last active
August 29, 2015 14:23
-
-
Save IOZ/ad3b1d4e7c90998357e0 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
/** | |
* Content Parser | |
* @param imageName - name from scene 7 | |
*/ | |
function parseContent(imageName) { | |
var imgPath = 'http://images.menswearhouse.com/is/image/JosBank/'; | |
var $content = $('.content.static_content').clone(); | |
var $nav = $('<p class="ea-back"><img src="http://images.menswearhouse.com/is/image/JosBank/Expert_Advice_logoArticle" width="94" height="30" alt="Expert Advice"/> <span aria-hidden="true"> | «</span><a href="ContentView?langId=-1&storeId=11001&catalogId=10050&contentKey=EXPERT_ADVICE">Back To Articles</a></p>'); | |
var center; | |
var output = '<div class="contentSectionArea" dir="ltr" id="main">{{content}}</div>'; | |
var addThisWidget = '<div class="a-center addthis_toolbox addthis_default_style" id="AddThisThirdParty" align="center"><a class="addthis_button_facebook_like" fb:like:layout="button_count"></a><a class="addthis_button_tweet"></a><a class="addthis_button_pinterest_pinit"></a><a class="addthis_counter addthis_pill_style"></a></div>'; | |
/* remove styles */ | |
$content.find('style').remove(); | |
/* replace classes */ | |
$content.find('.EA_GeneralText').removeClass('EA_GeneralText').addClass('ea-general-text'); | |
$content.find('.EA_ArticleTitle').removeClass('EA_ArticleTitle').addClass('ea-article-title'); | |
$content.find('.EA_GeneralTextListItems').removeClass('EA_GeneralTextListItems').addClass('ea-general-text-list'); | |
$content.find('.EA_SectionTitle').removeClass('EA_SectionTitle').addClass('ea-section-title'); | |
/* replace top navigation */ | |
$content.find('.EA_BackLink').replaceWith($nav); | |
center = $content.find('center:first').html(); | |
$content.find('center:first').replaceWith('<div class="a-center">' + center + '</div>'); | |
/* replace main image */ | |
$content.find('#image').attr('src', imgPath + imageName); | |
/* replace addThis */ | |
$content.find('center:last').replaceWith(addThisWidget); | |
$content.find('script').remove(); | |
/* | |
Remove extra spaces and display content. | |
After that copy text from console and put them into http://jsbeautifier.org/ | |
*/ | |
console.log(output.replace('{{content}}', $content.html()).replace(/<!--[\s\S]*?-->/g, '').replace(/(\r\n|\n|\r)/gm, '').replace(/\s+/g," ")); | |
} | |
parseContent('ArticleImage_StainRemoval'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment