MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / setupButtons

Function setupButtons

static/main.ts:141–261  ·  view source on GitHub ↗
(options: CompilerExplorerOptions, hub: Hub)

Source from the content-addressed store, hash-verified

139}
140
141function setupButtons(options: CompilerExplorerOptions, hub: Hub) {
142 const eventHub = hub.createEventHub();
143 const alertSystem = new Alert();
144
145 // I'd like for this to be the only function used, but it gets messy to pass the callback function around,
146 // so we instead trigger a click here when we want it to open with this effect. Sorry!
147 if (options.policies.privacy.enabled) {
148 $('#privacy').on('click', (event, data) => {
149 const modal = alertSystem.alert(data?.title ? data.title : 'Privacy policy', policyDocuments.privacy.text);
150 calcLocaleChangedDate(modal);
151 // I can't remember why this check is here as it seems superfluous
152 if (options.policies.privacy.enabled) {
153 jsCookie.set(options.policies.privacy.key, policyDocuments.privacy.hash, {
154 expires: 365,
155 sameSite: 'strict',
156 });
157 }
158 });
159 }
160
161 if (options.policies.cookies.enabled) {
162 const getCookieTitle = () => {
163 return (
164 'Cookies &amp; related technologies policy<br><p>Current consent status: <span style="color:' +
165 (hasCookieConsented(options) ? 'green' : 'red') +
166 '">' +
167 (hasCookieConsented(options) ? 'Granted' : 'Denied') +
168 '</span></p>'
169 );
170 };
171 $('#cookies').on('click', () => {
172 const modal = alertSystem.ask(getCookieTitle(), policyDocuments.cookies.text, {
173 yes: () => {
174 simpleCooks.callDoConsent.apply(simpleCooks);
175 },
176 yesHtml: 'Consent',
177 no: () => {
178 simpleCooks.callDontConsent.apply(simpleCooks);
179 },
180 noHtml: 'Do NOT consent',
181 });
182 calcLocaleChangedDate(modal);
183 });
184 }
185
186 $('#ui-reset').on('click', () => {
187 sessionThenLocalStorage.remove('gl');
188 hasUIBeenReset = true;
189 window.history.replaceState(null, '', window.httpRoot);
190 window.location.reload();
191 });
192
193 $('#ui-duplicate').on('click', () => {
194 window.open('/', '_blank');
195 });
196
197 $('#changes').on('click', () => {
198 // TODO(jeremy-rifkin): Fix types

Callers 1

startFunction · 0.85

Calls 15

alertMethod · 0.95
askMethod · 0.95
calcLocaleChangedDateFunction · 0.85
getCookieTitleFunction · 0.85
createEventHubMethod · 0.80
applyMethod · 0.80
doneMethod · 0.80
getStoredSettingsMethod · 0.80
SentryCaptureFunction · 0.70
setMethod · 0.65
removeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected