Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run prettier over all js files #1201

Merged
merged 1 commit into from May 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
87 changes: 42 additions & 45 deletions js/github.js
@@ -1,48 +1,45 @@
// Helpers for the GitHub API.

define(
[],
function () {
function findNext(header) {
// Finds the next URL of paginated resources which
// is available in the Link header. Link headers look like this:
// Link: <url1>; rel="next", <url2>; rel="foo"; bar="baz"
// More info here: https://developer.github.com/v3/#link-header
var m = (header||"").match(/<([^>]+)>\s*;\s*rel="next"/);
return (m && m[1]) || null;
}

function fetch(url, options) {
if (options) {
options.url = url;
url = options;
}
return $.ajax(url);
}
function fetchAll(url, options) {
return _fetchAll(url, options, []);
}

function _fetchAll(url, options, output) {
var request = fetch(url, options);
return request.then(function(resp) {
output.push.apply(output, resp);
var next = findNext(request.getResponseHeader("Link"));
return next ? _fetchAll(next, options, output) : output;
});
}

return {
fetch: fetch,
fetchAll: fetchAll,
fetchIndex: function(url, options) {
// converts URLs of the form:
// https://api.github.com/repos/user/repo/comments{/number}
// into:
// https://api.github.com/repos/user/repo/comments
// which is what you need if you want to get the index.
return fetchAll(url.replace(/\{[^}]+\}/, ""), options);
}
};
define([], function() {
function findNext(header) {
// Finds the next URL of paginated resources which
// is available in the Link header. Link headers look like this:
// Link: <url1>; rel="next", <url2>; rel="foo"; bar="baz"
// More info here: https://developer.github.com/v3/#link-header
var m = (header || "").match(/<([^>]+)>\s*;\s*rel="next"/);
return (m && m[1]) || null;
}

function fetch(url, options) {
if (options) {
options.url = url;
url = options;
}
return $.ajax(url);
}
function fetchAll(url, options) {
return _fetchAll(url, options, []);
}

function _fetchAll(url, options, output) {
var request = fetch(url, options);
return request.then(function(resp) {
output.push.apply(output, resp);
var next = findNext(request.getResponseHeader("Link"));
return next ? _fetchAll(next, options, output) : output;
});
}

return {
fetch: fetch,
fetchAll: fetchAll,
fetchIndex: function(url, options) {
// converts URLs of the form:
// https://api.github.com/repos/user/repo/comments{/number}
// into:
// https://api.github.com/repos/user/repo/comments
// which is what you need if you want to get the index.
return fetchAll(url.replace(/\{[^}]+\}/, ""), options);
}
);
};
});
25 changes: 14 additions & 11 deletions js/profile-w3c-common.js
Expand Up @@ -3,9 +3,13 @@
if (document.body) {
document.body.hidden = true;
} else {
document.addEventListener("DOMContentLoaded", function() {
document.body.hidden = true;
}, { once: true });
document.addEventListener(
"DOMContentLoaded",
function() {
document.body.hidden = true;
},
{ once: true }
);
}

// In case everything else fails, we always want to show the document
Expand All @@ -18,27 +22,26 @@ window.addEventListener("error", function(ev) {
require.config({
shim: {
shortcut: {
exports: "shortcut"
exports: "shortcut",
},
highlight: {
exports: "hljs"
exports: "hljs",
},
beautify: {
exports: "beautify"
}
exports: "beautify",
},
},
paths: {
"beautify-css": "deps/beautify-css",
"beautify-html": "deps/beautify-html",
"handlebars.runtime": "deps/handlebars",
"deps/highlight": "https://www.w3.org/Tools/respec/respec-highlight",
},
deps: [
"deps/fetch",
],
deps: ["deps/fetch"],
});

define([
define(
[
// order is significant
"deps/domReady",
"core/base-runner",
Expand Down