Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into stories/DT/overallscore-#121
Browse files Browse the repository at this point in the history
Conflicts:
	dist/yoast-seo.js
	dist/yoast-seo.min.js
	js/scoreFormatter.js
  • Loading branch information
omarreiss committed Nov 9, 2015
2 parents c1209c2 + 9658393 commit 20693e6
Show file tree
Hide file tree
Showing 13 changed files with 250 additions and 148 deletions.
20 changes: 8 additions & 12 deletions css/analyzer.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
clear: both;
}

.title {
.snippet_container .title {
color: #1e0fbe;
display: inline;
display: block;
overflow: hidden;
text-overflow: ellipsis;
text-decoration: none;
Expand All @@ -34,37 +34,33 @@
margin: 0;
}

.title:visited {
color: #609
}

.url, .desc {
.snippet_container .url, .desc {
font-size: 13px;
line-height: 1.4;
display: block;

}

.url {
.snippet_container .url {
font-size: 14px;
line-height: 16px;
color: #006621;
font-style: normal;
}

.urlBase{
.snippet_container .urlBase{
float: left;
}

.desc {
.snippet_container .desc {
color: #545454;
}

.tooLong {
.snippet_container .tooLong {
color: #f00 !important;
}

.editIcon:hover {
.snippet_container .editIcon:hover {
background: #bbdefb url("editicon.png") no-repeat right top;
cursor: pointer;
}
Expand Down
133 changes: 84 additions & 49 deletions dist/yoast-seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1028,12 +1028,13 @@ YoastSEO = ( "undefined" === typeof YoastSEO ) ? {} : YoastSEO;
YoastSEO.App = function( args ) {
this.config = this.extendConfig( args );
this.callbacks = this.config.callbacks;
this.rawData = this.callbacks.getData();

this.i18n = this.constructI18n( this.config.translations );
this.stringHelper = new YoastSEO.StringHelper();
this.pluggable = new YoastSEO.Pluggable( this );

this.getData();

this.showLoadingDialog();
this.createSnippetPreview();
this.runAnalyzer();
Expand Down Expand Up @@ -1112,11 +1113,22 @@ YoastSEO.App.prototype.constructI18n = function( translations ) {
return new YoastSEO.Jed( translations );
};

/**
* Retrieves data from the callbacks.getData and applies modification to store these in this.rawData.
*/
YoastSEO.App.prototype.getData = function() {
this.rawData = this.callbacks.getData();
if ( this.pluggable.loaded ) {
this.rawData.pageTitle = this.pluggable._applyModifications( "data_page_title", this.rawData.pageTitle );
this.rawData.meta = this.pluggable._applyModifications( "data_meta_desc", this.rawData.meta );
}
};

/**
* Refreshes the analyzer and output of the analyzer
*/
YoastSEO.App.prototype.refresh = function() {
this.rawData = this.callbacks.getData();
this.getData();
this.runAnalyzer();
};

Expand Down Expand Up @@ -1322,7 +1334,7 @@ YoastSEO.App.prototype.runAnalyzer = function() {

var keyword = this.stringHelper.sanitizeKeyword( this.rawData.keyword );
if ( keyword === "" ) {
this.analyzerData.queue = [ "keyWordCheck", "wordCount", "fleschReading", "pageTitleLength", "urlStopwords", "metaDescription" ];
this.analyzerData.queue = [ "keyWordCheck", "wordCount", "fleschReading", "pageTitleLength", "urlStopwords", "metaDescriptionLength" ];
}

if ( typeof this.pageAnalyzer === "undefined" ) {
Expand All @@ -1342,8 +1354,10 @@ YoastSEO.App.prototype.runAnalyzer = function() {
outputTarget: this.config.targets.output,
overallTarget: this.config.targets.overall,
keyword: this.rawData.keyword,
saveScores: this.callbacks.saveScores
saveScores: this.callbacks.saveScores,
i18n: this.i18n
} );
this.scoreFormatter.renderScore();

if ( this.config.dynamicDelay ) {
this.endTime();
Expand All @@ -1367,6 +1381,7 @@ YoastSEO.App.prototype.modifyData = function( data ) {
* Function to fire the analyzer when all plugins are loaded, removes the loading dialog.
*/
YoastSEO.App.prototype.pluginsLoaded = function() {
this.getData();
this.removeLoadingDialog();
this.runAnalyzer();
};
Expand Down Expand Up @@ -1435,7 +1450,7 @@ YoastSEO.Pluggable = function( app ) {
this.modifications = {};
this.customTests = [];

// Allow plugins 500 ms to register before we start polling their
// Allow plugins 1500 ms to register before we start polling their
setTimeout( this._pollLoadingPlugins.bind( this ), 1500 );
};

Expand Down Expand Up @@ -2090,7 +2105,14 @@ YoastSEO.ScoreFormatter = function( args ) {
this.overallTarget = args.overallTarget;
this.totalScore = 0;
this.keyword = args.keyword;
this.i18n = args.i18n;
this.saveScores = args.saveScores;
};

/**
* Renders the score in the HTML.
*/
YoastSEO.ScoreFormatter.prototype.renderScore = function() {
this.outputScore();
this.outputOverallScore();
};
Expand All @@ -2099,21 +2121,29 @@ YoastSEO.ScoreFormatter = function( args ) {
* creates the list for showing the results from the analyzerscorer
*/
YoastSEO.ScoreFormatter.prototype.outputScore = function() {
var seoScoreText, scoreRating;

this.sortScores();
var outputTarget = document.getElementById( this.outputTarget );
outputTarget.innerHTML = "";
var newList = document.createElement( "ul" );
newList.className = "wpseoanalysis";
for ( var i = 0; i < this.scores.length; i++ ) {
if ( this.scores[ i ].text !== "" ) {
scoreRating = this.scoreRating( this.scores[ i ].score );

var newLI = document.createElement( "li" );
newLI.className = "score";
var scoreSpan = document.createElement( "span" );
scoreSpan.className = "wpseo-score-icon " + this.scoreRating( this.scores[ i ].score );
scoreSpan.className = "wpseo-score-icon " + scoreRating;
newLI.appendChild( scoreSpan );

seoScoreText = this.getSEOScoreText( scoreRating );

var screenReaderDiv = document.createElement( "span" );
screenReaderDiv.className = "screen-reader-text";
screenReaderDiv.textContent = "seo score " + this.scoreRating( this.scores[ i ].score );
screenReaderDiv.textContent = seoScoreText;

newLI.appendChild( screenReaderDiv );
var textSpan = document.createElement( "span" );
textSpan.className = "wpseo-score-text";
Expand Down Expand Up @@ -2186,6 +2216,41 @@ YoastSEO.ScoreFormatter.prototype.overallScoreRating = function( score ) {
}
return this.scoreRating( score );
};

/**
* Returns a translated score description based on the textual score rating
*
* @param {string} scoreRating Textual score rating, can be retrieved with scoreRating from the actual score.
*
* @return {string}
*/
YoastSEO.ScoreFormatter.prototype.getSEOScoreText = function( scoreRating ) {
var scoreText = "";

switch ( scoreRating ) {
case "na":
scoreText = this.i18n.dgettext( "js-text-analysis", "No keyword" );
break;

case "bad":
scoreText = this.i18n.dgettext( "js-text-analysis", "Bad SEO score" );
break;

case "poor":
scoreText = this.i18n.dgettext( "js-text-analysis", "Poor SEO score" );
break;

case "ok":
scoreText = this.i18n.dgettext( "js-text-analysis", "Ok SEO score" );
break;

case "good":
scoreText = this.i18n.dgettext( "js-text-analysis", "Good SEO score" );
break;
}

return scoreText;
};
;/* jshint browser: true */
/* global YoastSEO: true */
YoastSEO = ( "undefined" === typeof YoastSEO ) ? {} : YoastSEO;
Expand Down Expand Up @@ -2222,10 +2287,6 @@ YoastSEO.SnippetPreview.prototype.init = function() {
this.output = this.htmlOutput();
this.renderOutput();
}
this.snippetSuffix = "";
if ( this.refObj.config.snippetSuffix !== "undefined" ) {
this.snippetSuffix = this.refObj.config.snippetSuffix;
}
};

/**
Expand All @@ -2249,13 +2310,11 @@ YoastSEO.SnippetPreview.prototype.htmlOutput = function() {
*/
YoastSEO.SnippetPreview.prototype.formatTitle = function() {
var title = this.refObj.rawData.snippetTitle;
if ( title === "" ) {
if ( title === "" || typeof title === "undefined" ) {
title = this.refObj.rawData.pageTitle;
}
if ( title === "" ) {
if ( title === "" || typeof title === "undefined" ) {
title = this.refObj.config.sampleText.title;
} else {
title += this.snippetSuffix;
}
title = this.refObj.stringHelper.stripAllTags( title );
if ( this.refObj.rawData.keyword !== "" ) {
Expand Down Expand Up @@ -2522,30 +2581,6 @@ YoastSEO.SnippetPreview.prototype.setUnformattedText = function( ev ) {
this.unformattedText[ elem ] = document.getElementById( elem ).textContent;
};

/**
* Adds the siteName to the snippetTitle when editting starts, this adds the sitename to
* the snippet_sitename that cannot be edited.
* Sets the display property to inline-block of the snippet_title so we can set a width.
* @param ev
*/
YoastSEO.SnippetPreview.prototype.setSiteName = function( ev ) {
if ( ev.currentTarget.id === "snippet_title" ) {
document.getElementById( "snippet_sitename" ).textContent = this.snippetSuffix;
document.getElementById( "snippet_sitename" ).style.display = "inline-block";
document.getElementById( "snippet_title" ).style.display = "inline-block";
}
};

/**
* Removes the siteName from the snippetTitle span when editing is finished, since it should only show
* when editing.
*/
YoastSEO.SnippetPreview.prototype.unsetSiteName = function() {
document.getElementById( "snippet_sitename" ).textContent = "";
document.getElementById( "snippet_title" ).style.display = "inline";
document.getElementById( "snippet_sitename" ).style.display = "inline";
};

/**
* Adds and remove the tooLong class when a text is too long.
* @param ev
Expand Down Expand Up @@ -3916,7 +3951,7 @@ YoastSEO.AnalyzerScoring = function( i18n ) {
score: 7,

/* translators: %1$d expands to the number of words in the text, %2$s to the recommended minimum of words */
text: i18n.dgettext('js-text-analysis', "The text contains %1$d words, this is slightly below the %2$d word recommended minimum, add a bit more copy.")
text: i18n.dgettext('js-text-analysis', "The text contains %1$d words, this is slightly below the %2$d word recommended minimum. Add a bit more copy.")
},
{
min: 200,
Expand Down Expand Up @@ -3966,31 +4001,31 @@ YoastSEO.AnalyzerScoring = function( i18n ) {
score: -50,

/* translators: %1$f expands to the keyword density percentage, %2$d expands to the number of times the keyword is found */
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is way over the advised 2.5% maximum, the focus keyword was found %2$d times.")
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is way over the advised 2.5% maximum; the focus keyword was found %2$d times.")
},
{
min: 2.5,
max: 3.49,
score: -10,

/* translators: %1$f expands to the keyword density percentage, %2$d expands to the number of times the keyword is found */
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is over the advised 2.5% maximum, the focus keyword was found %2$d times.")
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is over the advised 2.5% maximum; the focus keyword was found %2$d times.")
},
{
min: 0.5,
max: 2.49,
score: 9,

/* translators: %1$f expands to the keyword density percentage, %2$d expands to the number of times the keyword is found */
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is great, the focus keyword was found %2$d times.")
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is great; the focus keyword was found %2$d times.")
},
{
min: 0,
max: 0.49,
score: 4,

/* translators: %1$f expands to the keyword density percentage, %2$d expands to the number of times the keyword is found */
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is a bit low, the focus keyword was found %2$d times.")
text: i18n.dgettext('js-text-analysis', "The keyword density is %1$f%, which is a bit low; the focus keyword was found %2$d times.")
}
],
replaceArray: [
Expand All @@ -4017,7 +4052,7 @@ YoastSEO.AnalyzerScoring = function( i18n ) {
matcher: "totalKeyword",
min: 1,
score: 2,
text: i18n.dgettext('js-text-analysis', "You\'re linking to another page with the focus keyword you want this page to rank for, consider changing that if you truly want this page to rank.")
text: i18n.dgettext('js-text-analysis', "You\'re linking to another page with the focus keyword you want this page to rank for. Consider changing that if you truly want this page to rank.")
},

/* translators: %2$s expands the number of outbound links */
Expand Down Expand Up @@ -4111,7 +4146,7 @@ YoastSEO.AnalyzerScoring = function( i18n ) {
score: 6,

/* translators: %2$d expands to the maximum length for the meta description */
text: i18n.dgettext('js-text-analysis', "The specified meta description is over %2$d characters, reducing it will ensure the entire description is visible")
text: i18n.dgettext('js-text-analysis', "The specified meta description is over %2$d characters. Reducing it will ensure the entire description is visible")
},
{
min: 120,
Expand Down Expand Up @@ -4142,7 +4177,7 @@ YoastSEO.AnalyzerScoring = function( i18n ) {
{
max: 0,
score: 3,
text: i18n.dgettext('js-text-analysis', "The focus keyword doesn\'t appear in the first paragraph of the copy, make sure the topic is clear immediately.")
text: i18n.dgettext('js-text-analysis', "The focus keyword doesn\'t appear in the first paragraph of the copy. Make sure the topic is clear immediately.")
},
{min: 1, score: 9, text: i18n.dgettext('js-text-analysis', "The focus keyword appears in the first paragraph of the copy.")}
]
Expand Down Expand Up @@ -4213,8 +4248,8 @@ YoastSEO.AnalyzerScoring = function( i18n ) {
max: 70,
score: 9,

/* translators: %1$d expands to the minimum number of characters in the page title, %2$d to the minimum number of characters */
text: i18n.dgettext('js-text-analysis', "The page title is more than %1$d characters and less than the recommended %2$d character limit.")
/* translators: %1$d expands to the minimum number of characters in the page title, %2$d to the maximum number of characters */
text: i18n.dgettext('js-text-analysis', "The page title is between the %1$d character minimum and the recommended %2$d character maximum.")
}
],
replaceArray: [
Expand Down
2 changes: 1 addition & 1 deletion dist/yoast-seo.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions dist/yoast-seo.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 20693e6

Please sign in to comment.