15462e1a8f
## What changes were proposed in this pull request? We're using an old-ish jQuery, 1.12.4, and should probably update for Spark 3 to keep up in general, but also to keep up with CVEs. In fact, we know of at least one resolved in only 3.4.0+ (https://nvd.nist.gov/vuln/detail/CVE-2019-11358). They may not affect Spark, but, if the update isn't painful, maybe worthwhile in order to make future 3.x updates easier. jQuery 1 -> 2 doesn't sound like a breaking change, as 2.0 is supposed to maintain compatibility with 1.9+ (https://blog.jquery.com/2013/04/18/jquery-2-0-released/) 2 -> 3 has breaking changes: https://jquery.com/upgrade-guide/3.0/. It's hard to evaluate each one, but the most likely area for problems is in ajax(). However, our usage of jQuery (and plugins) is pretty simple. Update jquery to 3.4.1; update jquery blockUI and mustache to latest ## How was this patch tested? Manual testing of docs build (except R docs), worker/master UI, spark application UI. Note: this really doesn't guarantee it works, as our tests can't test javascript, and this is merely anecdotal testing, although I clicked about every link I could find. There's a risk this breaks a minor part of the UI; it does seem to work fine in the main. Closes #24843 from srowen/SPARK-28004. Authored-by: Sean Owen <sean.owen@databricks.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
98 lines
3.5 KiB
JavaScript
Executable file
98 lines
3.5 KiB
JavaScript
Executable file
/*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership.
|
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
* (the "License"); you may not use this file except in compliance with
|
|
* the License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/* Custom JavaScript code in the MarkDown docs */
|
|
|
|
// Enable language-specific code tabs
|
|
function codeTabs() {
|
|
var counter = 0;
|
|
var langImages = {
|
|
"scala": "img/scala-sm.png",
|
|
"python": "img/python-sm.png",
|
|
"java": "img/java-sm.png"
|
|
};
|
|
$("div.codetabs").each(function() {
|
|
$(this).addClass("tab-content");
|
|
|
|
// Insert the tab bar
|
|
var tabBar = $('<ul class="nav nav-tabs" data-tabs="tabs"></ul>');
|
|
$(this).before(tabBar);
|
|
|
|
// Add each code sample to the tab bar:
|
|
var codeSamples = $(this).children("div");
|
|
codeSamples.each(function() {
|
|
$(this).addClass("tab-pane");
|
|
var lang = $(this).data("lang");
|
|
var image = $(this).data("image");
|
|
var notabs = $(this).data("notabs");
|
|
var capitalizedLang = lang.substr(0, 1).toUpperCase() + lang.substr(1);
|
|
var id = "tab_" + lang + "_" + counter;
|
|
$(this).attr("id", id);
|
|
if (image != null && langImages[lang]) {
|
|
var buttonLabel = "<img src='" +langImages[lang] + "' alt='" + capitalizedLang + "' />";
|
|
} else if (notabs == null) {
|
|
var buttonLabel = "<b>" + capitalizedLang + "</b>";
|
|
} else {
|
|
var buttonLabel = ""
|
|
}
|
|
tabBar.append(
|
|
'<li><a class="tab_' + lang + '" href="#' + id + '">' + buttonLabel + '</a></li>'
|
|
);
|
|
});
|
|
|
|
codeSamples.first().addClass("active");
|
|
tabBar.children("li").first().addClass("active");
|
|
counter++;
|
|
});
|
|
$("ul.nav-tabs a").click(function (e) {
|
|
// Toggling a tab should switch all tabs corresponding to the same language
|
|
// while retaining the scroll position
|
|
e.preventDefault();
|
|
var scrollOffset = $(this).offset().top - $(document).scrollTop();
|
|
$("." + $(this).attr('class')).tab('show');
|
|
$(document).scrollTop($(this).offset().top - scrollOffset);
|
|
});
|
|
}
|
|
|
|
|
|
// A script to fix internal hash links because we have an overlapping top bar.
|
|
// Based on https://github.com/twitter/bootstrap/issues/193#issuecomment-2281510
|
|
function maybeScrollToHash() {
|
|
if (window.location.hash && $(window.location.hash).length) {
|
|
var newTop = $(window.location.hash).offset().top - 57;
|
|
$(window).scrollTop(newTop);
|
|
}
|
|
}
|
|
|
|
$(function() {
|
|
codeTabs();
|
|
// Display anchor links when hovering over headers. For documentation of the
|
|
// configuration options, see the AnchorJS documentation.
|
|
anchors.options = {
|
|
placement: 'right'
|
|
};
|
|
anchors.add();
|
|
|
|
$(window).bind('hashchange', function() {
|
|
maybeScrollToHash();
|
|
});
|
|
|
|
// Scroll now too in case we had opened the page on a hash, but wait a bit because some browsers
|
|
// will try to do *their* initial scroll after running the onReady handler.
|
|
$(window).on('load', function() { setTimeout(function() { maybeScrollToHash(); }, 25); });
|
|
});
|