Fix style in new url page

This commit is contained in:
Rodrigo Fernandes 2016-10-12 23:55:31 +01:00
parent b81d9eb17e
commit c225d665e8
4 changed files with 78 additions and 78 deletions

View file

@ -3,7 +3,7 @@ coverage/**
dist/** dist/**
# Ignore symlink to build folder # Ignore symlink to build folder
docs/assets/** docs/**
# Ignore HTML templates generated code # Ignore HTML templates generated code
src/** src/**

View file

@ -394,6 +394,8 @@
})(typeof self !== 'undefined' ? self : this); })(typeof self !== 'undefined' ? self : this);
},{}],2:[function(require,module,exports){ },{}],2:[function(require,module,exports){
/* global Diff2HtmlUI */
/* /*
* Example URLs: * Example URLs:
* *
@ -415,15 +417,15 @@ $(document).ready(function () {
require('whatwg-fetch'); require('whatwg-fetch');
var $container = $('.container'); var $container = $('.container');
var $url = $("#url"); var $url = $('#url');
var $outputFormat = $("#diff-url-options-output-format"); var $outputFormat = $('#diff-url-options-output-format');
var $showFiles = $("#diff-url-options-show-files"); var $showFiles = $('#diff-url-options-show-files');
var $matching = $("#diff-url-options-matching"); var $matching = $('#diff-url-options-matching');
var $wordThreshold = $("#diff-url-options-match-words-threshold"); var $wordThreshold = $('#diff-url-options-match-words-threshold');
var $matchingMaxComparisons = $("#diff-url-options-matching-max-comparisons"); var $matchingMaxComparisons = $('#diff-url-options-matching-max-comparisons');
var hash = window.location.hash var hash = window.location.hash
.replace(/^(#!?\/?)/, ""); .replace(/^(#!?\/?)/, '');
var search = window.location.search; var search = window.location.search;
@ -433,9 +435,9 @@ $(document).ready(function () {
} else if (search) { } else if (search) {
try { try {
var url = search var url = search
.split("?")[1] .split('?')[1]
.split("diff=")[1] .split('diff=')[1]
.split("&")[0]; .split('&')[0];
$url.val(url); $url.val(url);
draw(prepareUrl(url)); draw(prepareUrl(url));
} catch (_ignore) { } catch (_ignore) {
@ -460,12 +462,12 @@ $(document).ready(function () {
} }
function bind() { function bind() {
$("#url-btn").click(function (e) { $('#url-btn').click(function(e) {
e.preventDefault(); e.preventDefault();
fastDraw(); fastDraw();
}); });
$url.on("paste", function(e) { $url.on('paste', function(e) {
fastDraw(); fastDraw();
}); });
} }
@ -484,43 +486,41 @@ $(document).ready(function () {
var bitbucketPrUrl = /^https?:\/\/(?:www\.)?bitbucket\.org\/(.*?)\/(.*?)\/pull-requests\/(.*?)(?:\/.*)?$/; var bitbucketPrUrl = /^https?:\/\/(?:www\.)?bitbucket\.org\/(.*?)\/(.*?)\/pull-requests\/(.*?)(?:\/.*)?$/;
function genericUrlGen(provider, userName, projectName, type, value) { function genericUrlGen(provider, userName, projectName, type, value) {
return "https://" + provider + ".com/" + userName + "/" + projectName + "/" + type + "/" + value + ".diff"; return 'https://' + provider + '.com/' + userName + '/' + projectName + '/' + type + '/' + value + '.diff';
} }
function bitbucketUrlGen(userName, projectName, type, value) { function bitbucketUrlGen(userName, projectName, type, value) {
var baseUrl = "https://bitbucket.org/api/2.0/repositories/"; var baseUrl = 'https://bitbucket.org/api/2.0/repositories/';
if (type == "pullrequests") { if (type === 'pullrequests') {
return baseUrl + userName + "/" + projectName + "/pullrequests/" + value + "/diff"; return baseUrl + userName + '/' + projectName + '/pullrequests/' + value + '/diff';
} }
return baseUrl + userName + "/" + projectName + "/diff/" + value; return baseUrl + userName + '/' + projectName + '/diff/' + value;
} }
var values; var values;
var finalUrl; var finalUrl;
if ((values = githubPath.exec(url))) { if ((values = githubPath.exec(url))) {
finalUrl = genericUrlGen("github", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('github', values[1], values[2], 'commit', values[3]);
} else if ((values = githubCommitUrl.exec(url))) { } else if ((values = githubCommitUrl.exec(url))) {
finalUrl = genericUrlGen("github", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('github', values[1], values[2], 'commit', values[3]);
} else if ((values = githubPrUrl.exec(url))) { } else if ((values = githubPrUrl.exec(url))) {
finalUrl = genericUrlGen("github", values[1], values[2], "pull", values[3]); finalUrl = genericUrlGen('github', values[1], values[2], 'pull', values[3]);
} else if ((values = gitlabPath.exec(url))) { } else if ((values = gitlabPath.exec(url))) {
finalUrl = genericUrlGen("gitlab", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('gitlab', values[1], values[2], 'commit', values[3]);
} else if ((values = gitlabCommitUrl.exec(url))) { } else if ((values = gitlabCommitUrl.exec(url))) {
finalUrl = genericUrlGen("gitlab", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('gitlab', values[1], values[2], 'commit', values[3]);
} else if ((values = gitlabPrUrl.exec(url))) { } else if ((values = gitlabPrUrl.exec(url))) {
finalUrl = genericUrlGen("gitlab", values[1], values[2], "merge_requests", values[3]); finalUrl = genericUrlGen('gitlab', values[1], values[2], 'merge_requests', values[3]);
} else if ((values = bitbucketPath.exec(url))) { } else if ((values = bitbucketPath.exec(url))) {
finalUrl = bitbucketUrlGen(values[1], values[2], "commit", values[3]); finalUrl = bitbucketUrlGen(values[1], values[2], 'commit', values[3]);
} else if ((values = bitbucketCommitUrl.exec(url))) { } else if ((values = bitbucketCommitUrl.exec(url))) {
finalUrl = bitbucketUrlGen(values[1], values[2], "commit", values[3]); finalUrl = bitbucketUrlGen(values[1], values[2], 'commit', values[3]);
} else if ((values = bitbucketPrUrl.exec(url))) { } else if ((values = bitbucketPrUrl.exec(url))) {
finalUrl = bitbucketUrlGen(values[1], values[2], "pullrequests", values[3]); finalUrl = bitbucketUrlGen(values[1], values[2], 'pullrequests', values[3]);
} else { } else {
console.info("Could not parse url, using the provided url."); console.info('Could not parse url, using the provided url.');
finalUrl = url; finalUrl = url;
} }
@ -529,7 +529,7 @@ $(document).ready(function () {
function draw(url) { function draw(url) {
var outputFormat = $outputFormat.val(); var outputFormat = $outputFormat.val();
var showFiles = $showFiles.is(":checked"); var showFiles = $showFiles.is(':checked');
var matching = $matching.val(); var matching = $matching.val();
var wordThreshold = $wordThreshold.val(); var wordThreshold = $wordThreshold.val();
var matchingMaxComparisons = $matchingMaxComparisons.val(); var matchingMaxComparisons = $matchingMaxComparisons.val();
@ -537,16 +537,16 @@ $(document).ready(function () {
var fullUrl = 'https://crossorigin.me/' + url; var fullUrl = 'https://crossorigin.me/' + url;
fetch(fullUrl) fetch(fullUrl)
.then(function(res) { .then(function(res) {
return res.text() return res.text();
}) })
.then(function(data) { .then(function(data) {
var container = '#url-diff-container'; var container = '#url-diff-container';
var diff2htmlUi = new Diff2HtmlUI({diff: data}); var diff2htmlUi = new Diff2HtmlUI({diff: data});
if (outputFormat == 'side-by-side') { if (outputFormat === 'side-by-side') {
$container.css({"width": "1400px"}); $container.css({'width': '1400px'});
} else { } else {
$container.css({"width": ""}); $container.css({'width': ''});
} }
diff2htmlUi.draw(container, { diff2htmlUi.draw(container, {

2
docs/url.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,5 @@
/* global Diff2HtmlUI */
/* /*
* Example URLs: * Example URLs:
* *
@ -19,15 +21,15 @@ $(document).ready(function () {
require('whatwg-fetch'); require('whatwg-fetch');
var $container = $('.container'); var $container = $('.container');
var $url = $("#url"); var $url = $('#url');
var $outputFormat = $("#diff-url-options-output-format"); var $outputFormat = $('#diff-url-options-output-format');
var $showFiles = $("#diff-url-options-show-files"); var $showFiles = $('#diff-url-options-show-files');
var $matching = $("#diff-url-options-matching"); var $matching = $('#diff-url-options-matching');
var $wordThreshold = $("#diff-url-options-match-words-threshold"); var $wordThreshold = $('#diff-url-options-match-words-threshold');
var $matchingMaxComparisons = $("#diff-url-options-matching-max-comparisons"); var $matchingMaxComparisons = $('#diff-url-options-matching-max-comparisons');
var hash = window.location.hash var hash = window.location.hash
.replace(/^(#!?\/?)/, ""); .replace(/^(#!?\/?)/, '');
var search = window.location.search; var search = window.location.search;
@ -37,9 +39,9 @@ $(document).ready(function () {
} else if (search) { } else if (search) {
try { try {
var url = search var url = search
.split("?")[1] .split('?')[1]
.split("diff=")[1] .split('diff=')[1]
.split("&")[0]; .split('&')[0];
$url.val(url); $url.val(url);
draw(prepareUrl(url)); draw(prepareUrl(url));
} catch (_ignore) { } catch (_ignore) {
@ -64,12 +66,12 @@ $(document).ready(function () {
} }
function bind() { function bind() {
$("#url-btn").click(function (e) { $('#url-btn').click(function(e) {
e.preventDefault(); e.preventDefault();
fastDraw(); fastDraw();
}); });
$url.on("paste", function(e) { $url.on('paste', function(e) {
fastDraw(); fastDraw();
}); });
} }
@ -88,43 +90,41 @@ $(document).ready(function () {
var bitbucketPrUrl = /^https?:\/\/(?:www\.)?bitbucket\.org\/(.*?)\/(.*?)\/pull-requests\/(.*?)(?:\/.*)?$/; var bitbucketPrUrl = /^https?:\/\/(?:www\.)?bitbucket\.org\/(.*?)\/(.*?)\/pull-requests\/(.*?)(?:\/.*)?$/;
function genericUrlGen(provider, userName, projectName, type, value) { function genericUrlGen(provider, userName, projectName, type, value) {
return "https://" + provider + ".com/" + userName + "/" + projectName + "/" + type + "/" + value + ".diff"; return 'https://' + provider + '.com/' + userName + '/' + projectName + '/' + type + '/' + value + '.diff';
} }
function bitbucketUrlGen(userName, projectName, type, value) { function bitbucketUrlGen(userName, projectName, type, value) {
var baseUrl = "https://bitbucket.org/api/2.0/repositories/"; var baseUrl = 'https://bitbucket.org/api/2.0/repositories/';
if (type == "pullrequests") { if (type === 'pullrequests') {
return baseUrl + userName + "/" + projectName + "/pullrequests/" + value + "/diff"; return baseUrl + userName + '/' + projectName + '/pullrequests/' + value + '/diff';
} }
return baseUrl + userName + "/" + projectName + "/diff/" + value; return baseUrl + userName + '/' + projectName + '/diff/' + value;
} }
var values; var values;
var finalUrl; var finalUrl;
if ((values = githubPath.exec(url))) { if ((values = githubPath.exec(url))) {
finalUrl = genericUrlGen("github", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('github', values[1], values[2], 'commit', values[3]);
} else if ((values = githubCommitUrl.exec(url))) { } else if ((values = githubCommitUrl.exec(url))) {
finalUrl = genericUrlGen("github", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('github', values[1], values[2], 'commit', values[3]);
} else if ((values = githubPrUrl.exec(url))) { } else if ((values = githubPrUrl.exec(url))) {
finalUrl = genericUrlGen("github", values[1], values[2], "pull", values[3]); finalUrl = genericUrlGen('github', values[1], values[2], 'pull', values[3]);
} else if ((values = gitlabPath.exec(url))) { } else if ((values = gitlabPath.exec(url))) {
finalUrl = genericUrlGen("gitlab", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('gitlab', values[1], values[2], 'commit', values[3]);
} else if ((values = gitlabCommitUrl.exec(url))) { } else if ((values = gitlabCommitUrl.exec(url))) {
finalUrl = genericUrlGen("gitlab", values[1], values[2], "commit", values[3]); finalUrl = genericUrlGen('gitlab', values[1], values[2], 'commit', values[3]);
} else if ((values = gitlabPrUrl.exec(url))) { } else if ((values = gitlabPrUrl.exec(url))) {
finalUrl = genericUrlGen("gitlab", values[1], values[2], "merge_requests", values[3]); finalUrl = genericUrlGen('gitlab', values[1], values[2], 'merge_requests', values[3]);
} else if ((values = bitbucketPath.exec(url))) { } else if ((values = bitbucketPath.exec(url))) {
finalUrl = bitbucketUrlGen(values[1], values[2], "commit", values[3]); finalUrl = bitbucketUrlGen(values[1], values[2], 'commit', values[3]);
} else if ((values = bitbucketCommitUrl.exec(url))) { } else if ((values = bitbucketCommitUrl.exec(url))) {
finalUrl = bitbucketUrlGen(values[1], values[2], "commit", values[3]); finalUrl = bitbucketUrlGen(values[1], values[2], 'commit', values[3]);
} else if ((values = bitbucketPrUrl.exec(url))) { } else if ((values = bitbucketPrUrl.exec(url))) {
finalUrl = bitbucketUrlGen(values[1], values[2], "pullrequests", values[3]); finalUrl = bitbucketUrlGen(values[1], values[2], 'pullrequests', values[3]);
} else { } else {
console.info("Could not parse url, using the provided url."); console.info('Could not parse url, using the provided url.');
finalUrl = url; finalUrl = url;
} }
@ -133,7 +133,7 @@ $(document).ready(function () {
function draw(url) { function draw(url) {
var outputFormat = $outputFormat.val(); var outputFormat = $outputFormat.val();
var showFiles = $showFiles.is(":checked"); var showFiles = $showFiles.is(':checked');
var matching = $matching.val(); var matching = $matching.val();
var wordThreshold = $wordThreshold.val(); var wordThreshold = $wordThreshold.val();
var matchingMaxComparisons = $matchingMaxComparisons.val(); var matchingMaxComparisons = $matchingMaxComparisons.val();
@ -141,16 +141,16 @@ $(document).ready(function () {
var fullUrl = 'https://crossorigin.me/' + url; var fullUrl = 'https://crossorigin.me/' + url;
fetch(fullUrl) fetch(fullUrl)
.then(function(res) { .then(function(res) {
return res.text() return res.text();
}) })
.then(function(data) { .then(function(data) {
var container = '#url-diff-container'; var container = '#url-diff-container';
var diff2htmlUi = new Diff2HtmlUI({diff: data}); var diff2htmlUi = new Diff2HtmlUI({diff: data});
if (outputFormat == 'side-by-side') { if (outputFormat === 'side-by-side') {
$container.css({"width": "1400px"}); $container.css({'width': '1400px'});
} else { } else {
$container.css({"width": ""}); $container.css({'width': ''});
} }
diff2htmlUi.draw(container, { diff2htmlUi.draw(container, {