mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Overriding user preference is a bad idea from a usability point of view. Just allow people to decide for themselves whether they want to navigate away to another page or open the link in a new tab using the controls provided them by the browser (eg. cmd-click, or the options in the right click menu). This also fixes the situation where someone might want to open an external link in the same tab, which is currently made impossible.
74 lines
1.8 KiB
JavaScript
74 lines
1.8 KiB
JavaScript
check_links = function() {
|
|
var body = document.body.innerHTML;
|
|
|
|
var id_set = {};
|
|
|
|
body.replace(/id\s*=\s*"(.*?)"/g, function(match, id) {
|
|
if (! id) return;
|
|
if (id_set['$'+id]) {
|
|
console.log("ERROR: Duplicate id: "+id);
|
|
} else {
|
|
id_set['$'+id] = true;
|
|
}
|
|
});
|
|
|
|
body.replace(/"#(.*?)"/g, function(match, frag) {
|
|
if (! frag) return;
|
|
if (! id_set['$'+frag]) {
|
|
var suggestions = [];
|
|
_.each(_.keys(id_set), function(id) {
|
|
id = id.slice(1);
|
|
if (id.slice(-frag.length) === frag ||
|
|
frag.slice(-id.length) === id) {
|
|
suggestions.push(id);
|
|
}
|
|
});
|
|
var msg = "ERROR: id not found: "+frag;
|
|
if (suggestions.length > 0) {
|
|
msg += " -- suggest "+suggestions.join(', ');
|
|
}
|
|
console.log(msg);
|
|
}
|
|
});
|
|
|
|
return "DONE";
|
|
};
|
|
|
|
var basicTypes = ["String", "Number", "Boolean", "Function", "Any", "Object",
|
|
"Array", "null", "undefined", "Integer", "Error"];
|
|
|
|
// are all types either normal types or links?
|
|
check_types = function () {
|
|
$(".new-api-box .type").each(function () {
|
|
var typeSpan = this;
|
|
|
|
var typesPipeSeparated =
|
|
$(typeSpan).text().replace(/, or /g, "|").replace(/( or )/g, "|")
|
|
.replace(/, /g, "|");
|
|
|
|
_.each(typesPipeSeparated.split("|"), function (text) {
|
|
if (! text) {
|
|
console.log(typeSpan);
|
|
return;
|
|
}
|
|
|
|
text = text.replace(/^\s+|\s+$/g, '');
|
|
|
|
if (_.contains(basicTypes, text)) {
|
|
return; // all good
|
|
}
|
|
|
|
var hasLink = false;
|
|
$(typeSpan).find("a").each(function () {
|
|
if ($(this).text().replace(/^\s+|\s+$/g, '') === text) {
|
|
hasLink = true;
|
|
}
|
|
});
|
|
|
|
if (! hasLink) {
|
|
console.log("No link for: " + text);
|
|
}
|
|
});
|
|
});
|
|
};
|