blob: 11d10ac1931dbdd5395d0e0bba87c29bd1e0a3f2 [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001// Copyright 2016 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Copybara854996b2021-09-07 19:36:02 +00004
5/**
6 * @fileoverview Simple functions for dismissible on-page help ("cues").
7 */
8
9/**
10 * Dimisses the cue. This both updates the DOM and hits the server to
11 * record the fact that the user has dismissed it, so that it won't
12 * be shown again.
13 *
14 * If no security token is present, only the DOM is updated and
15 * nothing is recorded on the server.
16 *
17 * @param {string} cueId The identifier of the cue to hide.
18 * @return {boolean} false to cancel any event.
19 */
20function CS_dismissCue(cueId) {
21 let cueElements = document.querySelectorAll('.cue');
22 for (let i = 0; i < cueElements.length; ++i) {
23 cueElements[i].style.display = 'none';
24 }
25
26 if (CS_env.token) {
27 window.prpcClient.call(
28 'monorail.Users', 'SetUserPrefs',
29 {prefs: [{name: cueId, value: 'true'}]});
30 }
31 return false;
32}
33
34// Exports
35_CS_dismissCue = CS_dismissCue;