PageSourceSearch

https://www.onetonline.org/libraries/online/online.js

js onetonline.org collected 2026-10-01 08:42:35 UTC 4,793 bytes, 157 lines download raw bytes

1$(function () {
2  
3  var showTransientMessage = function($btn, msg) {
4    $btn.popover({
5        trigger: 'manual',
6        content: msg,
7        placement: 'bottom'
8       });
9    $btn.popover('show');
10    setTimeout(function() {
11      $btn.popover('dispose');
12    }, 5000);
13  };
14    
15  $('.cread-state').val(readCookie('OLstate'));
16  $('.csave-state').on('change', function () {
17    setCookie('OLstate', $(this).val());
18  });
19  $('.cread-zip').val(readCookie('OLzip'));
20  $('.csave-zip').on('change', function () {
21    setCookie('OLzip', $(this).val());
22  });
23  $('.cread-jobsource').val(readCookie('OLjobsource'));
24  $('.csave-jobsource').on('change', function () {
25    setCookie('OLjobsource', $(this).val());
26  });
27  
28  $('.csave-warnmnm').on('change', function () {
29    setCookie('OLwarnmnm', $(this).is(':checked') ? 'true' : 'false');
30  });
31  $('.csave-warnmpp').on('change', function () {
32    setCookie('OLwarnmpp', $(this).is(':checked') ? 'true' : 'false');
33  });
34  $('.csave-warnvets').on('change', function () {
35    setCookie('OLwarnvets', $(this).is(':checked') ? 'true' : 'false');
36  });
37    
38  var syncMilBranch = function () {
39    var $this = $(this);
40    var value = $this.val() || '';
41    var $form = $this.parents('form');
42    
43    $form.find('.milex').hide();
44    $form.find('.milex-' + value).show();
45    $form.find('.milsearch').each(function () {
46      var $this = $(this);
47      $this.attr('placeholder', $this.data('placeholder' + value));
48    });
49  };
50  $('.milbranch').on('change', syncMilBranch);
51  $('.milbranch').trigger('change');
52
53  $('[data-toggle="linkwarn"]').on('click', function (event) {
54    var $t = $(event.currentTarget);
55    var cval = readCookie($t.data('cookie'));
56    if (cval != 'true') {
57      // launch warning popup
58      event.preventDefault();
59      var el = document.querySelector($t.data('bsTarget'));
60      var modal = bootstrap.Modal.getInstance(el);
61      if (!modal)
62        modal = new bootstrap.Modal(el);
63      if (modal)
64        modal.show();
65      return;
66    } else {
67      // visit link directly
68      event.preventDefault();
69      var url = $t.data('track');
70      url += (url.includes('?') ? '&' : '?') + 'date=' + Date.now();
71      var jqxhr = $.ajax({
72          url : url,
73          timeout : 500
74        });
75      
76      jqxhr.always(function() {
77        jqxhr = null;
78        if ($t.attr('target')) {
79          if ($t.attr('target') != '_nopopup') {
80            window.open($t.attr('href'), $t.attr('target'));
81          }
82        } else {
83          window.location.href = $t.attr('href');
84        }
85      });
86    }
87  });
88
89  var clip = new ClipboardJS('.copy-btn');
90  clip.on('success', function(e) {
91    var $btn = $(e.trigger);
92    var msg = $btn.attr('data-success-msg');
93    if (msg) { showTransientMessage($btn, msg); }
94  });
95  clip.on('error', function(e) {
96    var $btn = $(e.trigger);
97    var msg = $btn.attr('data-error-msg');
98    if (msg) { showTransientMessage($btn, msg); }
99  });
100
101  if ($('#customform').length) {
102    var CustomWarnSelected = function () {
103      var has_sels = ($('#customform input[name="c"]:checked').length > 0);
104      $('#customform button[type="submit"]').prop('disabled', !has_sels);
105      if (has_sels) {
106        $('#customwarning').hide();
107      } else {
108        $('#customwarning').show();
109      }
110    }
111    $('#customform input[name="c"]').on('click', CustomWarnSelected);
112    CustomWarnSelected();
113  }
114
115  $('#customform input:checkbox[data-toggle="check-collapse"]').each(function () {
116    var $checkbox = $(this);
117    var $controlled = $($checkbox.data().bsTarget);
118    var $collapse = new bootstrap.Collapse($controlled[0], { toggle: false });
119    $controlled.on('shown.bs.collapse', function () {
120      if (!$controlled.data().controlChecked) {
121        $collapse.hide();
122      }
123    });
124    $controlled.on('hidden.bs.collapse', function () {
125      if ($controlled.data().controlChecked) {
126        $collapse.show();
127      }
128    });
129    
130    var handleCheck = function () {
131      if ($checkbox[0].checked) {
132        $checkbox.attr('aria-expanded', 'true');
133        $controlled.data('controlChecked', true);
134        $collapse.show();
135      } else {
136        $checkbox.attr('aria-expanded', 'false');
137        $controlled.data('controlChecked', false);
138        $collapse.hide();
139      }
140    };
141    $checkbox.on('change', handleCheck);
142    handleCheck();
143  });
144
145  $('#customform').on('submit', function (event) {
146    event.preventDefault();
147    var $this = $(this);
148    var $elements = $this.find('input, select').filter(':visible');
149    var qstring = $elements.serialize();
150    document.location = $this.attr('action') + '?' + qstring;
151  });
152  
153  $('[data-ac-toggle="autocomplete"]').each(function () {
154    $(this).autocomplete(AutocompleteData[$(this).data('acDataset')]);
155  });
156
157});

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.