From 0fcd312812536b7f8defd72b57675db0bb96d227 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 17 Apr 2015 19:31:02 +0200 Subject: [PATCH] Check if API-docs point to existing resources --- examples/resources/common.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/examples/resources/common.js b/examples/resources/common.js index 2609dbbd7c..c731a39b59 100644 --- a/examples/resources/common.js +++ b/examples/resources/common.js @@ -10,6 +10,31 @@ }); } + // Check whether links to API-docs of used classes actually point to + // existing html-files: + $('#api-links a').each(function() { + var url = this.href; + $.ajax({ + type: 'HEAD', + url: url, + context: this, + error: function() { + // We get into the error if either the resource didn't exist + // or if HEAD was not allowed (when serving locally via node) + // => remove the
  • and the following comma + var li = $(this).parent(); + var comma = $(li[0].nextSibling); + comma.remove(); + li.remove(); + // It may be that this was the last
  • , if that's the case, + // remove the complete
    , as we don't have an API-links + if ($('#api-links li').length === 0) { + $('#api-links').remove(); + } + } + }); + }); + if (window.location.host === 'localhost:3000') { return; }