Skip to content

Commit

Permalink
display error message if no feature or period passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Ire Aderinokun committed Jan 25, 2016
1 parent 8f90064 commit adac912
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion caniuse-embed.min.js

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

18 changes: 14 additions & 4 deletions development/embed/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
var caniuseDataUrl = 'https://raw.githubusercontent.com/Fyrd/caniuse/master/fulldata-json/data-2.0.json';

var featureID = location.href.split('?feat=')[1],
featureID = featureID.split('&periods=')[0];
featureID = featureID ? featureID.split('&periods=')[0] : null;

var periods = location.href.split('&periods=')[1],
periods = periods.split(",");
periods = periods ? periods.split(",") : null;

var browsers = ['ie', 'edge', 'firefox', 'chrome', 'safari', 'opera', 'ios_saf', 'op_mini', 'android', 'and_chr'];


if ( featureID && periods ) {
document.getElementById('defaultMessage').innerHTML = '<a href="http://caniuse.com/#feat='+featureID+'">Can I Use '+featureID+'?</a> Data on support for the '+featureID+' feature across the major browsers from caniuse.com. (Embed Loading)';

} else {
document.getElementById('defaultMessage').innerHTML = 'Error: Feature and/or Periods not Specified';
}







// ADD TABLE ROWS FOR EACH PERIOD
Expand Down Expand Up @@ -59,8 +70,7 @@ function loadJSON(path, success, error) {
}


// SET DEFAULT MESSAGE OF EMBED LOADING
document.getElementById('defaultMessage').innerHTML = '<a href="http://caniuse.com/#feat='+featureID+'">Can I Use '+featureID+'?</a> Data on support for the '+featureID+' feature across the major browsers from caniuse.com. (Embed Loading)';




Expand Down
2 changes: 1 addition & 1 deletion embed/script.js

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

0 comments on commit adac912

Please sign in to comment.