1function ncore_getElementsByClass( searchClass, domNode, tagName) { 2 if (domNode == null) domNode = document; 3 if (tagName == null) tagName = '*'; 4 var el = new Array(); 5 var tags = domNode.getElementsByTagName(tagName); 6 var tcl = " "+searchClass+" "; 7 for(i=0,j=0; i<tags.length; i++) { 8 var test = " " + tags[i].className + " "; 9 if (test.indexOf(tcl) != -1) 10 el[j++] = tags[i]; 11 } 12 return el; 13} 14 15function ncore_setupJsForAllInputTypes() 16{ 17 ncore_initCheckbox(); 18 ncore_initCheckboxList(); 19 ncore_initTimeSelector(); 20 ncore_initSelectableImageList(); 21} 22 23function ncore_setupJsInputColorPicker() { 24 25 var obj = ncoreJQ('input[data-ncore-colorpicker]'); 26 27 if (typeof obj.wpColorPicker != 'undefined') 28 { 29 obj.wpColorPicker(); 30 } 31} 32 33 34function ncore_initSelectableImageList() 35{ 36 ncoreJQ('.ncore-selectable-image-list .list-item[data-tooltip]').each(function() { 37 var $this = ncoreJQ(this); 38 var tt = $this.attr('data-tooltip'); 39 $this.tooltip({ 40 items: '.ncore-selectable-image-list .list-item', 41 content: function() { return tt; }, 42 tooltipClass: 'ncore_jquery-ui-tooltip' 43 }); 44 }); 45 46 ncoreJQ('.ncore-selectable-image-list .list-row .list-item').on('click.ncore',function() { 47 var $this = ncoreJQ(this); 48 var name = $this.attr('data-name'); 49 var value = $this.attr('data-value'); 50 51 ncoreJQ('input[name="' + name + '"]').val(value).change(); 52 53 $this.parent().parent().find('.list-item').removeClass('selected'); 54 $this.addClass('selected'); 55 }); 56 57 ncoreJQ('.ncore-selectable-image-list .list-item.selected').click(); 58} 59 60function ncore_initTimeSelector() 61{ 62 ncoreJQ('select[data-time-select]').on('change.ncore',function() { 63 var $this = ncoreJQ(this); 64 var name = $this.attr('data-name'); 65 var $hidden = ncoreJQ('input[data-name="' + name + '"]'); 66 67 var hours = ncoreJQ('select[data-time-select="hours"][data-name="' + name + '"]').val(); 68 var minutes = ncoreJQ('select[data-time-select="minutes"][data-name="' + name + '"]').val(); 69 var seconds = ncoreJQ('select[data-time-select="seconds"][data-name="' + name + '"]').val(); 70 71 var str = ''; 72 if ($hidden.attr('data-time-hours') === '1') { 73 hours = (parseInt(hours) < 10) ? '0' + hours : hours; 74 str += hours; 75 if ($hidden.attr('data-time-seconds') === '1' || $hidden.attr('data-time-minutes') === '1') { 76 str += ':'; 77 } 78 } 79 if ($hidden.attr('data-time-minutes') === '1') { 80 minutes = (parseInt(minutes) < 10) ? '0' + minutes : minutes; 81 str += minutes; 82 if ($hidden.attr('data-time-seconds') === '1') { 83 str += ':'; 84 } 85 } 86 if ($hidden.attr('data-time-seconds') === '1') { 87 seconds = (parseInt(seconds) < 10) ? '0' + seconds : seconds; 88 str += seconds; 89 } 90 91 ncoreJQ('input[name="' + name + '"]').val(str); 92 }); 93 ncoreJQ('input[data-time-select]').on('change.ncore',function() { 94 var $this = ncoreJQ(this); 95 var name = $this.attr('data-name'); 96 var value = $this.val(); 97 var hours = $this.attr('data-time-hours'); 98 var minutes = $this.attr('data-time-minutes'); 99 var seconds = $this.attr('data-time-seconds'); 100 101 var spl = value.split(':'); 102 103 if (hours === '1' && minutes === '1' && seconds === '1') { 104 ncoreJQ('select[data-time-select="hours"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[0],'0')); 105 ncoreJQ('select[data-time-select="minutes"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[1],'0')); 106 ncoreJQ('select[data-time-select="seconds"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[2],'0')); 107 } 108 else if (hours === '1' && minutes === '1' && seconds === '0') { 109 ncoreJQ('select[data-time-select="hours"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[0],'0')); 110 ncoreJQ('select[data-time-select="minutes"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[1],'0')); 111 } 112 else if (hours === '0' && minutes === '1' && seconds === '1') { 113 ncoreJQ('select[data-time-select="minutes"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[0],'0')); 114 ncoreJQ('select[data-time-select="seconds"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[1],'0')); 115 } 116 else if (hours === '1' && minutes === '0' && seconds === '0') { 117 ncoreJQ('select[data-time-select="seconds"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[0],'0')); 118 } 119 else if (hours === '0' && minutes === '1' && seconds === '0') { 120 ncoreJQ('select[data-time-select="minutes"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[0],'0')); 121 } 122 else if (hours === '0' && minutes === '0' && seconds === '1') { 123 ncoreJQ('select[data-time-select="seconds"][data-name="' + name + '"]').val(ncore.helpers.string.ltrim(spl[0],'0')); 124 } 125 }); 126 ncoreJQ('select[data-time-select]').change(); 127} 128 129function ncore_initCheckbox() 130{ 131 ncoreJQ( 'input.ncore_checkbox').off('change').on( 'change', function() { 132 133 var checkbox_postname = ncoreJQ( this ).attr( 'name' ); 134 135 // checkbox_ -> 9 chars 136 var postname = checkbox_postname.substring( 9 ); 137 138 var checked = this.checked; 139 140 var value; 141 142 if (checked) 143 { 144 value = ncoreJQ( this ).attr( 'data-value-checked' ); 145 if (!value) { 146 value = 1; 147 } 148 } 149 else 150 { 151 value = ncoreJQ( this ).attr( 'data-value-unchecked' ); 152 if (!value) { 153 value = 0; 154 } 155 } 156 157 var obj = ncoreJQ(this).parent('span.ncore_checkbox').find( 'input[name="' + postname + '"]'); // in case of error, replace parent() by parents() 158 obj.val( value ); 159 obj.trigger( 'change' ); 160 } ); 161} 162 163 164 165 166function ncore_initCheckboxList() 167{ 168 ncoreJQ( 'input.ncore_checkbox_list').off('change').on( 'change', function() { 169 170 var checkbox_postname = ncoreJQ( this ).attr( 'name' ); 171 172 // checkbox_ -> 9 chars 173 var postname = checkbox_postname.substring( 9 ); 174 175 var all_checked = false;
176 177 var father = ncoreJQ(this).parentsUntil('div.ncore_checkbox_list').parent(); 178 var checkboxes = father.find('input.ncore_checkbox_list[name="' + checkbox_postname + '"]' ); 179 180 checkboxes.each( function( index, obj ) { 181 if (obj.checked && obj.value=='all') 182 { 183 all_checked = true; 184 } 185 } ); 186 187 var value=''; 188 checkboxes.each( function( index, obj ) { 189 190 if (obj.checked) { 191 if (value) value += ','; 192 value += obj.value; 193 } 194 195 var css_checked = obj.checked || all_checked; 196 if (css_checked) { 197 ncoreJQ(obj).parent().removeClass('ncore_unchecked'); 198 ncoreJQ(obj).parent().addClass('ncore_checked'); 199 } 200 else 201 { 202 ncoreJQ(obj).parent().removeClass('ncore_checked'); 203 ncoreJQ(obj).parent().addClass('ncore_unchecked'); 204 } 205 } ); 206 207 var obj = father.find( 'input[name="' + postname + '"]'); 208 obj.val( value ); 209 obj.trigger( 'change' ); 210 } ); 211 212 ncoreJQ('div.ncore_checkbox_list input[type="hidden"]').off('change').on('change',function() { 213 var $this = ncoreJQ(this); 214 var value = $this.val(); 215 216 var spl = value.split(','); 217 $this.parent().find('input[type="checkbox"]').prop('checked',false).parent().addClass('ncore_unchecked').removeClass('ncore_checked'); 218 for (var i in spl) { 219 $this.parent().find('input[type="checkbox"][value="' + spl[i] + '"]').prop('checked',true).parent().addClass('ncore_checked').removeClass('ncore_unchecked'); 220 } 221 }); 222} 223 224function ncore_windowOpenPosition( width, height ) 225{ 226 var specs = 'height=' + height + ',width=' + width; 227 228 var w = window, 229 d = document, 230 e = d.documentElement, 231 g = d.getElementsByTagName('body')[0], 232 x = w.innerWidth || e.clientWidth || g.clientWidth, 233 y = w.innerHeight|| e.clientHeight|| g.clientHeight, 234 235 l = w.screenLeft || w.screenX, 236 t = w.screenTop || w.screenY; 237 238 var left = l + Math.round((x-width)/2); 239 var top = t + Math.round((y-height)/2); 240 241 specs += ',left=' + left + ',top=' + top; 242 243 return specs; 244 245} 246 247function ncore_urlBase64ToUint8Array(base64String) { 248 const padding = '='.repeat((4 - base64String.length % 4) % 4); 249 const base64 = (base64String + padding) 250 .replace(/\-/g, '+') 251 .replace(/_/g, '/'); 252 253 const rawData = window.atob(base64); 254 const outputArray = new Uint8Array(rawData.length); 255 256 for (var i = 0; i < rawData.length; ++i) { 257 outputArray[i] = rawData.charCodeAt(i); 258 } 259 return outputArray; 260} 261 262 263function ncore_canShowByCookieCount( basename, max_count, max_days, do_increase_counter ) 264{ 265 var is_initialized = parseInt( ncore_readCookie( 'dm_' + basename + '_initialized' ) ); 266 var counts_so_far = parseInt( ncore_readCookie( 'dm_' + basename + '_count' ) ); 267 268 if (isNaN(is_initialized)) { 269 is_initialized = 0; 270 } 271 if (isNaN(counts_so_far)) { 272 counts_so_far = 0; 273 } 274 275 var must_reset = !is_initialized; 276 277 if (must_reset) 278 { 279 ncore_createCookie( 'dm_' + basename + '_initialized', 1, max_days ); 280 ncore_createCookie( 'dm_' + basename + '_count', 0, max_days+1 ); 281 282 return true; 283 } 284 285 var can_show = counts_so_far < max_count; 286 287 if (can_show && typeof do_increase_counter != 'undefined' && do_increase_counter) 288 { 289 ncore_createCookie( 'dm_' + basename + '_count', counts_so_far+1, max_days+1 ); 290 } 291 292 return can_show; 293} 294 295 296 297function ncore_createCookie(name,value,days) { 298 if (days) { 299 var date = new Date(); 300 date.setTime(date.getTime()+(days*24*60*60*1000)); 301 var expires = "; expires="+date.toGMTString(); 302 } 303 else var expires = ""; 304 document.cookie = name+"="+value+expires+"; path=/"; 305} 306 307function ncore_readCookie(name) { 308 var nameEQ = name + "="; 309 var ca = document.cookie.split(';'); 310 for(var i=0;i < ca.length;i++) { 311 var c = ca[i]; 312 while (c.charAt(0)==' ') c = c.substring(1,c.length); 313 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 314 } 315 return null; 316} 317 318function ncore_eraseCookie(name) { 319 createCookie(name,"",-1); 320} 321 322function ncore_copyShortcodeToClipboard(type, id) { 323 var shortcode = '[ds_'+type+' id="'+id+'"]'; 324 if (!navigator.clipboard) {
325 ncore_fallbackCopyTextToClipboard(shortcode, id); 326 return; 327 } 328 navigator.clipboard.writeText(shortcode).then(function() {}, function(err) {}); 329} 330 331function ncore_fallbackCopyTextToClipboard(text, id) { 332 var textArea = document.createElement("textarea"); 333 textArea.value = text; 334 textArea.style.top = "0"; 335 textArea.style.left = "0"; 336 textArea.style.position = "fixed"; 337 document.body.appendChild(textArea); 338 textArea.focus(); 339 textArea.select(); 340 try { 341 document.execCommand('copy'); 342 } catch (err) {} 343 document.body.removeChild(textArea); 344} 345 346function ncore_fallbackCopyValueToClipboard(text) { 347 var textArea = document.createElement("textarea"); 348 textArea.value = text; 349 textArea.style.top = "0"; 350 textArea.style.left = "0"; 351 textArea.style.position = "fixed"; 352 document.body.appendChild(textArea); 353 textArea.focus(); 354 textArea.select(); 355 try { 356 document.execCommand('copy'); 357 } catch (err) {} 358 document.body.removeChild(textArea); 359} 360 361function ncore_copyTooltipInputToClipboard(e, linkElement) { 362 e.preventDefault(); 363 var elementValue = linkElement.firstChild.value; 364 if (!navigator.clipboard) { 365 ncore_fallbackCopyValueToClipboard(elementValue); 366 return; 367 } 368 navigator.clipboard.writeText(elementValue).then(function() {}, function(err) {}); 369} 370 371function ncore_switchElementAttribute(element, attribute, change, back = false, timer = false) { 372 element.setAttribute(attribute, change); 373 if (back && timer) { 374 setTimeout(() => { 375 element.setAttribute(attribute, back); 376 }, timer); 377 } 378} 379 380function ncore_switchElementTooltip(element, attribute, change, back = false, timer = false) { 381 element.setAttribute(attribute, change); 382 if (back && timer) { 383 setTimeout(() => { 384 element.setAttribute(attribute, back); 385 }, timer); 386 } 387} 388
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.