PageSourceSearch

https://coach.basiqs.com/sites/default/files/js/js_6BNT5QZMV7en3jWfGe1nvReCLn5YKN5Mw9HstnoNmKI.js

js basiqs.com collected 2026-10-02 00:46:43 UTC 13,999 bytes, 359 lines download raw bytes

1(function ($) {
2
3  Drupal.behaviors.questionWidget = {
4
5    attach: function (context) {
6      /*New UI code @Sanjeet*/
7      $(document).ready(function () {
8        /*Triggering edit button by @Sanjeet*/
9        let path = window.location.pathname;
10        let full_path = window.location.href;
11        if (path.includes('/question/') && path.includes('/edit')) {
12          let pathIndex = path.substring(path.lastIndexOf('/') + 1);
13          MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
14          var observer = new MutationObserver(function (mutations, observer) {
15            let root = document.getElementById('game-form-question-add');
16            let items = root.getElementsByTagName('fieldset');
17            for (let i = 0; i < items.length; i++) {
18              if (i !== Number(pathIndex)) {
19                items[i].classList.add('element-hidden-forced')
20              } else {
21                //items[i].style.visibility = "hidden";
22                console.log(items[i])
23              }
24            }
25            const questionListPath = path.substring(0, path.lastIndexOf('question'));
26            const redirect_cond = document.getElementsByClassName('messages status')[0].textContent.includes('Question saved');
27            if (redirect_cond) {
28              var activeNode = document.getElementById('game-form-question-add');
29              if (activeNode)
30                activeNode.style.visibility = 'hidden';
31              window.location = questionListPath;
32                  if (full_path.includes('?page=add_quick')) {
33                  window.location = questionListPath + '?page=add_quick';
34                } else {
35                  window.location = questionListPath
36                }
37            }
38
39
40          });
41          observer.observe(document, { subtree: true, childList: true });
42          var activeNode = document.getElementById('edit-questions-' + pathIndex + '--2');
43          if (activeNode)
44            activeNode.style.visibility = 'visible';
45          var editButton = document.querySelector('#edit-questions-' + pathIndex + '-context-actions-edit');
46          var clickEvent = document.createEvent('MouseEvents');
47          clickEvent.initEvent('mousedown', true, true);
48          editButton.dispatchEvent(clickEvent);
49
50        }
51
52        /*Triggering edit button by @Sanjeet*/
53
54        /*Triggering add button by @Sanjeet*/
55        if (window.location.pathname.includes('/question/') && window.location.pathname.includes('/add')) {
56          var addQuestion = document.querySelector('#edit-questions-add');
57          if (addQuestion) {
58            var clickEvent = document.createEvent('MouseEvents');
59            clickEvent.initEvent('mousedown', true, true);
60            addQuestion.dispatchEvent(clickEvent);
61          }
62          /*Removes all the expanded question*/
63          /*Fixes question from library issue @Sanjeet*/
64          var questionParent = document.getElementById('game-form-question-add');
65          var formElement = questionParent.lastElementChild.lastElementChild;
66          var child = questionParent.lastElementChild.firstElementChild;
67
68          let clonedElement = formElement.previousElementSibling;
69
70          while (child !== formElement && child !== clonedElement) {
71            questionParent.lastElementChild.removeChild(child);
72            child = questionParent.lastElementChild.firstElementChild;
73          }
74
75
76          let edit = document.querySelector('[value^="Edit"]');
77          var eventClick = document.createEvent('MouseEvents');
78          eventClick.initEvent('mousedown', true, true);
79          if (edit)
80            edit.dispatchEvent(eventClick);
81
82          if (clonedElement && clonedElement.nextElementSibling &&
83            clonedElement.nextElementSibling.getAttribute('id') === 'question-form-wrapper') {
84            clonedElement.classList.add('element-hidden-forced')
85          }
86
87          try {
88            const questionListPath = path.substring(0, path.lastIndexOf('question'));
89            const redirect_cond = document.getElementsByClassName('messages status')[0].textContent.includes('Question saved');
90            if (redirect_cond) {
91              var activeNode = document.getElementById('game-form-question-add');
92              if (activeNode)
93                activeNode.style.visibility = 'hidden';
94              window.location = questionListPath;
95            }
96          } catch (e) {
97            //had issue redirecting the page
98          }
99          /*Fixes question from library issue @Sanjeet*/
100
101          /*Hide cancel button*/
102          var cancelButton = document.querySelector('[id^="edit-questions-add-question-context-actions"]');
103          if (cancelButton)
104            cancelButton.classList.add('element-hidden-forced');
105          /*Hide titles and links*/
106          var exampleTitle = document.querySelector('#game-form > div > div.title-examples');
107          if (exampleTitle)
108            exampleTitle.classList.add('element-hidden-forced');
109          var fieldTitle = document.querySelector('#edit-field-title');
110          if (fieldTitle)
111            fieldTitle.classList.add('element-hidden-forced');
112          var gameLinks = document.querySelector('#edit-game-links');
113          if (gameLinks)
114            gameLinks.classList.add('element-hidden-forced')
115
116          /**
117           * Keep the first tab on the question composition section
118           * @type {HTMLElement}
119           */
120          const activeTab = document.getElementById('question-new-tab');
121          if (activeTab) {
122            activeTab.firstElementChild.click();
123          }
124          const tabs = document.querySelector('.nav');
125          if (tabs)
126            tabs.addEventListener('click', function (event) {
127              if (event.target.href.includes('#question-new')) {
128                document.querySelector('.question-detailed-view').classList.add('element-hidden')
129              } else {
130                document.querySelector('.question-detailed-view').classList.remove('element-hidden')
131              }
132            })
133
134        }
135
136        var addButtonContainer = document.getElementsByClassName('btn-add form-submit ajax-processed');
137        if (addButtonContainer) {
138          const addButton = addButtonContainer[0];
139          if (addButton)
140            addButton.classList.add('element-hidden-forced');
141        }
142        /*Triggering add button by @Sanjeet*/
143
144        try {
145          const reload_cond = document.getElementsByClassName('messages alert alert-success alert-dismissible successful-team-delete')[0].textContent.includes('Success!The question was successfully deleted');
146          if (reload_cond) {
147            window.location = path.substring(0, path.lastIndexOf('question'));
148          }
149        } catch (e) {
150
151        }
152
153        try {
154          const content = document.getElementsByClassName('messages status')[0].textContent;
155          const reload_cond = content.includes('Game published') || content.includes('Status changed back to Draft');
156          if (reload_cond) {
157            setTimeout(function () {
158              window.location.reload();
159            }, 1500);
160          }
161        } catch (e) {
162
163        }
164
165      });
166
167      if (window.location.pathname.includes('/game')) {
168        const addGameButton = document.querySelector('#main > ul > li > a');
169        if (addGameButton)
170          document.querySelector('#main > ul > li > a').classList.add('add-question-button')
171      }
172
173      const items = document.querySelectorAll('#edit-container > div > table > tbody > * > * > a');
174      for (let i = 0; i < items.length; i++) {
175        if (items[i].innerText === 'Un-publish') {
176          items[i].classList.add('unpublish');
177        }
178      }
179
180      /**
181       * Change the Question Saved message
182       */
183      /*      if (window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1) === 'game') {
184              const message = document.getElementsByClassName('messages status')[0];
185              if (message)
186                message.textContent = 'Game published';
187            }*/
188
189      /**
190       * Show first tab when adding first question
191       */
192      if (window.location.pathname.includes('/game/add')) {
193        MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
194        const observer = new MutationObserver(function (mutations, observer) {
195          const activeTab = document.getElementById('question-new-tab');
196          if (activeTab) {
197            activeTab.firstElementChild.click();
198          }
199        });
200        observer.observe(document, { subtree: true, childList: true });
201        const tabs = document.querySelector('.nav');
202        if (tabs)
203          tabs.addEventListener('click', function (event) {
204            if (event.target.href.includes('#question-new')) {
205              document.querySelector('.question-detailed-view').classList.add('element-hidden')
206            } else {
207              document.querySelector('.question-detailed-view').classList.remove('element-hidden')
208            }
209          })
210      }
211      /*Fix issue with breadcrumbs back button on publish page*/
212      if (window.location.pathname.includes('/game/') && window.location.pathname.includes('/publish')) {
213        const backButton = document.querySelector('.breadcrumb > a:nth-child(2)');
214        if (backButton)
215          backButton.href = '/game';
216      }
217      /*New UI code @Sanjeet*/
218
219      if (window.location.pathname.includes('GameLeaderboard')) {
220        const breadcrumb = document.querySelector('#main > header > div > a');
221        if (breadcrumb)
222          breadcrumb.href = document.referrer
223      }
224
225      $('#delete-coach').on('click', function(e) {
226        $('#delete-coach-submit').click();
227      });
228
229      // Click the hidden submit form item.
230      $('#delete-team').on('click', function(e) {
231        $('#delete-team-submit').click();
232      });
233
234      $('#delete-game').on('click', function(e) {
235        $('#delete-game-submit').click();
236      });
237
238      /*New UI code @Sanjeet*/
239      $('#delete-question').on('click', function (e) {
240        $('#delete-question-submit').click();
241      });
242      /*New UI code @Sanjeet*/
243
244      $('#MoreInfo').on('click', function (e) {
245        if ($('#edit-moreinfo .fieldset-wrapper').hasClass('in')) {
246          $('#edit-moreinfo .fieldset-wrapper').removeClass('in');
247        } else {
248          $('#edit-moreinfo .fieldset-wrapper').addClass('in');
249        }
250      });
251
252      // Dismiss the success alert after form submission.
253      if ($('.alert-success.alert-dismissible').length == 1) {
254        setTimeout(function() {
255          $('.alert-success.alert-dismissible').fadeOut("slow", function() {
256            $(this).remove();
257          });
258        }, 3000);
259      }
260
261      // Move the delete button to the proper place in the coach table.
262      if ($('#coach-list-table-wrapper').length === 1) {
263        $.each($('.link-submit-button-delete'), function(index, link) {
264          var coach = link.name;
265
266          $('span#' + coach).append(link);
267
268        });
269      }
270
271      // Move the delete button to the proper place in the team list item.
272      if ($('#team-filter-form-wrapper').length == 1) {
273        $.each($('.link-submit-button'), function(index, link) {
274          var group = link.name;
275
276          $('span#' + group).append(link);
277
278        });
279      }
280
281      if ($('#game-list-table-wrapper').length == 1) {
282        $.each($('.link-submit-button-delete'), function (index, link) {
283          var game = link.name;
284
285          $('span#d' + game).append(link);
286
287        });
288      }
289
290      if ($('#game-list-table-wrapper').length == 1) {
291        $.each($('.link-submit-button-publish'), function (index, link) {
292          var game = link.name;
293
294          $('span#p' + game).append(link);
295
296        });
297
298
299      }
300      /*New UI code @Sanjeet*/
301      //Move delete button to proper place in the question list
302      if ($('#questions-list-table-wrapper').length === 1) {
303        $.each($('.link-submit-button'), function (index, link) {
304          const question = link.name;
305          $('span#' + question).append(link);
306        });
307      }
308
309      /*New UI code @Sanjeet*/
310
311      if ($('#questions-list-table-wrapper').length === 1) {
312        $.each($('.link-submit-replace-button'), function (index, link) {
313          const questionq = link.name;
314          $('span#replace-' + questionq).append(link);
315        });
316
317           let full_path = window.location.href;
318
319          if (full_path.includes('?page=add_quick&replaced_id') || full_path.includes('?page=add_quick')) {
320            let urlParams = new URLSearchParams(window.location.search);
321            let myParam = urlParams.get('replaced_id');
322
323              $('input[type="submit"]').click(function(e){
324                if(this.value == 'Replace') {
325                    sessionStorage.setItem("ReplaceValue", this.value);
326                  }
327              });
328
329           if(sessionStorage.getItem("ReplaceValue") == 'Replace'
330           && sessionStorage.getItem("ReplaceValue") != null
331           && myParam !='' ) {
332
333           $('html, body').animate({
334                scrollTop: parseInt($('#replace-' + myParam).position().top)
335                //marginTop: "60px"
336            }, 1000);
337
338
339            $('#replace-' + myParam).parent().parent().addClass('replace-row-bg-color');
340            $("table .replace-row-bg-color td:lt(6):gt(0), table .replace-row-bg-color td:first").addClass('replace-td-bg-color');
341            setTimeout(function() {
342                $('table .replace-row-bg-color td:lt(6):gt(0), table .replace-row-bg-color td:first').removeClass('replace-td-bg-color')
343                $('#replace-' + myParam).parent().parent().removeClass('replace-row-bg-color');
344                sessionStorage.removeItem("ReplaceValue");
345                //$('html, body').css('margin-top', '');
346              },
347              8000);
348           }
349          }
350      }
351    },
352
353    detach: function (context) {
354
355    }
356  }
357
358})(jQuery);
359;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.