/usr/share/doc/fcm/etc/fcm.js is in fcm 2016.12.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | /**********************************************************************
* (C) British Crown Copyright 2006-16 Met Office.
*
* This file is part of FCM.
*
* FCM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FCM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FCM. If not, see <http://www.gnu.org/licenses/>.
*
**********************************************************************/
FCM = {};
$(function() {
var TITLE_COLLAPSE = "collapse";
var TITLE_EXPAND = "expand";
var IS_MAIN = true;
// Toggle a collapse/expand image.
function collapse_expand_icon_toggle(anchor) {
var icon = $("span", anchor);
if (icon.attr("title") == TITLE_EXPAND) {
icon.attr("title", TITLE_COLLAPSE);
icon.removeClass("glyphicon-triangle-right");
icon.addClass("glyphicon-triangle-bottom");
anchor.siblings().filter("ul").show();
}
else { // if (icon.attr("title") == "collapse")
icon.attr("title", TITLE_EXPAND);
icon.removeClass("glyphicon-triangle-bottom");
icon.addClass("glyphicon-triangle-right");
anchor.siblings().filter("ul").hide();
}
}
// Add collapse/expand anchor to a ul tree.
function ul_collapse_expand(ul, is_main) {
var nodes = $("li", ul);
nodes.each(function(i) {
var li = $(this);
var li_anchor = li.children().first();
if (!li_anchor.is("a")) {
return;
}
var li_ul = $("> ul", li);
li_ul.hide();
var icon = $("<span/>", {"title": TITLE_EXPAND, "aria-hidden": "true"});
icon.addClass("glyphicon");
icon.addClass("glyphicon-triangle-right");
icon.css("cursor", "pointer");
icon.css("opacity", 0.5);
var anchor = $("<a/>").append(icon);
li.prepend(" ");
li.prepend(anchor);
if (is_main) {
anchor.click(function() {
var href = li_anchor.attr("href");
$.get(
href,
function(data) {
collapse_expand_icon_toggle(anchor);
anchor.unbind("click");
if (content_gen(li, data, href)) {
ul_collapse_expand(li.children().filter("ul"));
anchor.click(function() {
collapse_expand_icon_toggle(anchor);
});
}
else {
icon.css("opacity", 0.1);
}
},
"html"
)
.error(function(b) {
alert(b);
anchor.unbind("click");
icon.css("opacity", 0.1);
});
});
}
else if (li_ul.length) {
anchor.click(function() {
collapse_expand_icon_toggle(anchor);
});
}
else {
icon.css("opacity", 0.1);
}
});
}
// Generate table of content of a document.
function content_gen(root, d, d_href) {
if (d == null) {
d = document;
}
var CONTENT_INDEX_OF = {"h2": 1, "h3": 2, "h4": 3, "h5": 4, "h6": 5};
var stack = [];
var done_something = false;
var headings = $("h2, h3, h4, h5, h6", $(d));
headings.each(function(i) {
if (this.id == null || this.id == "") {
return;
}
var tag_name = this.tagName.toLowerCase();
// Add to table of content
while (CONTENT_INDEX_OF[tag_name] < stack.length) {
stack.shift();
}
while (stack.length < CONTENT_INDEX_OF[tag_name]) {
var node = stack.length == 0 ? root : $("> :last-child", stack[0]);
stack.unshift($("<ul/>").appendTo(node).addClass("list-unstyled"));
}
var href = "#" + this.id;
if (d_href) {
href = d_href + href;
}
var padding = "";
for (var i = 0; i < stack.length; i++) {
padding += " ";
}
stack[0].append($("<li/>").html(padding).append(
$("<a/>", {"href": href}).html($(this).text())
));
// Add a section link as well
if (d == document) {
var section_link_anchor = $("<a/>", {"href": "#" + this.id});
section_link_anchor.addClass("sectionlink");
section_link_anchor.append("\xb6");
$(this).append(section_link_anchor);
}
done_something = true;
});
return done_something;
}
var NODE;
// Top page table of content
NODE = $(".fcm-top-content");
if (NODE) {
ul_collapse_expand(NODE, IS_MAIN);
}
// Table of content
NODE = $(".fcm-page-content");
if (NODE) {
if (content_gen(NODE)) {
ul_collapse_expand(NODE);
}
}
// Display version information
NODE = $(".fcm-version");
if (NODE) {
NODE.text("FCM " + FCM.VERSION);
}
});
|