-
Notifications
You must be signed in to change notification settings - Fork 14
/
pad.js.sample
155 lines (118 loc) · 4.31 KB
/
pad.js.sample
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
/**
* Some Customizations for the pad in ilias
*
* @author Timon Amstutz <[email protected]>
*
* **/
function customStart()
{
if(is_iOS_Safari() == true)
$("#editorcontainer").addClass("etherpad-lite-ios");
/** Get Params from URL **/
var parameters = getUrlVars();
/** Set language via cookie **/
document.cookie = "language="+parameters["language"]+"; path=/";
/** Get rid of error in view if language is german **/
$("#mycolorpickersave").css({"padding":"2px","min-width":"70px"});
$("#mycolorpickercancel").css({"padding":"2px","min-width":"70px"});
/** Add classes for data-key fields **/
$( "li[data-key='bold']" ).addClass("bold");
$( "li[data-key='italic']" ).addClass("italic");
$( "li[data-key='underline']" ).addClass("underline");
$( "li[data-key='strikethrough']" ).addClass("strikethrough");
$( "li[data-key='insertorderedlist']" ).addClass("insertorderedlist");
$( "li[data-key='insertunorderedlist']" ).addClass("insertunorderedlist");
$( "li[data-key='indent']" ).addClass("indent");
$( "li[data-key='outdent']" ).addClass("outdent");
$( "li[data-key='undo']" ).addClass("undo");
$( "li[data-key='redo']" ).addClass("redo");
$( "li[data-key='clearauthorship']" ).addClass("clearauthorship");
$( "li[data-key='import_export']" ).addClass("import_export");
$( "li[data-key='showTimeSlider']" ).addClass("showTimeSlider");
$( "li[data-key='savedRevision']" ).addClass("savedRevision");
$( "li[data-key='embed']" ).addClass("embed");
$( "li[data-key='settings']" ).addClass("settings");
$( "#myusernameedit" ).prop('readonly', true);
/** Always hide Button for embedLinks (direct Link in Ilias should be used instaed) **/
$(".embed").hide();
/** Hide Settings Button (Settings are made in Ilias with tab settings) **/
$(".settings").hide();
/** Hide export doku wiki (comment this out if this is wanted) **/
$("#exportdokuwikia").hide();
$(".import_export a").removeClass("grouped-left");
$(".showTimeSlider a").removeClass("grouped-middle").addClass("grouped-left");
$("li[data-key='import_export']").after("<li class='separator'></li><li class='separator'></li>");
if(parameters["showStyleBlock"] != "true")
{
$(".bold").hide();
$(".italic").hide();
$(".underline").hide();
$(".strikethrough").hide();
}
if(parameters["showListBlock"] != "true")
{
$(".insertorderedlist").hide();
$(".insertunorderedlist").hide();
$(".indent").hide();
$(".outdent").hide();
}
if(parameters["showRedoBlock"] != "true")
{
$(".undo").hide();
$(".redo").hide();
}
if(parameters["showColorBlock"] != "true")
{
$(".clearauthorship").hide();
}
if(parameters["showHeadingBlock"] != "true")
{
$("#heading-selection").hide();
}
if(parameters["showImportExportBlock"] != "true")
{
$(".import_export").hide();
}
if(parameters["showTimelineBlock"] != "true")
{
$(".showTimeSlider").hide();
$(".savedRevision").hide();
}
}
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
var cookies = getCookiesArray();
if(hashes.length < 2 && cookies["showChat"] != '')
{
var vars = cookies;
} else {
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
document.cookie = hash[0] + "=" + hash[1] + "; path=/";
}
}
return vars;
}
function is_iOS_Safari() {
var ua = window.navigator.userAgent;
var iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
var webkit = !!ua.match(/WebKit/i);
return iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
}
function getCookiesArray() {
var cookies = { };
if (document.cookie && document.cookie != '') {
var split = document.cookie.split(';');
for (var i = 0; i < split.length; i++) {
var name_value = split[i].split("=");
name_value[0] = name_value[0].replace(/^ /, '');
cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
}
}
return cookies;
}