CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/* manual.js Frank Lübeck */
2
3
/* This file contains a few javascript functions which allow to switch
4
between display styles for GAPDoc HTML manuals.
5
If javascript is switched off in a browser or this file in not available
6
in a manual directory, this is no problem. Users just cannot switch
7
between several styles and don't see the corresponding button.
8
9
A style with name mystyle can be added by providing two files (or only
10
one of them).
11
mystyle.js: Additional javascript code for the style, it is
12
read in the HTML pages after this current file.
13
The additional code may adjust the preprocessing function
14
jscontent() with is called onload of a file. This
15
is done by appending functions to jscontentfuncs
16
(jscontentfuncs.push(newfunc);).
17
Make sure, that your style is still usable without
18
javascript.
19
mystyle.css: CSS configuration, read after manual.css (so it can
20
just reconfigure a few details, or overwrite everything).
21
22
Then adjust chooser.html such that users can switch on and off mystyle.
23
24
A user can change the preferred style permanently by using the [Style]
25
link and choosing one. Or one can append '?GAPDocStyle=mystyle' to the URL
26
when loading any file of the manual (so the style can be configured in
27
the GAP user preferences).
28
29
*/
30
31
/* generic helper function */
32
function deleteCookie(nam) {
33
document.cookie = nam+"=;Path=/;expires=Thu, 01 Jan 1970 00:00:00 GMT";
34
}
35
36
/* read a value from a "nam1=val1;nam2=val2;..." string (e.g., the search
37
part of an URL or a cookie */
38
function valueString(str,nam) {
39
var cs = str.split(";");
40
for (var i=0; i < cs.length; i++) {
41
var pos = cs[i].search(nam+"=");
42
if (pos > -1) {
43
pos = cs[i].indexOf("=");
44
return cs[i].slice(pos+1);
45
}
46
}
47
return 0;
48
}
49
50
/* when a non-default style is chosen via URL or a cookie, then
51
the cookie is reset and the styles .js and .css files are read */
52
function overwriteStyle() {
53
/* style in URL? */
54
var style = valueString(window.location.search, "GAPDocStyle");
55
/* otherwise check cookie */
56
if (style == 0)
57
style = valueString(document.cookie, "GAPDocStyle");
58
if (style == 0)
59
return;
60
if (style == "default")
61
deleteCookie("GAPDocStyle");
62
else {
63
/* ok, we set the cookie for path "/" */
64
var path = "/";
65
/* or better like this ???
66
var here = window.location.pathname.split("/");
67
for (var i=0; i+3 < here.length; i++)
68
path = path+"/"+here[i];
69
*/
70
document.cookie = "GAPDocStyle="+style+";Path="+path;
71
/* split into names of style files */
72
var stlist = style.split(",");
73
/* read style's css and js files */
74
for (var i=0; i < stlist.length; i++) {
75
document.writeln('<link rel="stylesheet" type="text/css" href="'+
76
stlist[i]+'.css" />');
77
document.writeln('<script src="'+stlist[i]+
78
'.js" type="text/javascript"></script>');
79
}
80
}
81
}
82
83
/* this adds a "[Style]" link next to the MathJax switcher */
84
function addStyleLink() {
85
var line = document.getElementById("mathjaxlink");
86
var el = document.createElement("a");
87
var oncl = document.createAttribute("href");
88
var back = window.location.protocol+"//"
89
if (window.location.protocol == "http:") {
90
back = back+window.location.host;
91
if (window.location.port != "") {
92
back = back+":"+window.location.port;
93
}
94
}
95
back = back+window.location.pathname;
96
oncl.nodeValue = "chooser.html?BACK="+back;
97
el.setAttributeNode(oncl);
98
var cont = document.createTextNode(" [Style]");
99
el.appendChild(cont);
100
line.appendChild(el);
101
}
102
103
var jscontentfuncs = new Array();
104
105
jscontentfuncs.push(addStyleLink);
106
107
/* the default jscontent() only adds the [Style] link to the page */
108
function jscontent () {
109
for (var i=0; i < jscontentfuncs.length; i++)
110
jscontentfuncs[i]();
111
}
112
113
114