From 8f900640bdc65d66059a627ec0062b1e0cef8ba6 Mon Sep 17 00:00:00 2001 From: Ire Aderinokun Date: Mon, 25 Jan 2016 09:55:21 +0100 Subject: [PATCH] min file --- caniuse-embed.js => caniuse-embed.min.js | 0 embed/script.js | 2 +- gulpfile.js | 4 ++-- index.html | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename caniuse-embed.js => caniuse-embed.min.js (100%) diff --git a/caniuse-embed.js b/caniuse-embed.min.js similarity index 100% rename from caniuse-embed.js rename to caniuse-embed.min.js diff --git a/embed/script.js b/embed/script.js index b026cd0..b586f40 100644 --- a/embed/script.js +++ b/embed/script.js @@ -1 +1 @@ -function getShortenedBrowserVersion(e){return e&&e.indexOf("-")>-1&&(e=e.split("-")[1]),e}function loadJSON(e,t,s){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&(200===n.status?t&&t(JSON.parse(n.responseText)):s&&s(n))},n.open("GET",e,!0),n.send()}for(var caniuseDataUrl="https://raw.githubusercontent.com/Fyrd/caniuse/master/fulldata-json/data-2.0.json",featureID=location.href.split("?feat=")[1],featureID=featureID.split("&periods=")[0],periods=location.href.split("&periods=")[1],periods=periods.split(","),browsers=["ie","edge","firefox","chrome","safari","opera","ios_saf","op_mini","android","and_chr"],i=periods.length-1;i>-1;i--){var tableCells='',row=document.createElement("tr");row.className="statistics "+periods[i],row.innerHTML=tableCells,document.getElementById("tableBody").appendChild(row)}document.getElementById("defaultMessage").innerHTML='Can I Use '+featureID+"? Data on support for the "+featureID+" feature across the major browsers from caniuse.com. (Embed Loading)",loadJSON(caniuseDataUrl,function(e){var t=e.data[featureID];if(t){var s=t.usage_perc_y,r=t.usage_perc_a,a=s+r,a=a.toFixed(2);document.getElementById("featureTitle").innerHTML=t.title,document.getElementById("featureDescription").innerHTML=t.description,document.getElementById("featureLink").href="http://caniuse.com/#feat="+featureID,document.getElementById("note").innerHTML='Global: '+s+'% + '+r+"% = "+a+"%";for(var o={},i=0;i-1?(n=parseInt(f.split("_")[1]),o[l][f]=e.agents[l].version_list[d-n]?e.agents[l].version_list[d-n].version:null):f.indexOf("future")>-1&&(n=parseInt(f.split("_")[1]),o[l][f]=e.agents[l].version_list[d+n]?e.agents[l].version_list[d+n].version:null)}}for(var p={},i=0;i-1&&(I=b[B]);void 0!=y[l][f]?I.className+=" "+y[l][f]:!1;var _=getShortenedBrowserVersion(o[l][f]),w=""+_+''+p[l][f]+"%";void 0!=o[l][f]?I.innerHTML=w:I.innerHTML="",void 0!=y[l][f]&&y[l][f].indexOf("x")>-1&&(v=!0),void 0!=y[l][f]&&y[l][f].indexOf("u")>-1&&(h=!0)}v?document.getElementById("legendX").style.display="inline-block":document.getElementById("legendX").style.display="none",h?document.getElementById("legendU").style.display="inline-block":document.getElementById("legendU").style.display="none"}else document.getElementById("featureTitle").innerHTML="Uh Oh!",document.getElementById("featureDescription").innerHTML="The feature '"+featureID+"' was not recognized. ",document.getElementById("featureMain").innerHTML="";document.getElementById("defaultMessage").style.display="none",document.getElementsByClassName("feature")[0].style.display="block";var M=document.getElementsByClassName("feature")[0].scrollHeight,D="ciu_embed:"+featureID+":"+M;parent.postMessage(D,"*"),window.onresize=function(e){M=document.getElementsByClassName("feature")[0].scrollHeight;var t="ciu_embed:"+featureID+":"+M;parent.postMessage(t,"*")}},function(e){document.getElementById("defaultMessage").innerHTML="Error Getting JSON File: "+e.response,console.error(e)}); \ No newline at end of file +function getShortenedBrowserVersion(e){return e&&e.indexOf("-")>-1&&(e=e.split("-")[1]),e}function loadJSON(e,t,s){var n=new XMLHttpRequest;n.onreadystatechange=function(){n.readyState===XMLHttpRequest.DONE&&(200===n.status?t&&t(JSON.parse(n.responseText)):s&&s(n))},n.open("GET",e,!0),n.send()}for(var caniuseDataUrl="https://raw.githubusercontent.com/Fyrd/caniuse/master/fulldata-json/data-2.0.json",featureID=location.href.split("?feat=")[1],featureID=featureID.split("&periods=")[0],periods=location.href.split("&periods=")[1],periods=periods.split(","),browsers=["ie","edge","firefox","chrome","safari","opera","ios_saf","op_mini","android","and_chr"],i=periods.length-1;i>-1;i--){var tableCells='',row=document.createElement("tr");row.className="statistics "+periods[i],row.innerHTML=tableCells,document.getElementById("tableBody").appendChild(row)}document.getElementById("defaultMessage").innerHTML='Can I Use '+featureID+"? Data on support for the "+featureID+" feature across the major browsers from caniuse.com. (Embed Loading)",loadJSON(caniuseDataUrl,function(e){var t=e.data[featureID];if(t){var s=t.usage_perc_y,a=t.usage_perc_a,r=s+a,r=r.toFixed(2);document.getElementById("featureTitle").innerHTML=t.title,document.getElementById("featureDescription").innerHTML=t.description,document.getElementById("featureLink").href="http://caniuse.com/#feat="+featureID,document.getElementById("note").innerHTML='Global: '+s+'% + '+a+"% = "+r+"%";for(var o={},i=0;i-1?(n=parseInt(f.split("_")[1]),o[l][f]=e.agents[l].version_list[d-n]?e.agents[l].version_list[d-n].version:null):f.indexOf("future")>-1&&(n=parseInt(f.split("_")[1]),o[l][f]=e.agents[l].version_list[d+n]?e.agents[l].version_list[d+n].version:null)}}for(var p={},i=0;i-1&&(b=w[E]);void 0!=h[l][f]?b.className+=" "+h[l][f]:!1;var _=getShortenedBrowserVersion(o[l][f]),B=""+_+''+p[l][f]+"%";void 0!=o[l][f]?b.innerHTML=B:b.innerHTML="",void 0!=h[l][f]&&h[l][f].indexOf("x")>-1&&(v=!0),void 0!=h[l][f]&&h[l][f].indexOf("u")>-1&&(y=!0)}v?document.getElementById("legendX").style.display="inline-block":document.getElementById("legendX").style.display="none",y?document.getElementById("legendU").style.display="inline-block":document.getElementById("legendU").style.display="none"}else document.getElementById("featureTitle").innerHTML="Uh Oh!",document.getElementById("featureDescription").innerHTML="The feature '"+featureID+"' was not recognized. ",document.getElementById("featureMain").innerHTML="";document.getElementById("defaultMessage").style.display="none",document.getElementsByClassName("feature")[0].style.display="block";var M=document.getElementsByClassName("feature")[0].scrollHeight,L="ciu_embed:"+featureID+":"+M;parent.postMessage(L,"*"),window.onresize=function(e){M=document.getElementsByClassName("feature")[0].scrollHeight;var t="ciu_embed:"+featureID+":"+M;parent.postMessage(t,"*")}},function(e){document.getElementById("defaultMessage").innerHTML="Error Getting JSON File: "+e.response,console.error(e)}); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 5d149d5..bbe24a2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,7 @@ var gulp = require('gulp'), sass = require('gulp-sass'), gutil = require('gulp-util'), - uglify = require('gulp-uglify'), + uglify = require('gulp-uglifyjs'), minifyHTML = require('gulp-minify-html'), connect = require('gulp-connect'); @@ -12,7 +12,7 @@ var embedHTML = "development/embed/index.html"; gulp.task('script', function() { gulp.src(caniuseEmbed) - .pipe(uglify()) + .pipe(uglify('caniuse-embed.min.js')) .pipe(gulp.dest('')); gulp.src(embedScript) .pipe(uglify()) diff --git a/index.html b/index.html index f0f74c6..7154bf8 100644 --- a/index.html +++ b/index.html @@ -87,7 +87,7 @@

Step 1 - Include Script

Include the following javascript file in your document.

-
<script src="https://caniuse.bitsofco.de/caniuse-embed.js"></script>
+
<script src="https://caniuse.bitsofco.de/caniuse-embed.min.js"></script>
Copy
@@ -168,7 +168,7 @@

Step 3 - Get the Embed Code

- + diff --git a/package.json b/package.json index adc7002..30fa008 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "gulp": "^3.9.0", "gulp-minify-html": "^1.0.5", "gulp-sass": "^2.1.1", - "gulp-uglify": "^1.2.0", + "gulp-uglifyjs": "^0.6.2", "gulp-util": "^3.0.6" } }