1var debug = false; 2 3jQuery(document).ready(function($) { 4 $('[tagData]').cascade().bindHtml(true); 5 // $('[data-tag]').cascade().bindHtml(true); 6}); 7 8(function(jQuery) { 9 10 var jQueryVersion = parseInt(jQuery.fn.jquery.split('.').join('')); 11 var $ = jQuery.sub(); 12 13 jQuery.fn.cascade = function() { 14 return $(this); 15 }; 16 17 $.fn.extend({ 18 bindHtml: bindHtml, 19 triggerCascade: triggerCascade, 20 createEventX: createEventX 21 }); 22 23 /** jQuery */ var context = new Context(); 24 /** jQuery */ var eventQueue = []; 25 26 /** set handlers from html attributes */ 27 function bindHtml(cascade, clear) { 28 if(clear === undefined){ 29 clear = true; 30 } 31 log('bindHtml() cascade=%s', cascade); 32 if(clear){ 33 context.clear(); 34 } 35 this.each(function() { 36 for (var i = 0; i < this.attributes.length; i++) { 37 var attrX = new AttrX(this.attributes[i]); 38 if (attrX.isEventHandler) { 39 if(jQueryVersion <= 174) { 40 41 $(this).unbind(attrX.event); // > 1.7, unbind() 42 $(this).bind(attrX.event, getBindHandler(cascade, attrX.handler, attrX.params)); // > 1.7, bind() 43 44 } else { 45 46 $(this).off(attrX.event); 47 $(this).on(attrX.event, getBindHandler(cascade, attrX.handler, attrX.params)); 48 }; 49 50 context.push(attrX.event.toLowerCase(), this); 51 } 52 } 53 if(jQueryVersion <= 174) { 54 55 $(this).data('_path', $(this).parents().andSelf().get()); 56 57 } else { 58 59 $(this).data('_path', $(this).parents().addBack().get()); 60 61 } 62 }); 63 log('context count:%d', context.count()); 64 } 65 66 function getBindHandler(cascade, handlerName, handlerParams) { 67 var handler = window[handlerName]; 68 if (!cascade) { 69 return $.proxy(handler, this); // not uses handlerParams 70 } else if (handler === undefined) { 71 return function(e) { 72 e.params = handlerParams; 73 triggerCascade(createEventX(handlerName.toLowerCase(), this, e)); 74 return false; 75 } 76 } else { 77 return function(e, p) { 78 log('call %s %s', handlerName, handlerParams); 79 var result = handler.call(this, e, handlerParams); 80 if (typeof result === 'string') { 81 triggerCascade(createEventX(result.toLowerCase(), this, e)); 82 } else if (typeof result === 'boolean') { 83 return result; 84 } 85 return false; 86 } 87 } 88 } 89 90 /** trigger event to all document tag (in some context) */ 91 function triggerCascade(/** Event */ event) { 92 log('add event %s',event.type); 93 eventQueue.push(event); 94 if (eventQueue.length > 1) { 95 return; 96 } 97 log('begin triggerCascade'); 98 while (eventQueue.length > 0) { 99 /** Event */ var e = eventQueue[0]; 100 101 var subContext = context.get(e.type); 102 if (subContext === undefined) { 103 eventQueue.shift(); 104 continue; 105 } 106 for (i = 0; i < subContext.length; i++) { 107 var tag = subContext[i]; 108 tag._position = comparePaths($(e.target).data('_path'), $(tag).data('_path')) 109 } 110 subContext.sort(function($1, $2) { 111 return Position.compare($1._position, $2._position); 112 }); 113 114 for (var i = 0; i < subContext.length; i++) { 115 if(jQueryVersion <= 174) { 116 117 $.event.trigger(e, e.result, subContext[i]); // jquery 1.7.4 118 119 } else { 120 121 console.log(e.tagData); 122 123 $(subContext[i]).trigger(e.type, [e, e.result]); 124 125 }; 126 if (e.isImmediatePropagationStopped() || $(subContext[i]).attr('data-stop') === 'true') { 127 $(subContext[i]).attr('data-stop',''); 128 break; 129 } 130 } 131 eventQueue.shift(); 132 } 133 log('end triggerCascade'); 134 } 135 136 function createEventX(/**String*/name, /**HTMLElement*/target, /**Event*/e) { 137 var event = $.Event(name); 138 event.preventDefault(); 139 event.stopPropagation(); 140 event.target = target; 141 event.resultX = e?e.resultX:{}; 142 event.params = e?e.params:{}; 143 event.tagData = e ? e.tagData:{}; 144 145 // log('createEventX() name=%s,target=%s', event.type, event.target); 146 return event; 147 } 148 149 /** Class extract event-handler data from html elements */ 150 function AttrX(/**Attr*/attr) { 151 this.name = attr.name; 152 this.value = attr.value; 153 154 this.isEventHandler = this.name.substring(0, 3) == 'on_'; 155 if (this.isEventHandler) { 156 this.event = this.name.substring(3).toLowerCase(); 157 158 var rgx = /(\w+)\((.+)\)/.exec(this.value); 159 if (rgx != null && rgx.length == 3) { 160 this.handler = rgx[1]; 161 this.params = rgx[2].split(','); 162 } else { 163 this.handler = this.value; 164 } 165 //log('constructor AttrX() is=%s,event=%s,handler=%s,params=%s', this.isEventHandler, this.event, this.handler, this.params); 166 } 167 } 168 169 /** Class contains cascade tag handlers */ 170 function Context() { 171 this.bag = {}; 172 } 173 174 Context.prototype.clear = function() { 175 var countBefore = this.count(); 176 for (var events in this.bag) { 177 var tags = this.bag[events]; 178 for (var i = tags.length - 1; i >= 0; i--) { 179 var $root = $(tags[i]).parents('html'); 180 if ($root.length == 0) { 181 tags.splice(i, 1); 182 } 183 } 184 } 185 log('Context.clear() %d', countBefore - this.count()); 186 }; 187 Context.prototype.count = function() { 188 var x = 0; 189 for (var eventTags in this.bag) { 190 x += this.bag[eventTags].length; 191 } 192 return x; 193 }; 194 Context.prototype.get = function(event) { 195 return this.bag[event]; 196 }; 197 Context.prototype.push = function(event, tag) { 198 if (this.bag[event] == undefined) { 199 this.bag[event] = []; 200 } 201 for (var i = 0; i < this.bag[event].length; i++) { 202 if (this.bag[event][i] == tag) { 203 return; 204 } 205 } 206 this.bag[event].push(tag); 207 }; 208 209 /** Class define relative position beetwin two elements */ 210 function Position(direction1, distance1, indirect_deep1) { 211 this.direction = direction1; 212 this.distance = distance1; 213 this.indirect_deep = indirect_deep1; 214 } 215 216 Position.prototype.SELF = 0; 217 Position.prototype.CHILD = 1; 218 Position.prototype.PARENT = 2; 219 Position.prototype.INDIRECT = 3; 220 Position.compare = function(p1, p2) { 221 if (p1.direction != p2.direction) { 222 return p1.direction - p2.direction; 223 } else if (p1.distance != p2.distance) { 224 return p1.distance - p2.distance; 225 } else { 226 return p1.indirect_deep - p2.indirect_deep; 227 } 228 }; 229 function comparePaths($path0, $path2) { 230 if ($path0 == undefined) { 231 return new Position(0, 0, 0);
231 //Position.SELF - event were generated without target 232 } 233 234 if (($path0 == undefined) || ($path2 == undefined)) { 235 log('Using html tag with not set tagData=""'); 236 } 237 var l = 0; 238 while (l < $path0.length && l < $path2.length && $path0[l] == $path2[l]) { 239 l++; 240 } 241 var distance = Math.abs($path0.length - l); 242 if (distance == 0) { 243 return new Position(0, 0, 0); //Position.SELF 244 } else if (l == $path0.length) { 245 return new Position(1, distance, 0); //Position.CHILD 246 } else if (l == $path2.length) { 247 return new Position(2, distance, 0); // Position.PARENT 248 } else { 249 return new Position(3, distance, $path2.length); //Position.INDIRECT 250 } 251 } 252})($); 253 254/* todo 255 поддеÑжка неÑколÑÐºÐ¸Ñ Ð¾ÑеÑедей ÑобÑÑий 256 ÑделаÑÑ getBindHandler(cascade, handlerName) внеÑним инÑеÑÑейÑом, Ð´Ð»Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ Ð² каÑкад не html-обÑабоÑÑиков 257 заÑиÑÑиÑÑ Ð¿ÐµÑÐµÐ²Ð¾Ð´Ñ DOM <-> $ 258 // Ð´Ð»Ñ Ð¾ÑÐ¼ÐµÐ½Ñ Ð¿ÑÐ¾Ð´Ð¾Ð»Ð¶ÐµÐ½Ð¸Ñ Ð¸ÑÐ¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ ÑобÑÑий дÑÑгими ÑÑгами иÑполÑзÑеÑÑÑ isImmediatePropagationStopped (дÑÑгой незавиÑимÑй аÑпекÑ) 259 */ 260 261 262function log() { 263// var h = arguments.callee.history; 264// h || (h = ""); 265 if (debug == false) return; 266 var log = document.getElementById('log') || $('<div id="log" style="float:right;" onclick="$(this).empty()"><h3>Log:</h3></div>').appendTo($('body:first')).get(0); 267 var now = new Date(); 268 var date = now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds() + '.' + now.getMilliseconds(); 269 log.innerHTML += '<br/>' + date + ' ' + sprintf.apply(this, arguments); 270 // arguments.callee.history += 271} 272 273//log('handle ' + e.target.id + ':' + e.type + ' (' + this.id + ')'); 274//log('call- ' + e.target.id + ':' + e.type + ':' + subContext[i].id + '(' + eventQueue.length + ')'); 275 276 277var storage = {}; 278 279 280/** обновление блока на ÑÑÑаниÑе */ 281function reload(/**Event*/e, param) { 282 log('reload %s %s %s', typeof this, e.result, param); 283 var tag = this; 284 var $tag = $(this); 285 286 console.log(storage.tagData); 287 288 // e.stopImmediatePropagation(); 289 var data = this.attributes['tagData'].value; //$tag.attr('tagData') 290 data = storage.tagData ? data + '&' + storage.tagData : data; 291 $.post(url, {reload: 'reload', data: data}, function (data) { 292 $tag.html($('#' + tag.id, data).html()); 293 $('[tagData]', $tag).cascade().bindHtml(true); 294 if (param && param[0]) { 295 var e = $(document).cascade().createEventX(param[0].toLowerCase(), tag); 296 $(document).cascade().triggerCascade(e); 297 } 298 }); 299 // return param[0]; 300} 301function reloadCKE(/**Event*/e, param) { 302 log('reload %s %s %s', typeof this, e.result, param); 303 304 var CKEDITORS = []; 305 if(CKEDITOR && CKEDITOR.env.isCompatible) 306 { 307 for(var o in CKEDITOR.instances) 308 if(CKEDITOR.instances[o]){ 309 CKEDITOR.instances[o].destroy(); 310 CKEDITOR.remove(o); 311 CKEDITORS.push(o) 312 } 313 } 314 var tag = this; 315 var $tag = $(this); 316 // e.stopImmediatePropagation(); 317 var data = this.attributes['tagData'].value; //$tag.attr('tagData') 318 data = e.tagData ? data + '&' + e.tagData : data; 319 $.post(url, {reload: 'reload', data: data}, function (data) { 320 $tag.html($('#' + tag.id, data).html()); 321 $('[tagData]', $tag).cascade().bindHtml(true); 322 if (param && param[0]) { 323 var e = $(document).cascade().createEventX(param[0].toLowerCase(), tag); 324 $(document).cascade().triggerCascade(e); 325 } 326 for(var o in CKEDITORS){ 327 CKEDITOR.replace(CKEDITORS[o]); 328 } 329 }); 330 // return param[0]; 331} 332 333 334function reloadStop(/**Event*/e, param) { 335 e.stopImmediatePropagation(); 336 $(this).attr('data-stop', 'true'); 337 reload.call(this, e, param); 338} 339 340function load(/**Event*/e, param) { 341 var tag = this; 342 var $tag = $(this); 343 // e.stopImmediatePropagation(); 344 var data = this.attributes['tagData'].value; //$tag.attr('tagData') 345 data = e.tagData ? data + '&' + e.tagData : data; 346 $.post(url, {load: param[0], data: data}, function (data) { 347 $tag.after(data); 348 $('[tagData]', $tag.next()).cascade().bindHtml(true); 349/* if (param && param[0]) { 350 var e = $(document).cascade().createEventX(param[0].toLowerCase(), tag); 351 $(document).cascade().triggerCascade(e); 352 }*/ 353 }); 354} 355 356 357 358function filterReload(tag, param, id) { 359 var $tag = $(tag); 360 var data1 = $tag.serialize(); 361 362 var rel_el = $('#' + id); 363 var data = rel_el.attr('tagData'); 364 var a=1; 365 $.post(url, {reload: 'reload', data1: data1, data:data}, function (data) { 366 if(!data) return false;
367 rel_el.html($('#' + id, data).html()); 368 $('[tagData]', rel_el).cascade().bindHtml(true); 369 if (param && param[0]) { 370 var e = $(document).cascade().createEventX(param[0].toLowerCase(), tag); 371 $(document).cascade().triggerCascade(e); 372 } 373 return false; 374 }); 375 return false; 376} 377 /** вÑполнение ÐºÐ¾Ð¼Ð°Ð½Ð´Ñ Ð½Ð° ÑеÑвеÑе и генеÑаÑÐ¸Ñ Ð¾Ð´Ð½Ð¾Ð¸Ð¼ÐµÐ½Ð½Ð¾Ð³Ð¾ ÑобÑÑÐ¸Ñ Ð½Ð° ÑÑÑаниÑе */ 378function remote(e, commands) { 379 log('remote %s %s %s', typeof this, e.result, commands); 380 var tag = this; 381 var $tag = $(this); 382 e.stopImmediatePropagation(); 383 $(this).attr('data-stop', 'true'); 384 var data = $tag.attr('tagData'); 385 //if (this instanceof HTMLFormElement) { 386 if (this.tagName == 'FORM') { 387 // data = $tag.serialize(); 388 data = data ? data + '&' + $tag.serialize() : $tag.serialize(); 389 } 390 $.post(url, {command: commands[0], data: data}, function (data) { 391 var next_command = data.indexOf('Exception') < 0 ? commands[0] : commands[1]; 392 var e = $(document).cascade().createEventX(next_command.toLowerCase(), tag, data); 393 $(document).cascade().triggerCascade(e); 394 }); 395} 396 397function submit(e, commands) { 398 //if (this instanceof HTMLFormElement) { 399 if (this.tagName == 'FORM') { 400 if (commands != undefined) { 401 this.action = url + "?command=" + commands[0]; 402 } 403 this.submit(); 404 } 405} 406 407function redirect(e, params) { 408 if (params && params[0]) { 409 document.location.href=params[0]; 410 } 411} 412 413//for sso 414//function remoteRedirect(e, commands) { 415// log('remote %s %s %s', typeof this, e.result, commands); 416// var tag = this; 417// var $tag = $(this); 418// e.stopImmediatePropagation(); 419// var data = $tag.attr('tagData'); 420// if (this instanceof HTMLFormElement) { 421// data = $tag.serialize(); 422// } 423// $.post(url, {command: commands[0], data: data}, function (data) { 424// var next_command = data.indexOf('Exception') < 0 ? commands[0] : commands[1]; 425// var e = $(document).cascade().createEventX(next_command.toLowerCase(), tag, data); 426// // $(document).cascade().triggerCascade(e); 427// location.href(data); 428// }); 429//} 430 431/** поглоÑение ÑобÑÑÐ¸Ñ */ 432function capture(e) { 433 e.stopImmediatePropagation(); 434 $(this).attr('data-stop', 'true'); 435} 436 437/** ÑегенеÑаÑÐ¸Ñ Ð½Ð¾Ð²Ð¾Ð³Ð¾ ÑобÑÑÐ¸Ñ Ñ Ð¿ÐµÑедаÑей паÑамеÑÑов Ð¾Ñ ÑекÑÑего ÑÑга */ 438function carry(/**Event*/e, event) { 439 e.stopImmediatePropagation(); 440 $(this).attr('data-stop', 'true'); 441 e.resultX = { 442 data:this.attributes['tagData'].value, 443 text:this.innerHTML 444 }; 445 return event[0]; 446} 447 448function fillForm(e) { 449 e.stopImmediatePropagation(); 450 $(this).attr('data-stop', 'true'); 451 this.text.value = e.resultX.text; 452 $('[name=id]', this).get(0).value = e.resultX.data; 453} 454 455function js(e, params) { 456 e.stopImmediatePropagation(); 457 $(this).attr('data-stop', 'true'); 458 var next_command = eval(params[0]) ? params[1] : params[2]; 459 if (next_command != undefined) { 460 var e = $(document).cascade().createEventX(next_command.toLowerCase(), this); 461 $(document).cascade().triggerCascade(e); 462 } 463} 464 465function clear(e) { 466 this.reset(); 467} 468 469function show(e) { 470 $(this).css('display', 'inline-block'); 471} 472 473function showStop(e) { 474 e.stopImmediatePropagation(); 475 $(this).attr('data-stop', 'true'); 476 $(this).css('display', 'inline-block'); 477} 478 479function hide(e) { 480 $(this).css('display', 'none'); 481} 482 483function remove(e) { 484 $(this).remove(); 485} 486 487function tabswitch(e, params) { 488 if (e && e.params && params && e.params[0] == params[0]) { 489 $(this).addClass('active'); 490 } else { 491 $(this).removeClass('active'); 492 } 493} 494 495function pageswitch(e, params) { 496 var anchor = $(this).attr('href'), 497 eventName = 'PageSwitch'; 498 499 e.tagData = e.tagData ? e.tagData + '&' : ''; 500 e.tagData += 'attrFrameTag.current=' + params[0]; 501 502 storage.tagData = e.tagData; 503 504 e = $(document).cascade().createEventX(eventName.toLowerCase(), this, e); 505 506 $(document).cascade().triggerCascade(e); 507 508 if(anchor != null && anchor!="") 509 document.location.href=anchor; 510} 511 512function initFromCKEditor(e, instanceName, params) { 513 if(CKEDITOR.env.isCompatible) 514 { 515 var ckeditorText = CKEDITOR.instances[instanceName].getData(); 516 $(this).val(ckeditorText); 517 } 518 var new_event = params && params[0] ? params[0] : 'initFromCKEditor'; 519 return new_event; 520} 521function initCKEditor(e, instanceName, params) { 522 if(CKEDITOR.instances[instanceName]){ 523 CKEDITOR.instances[instanceName].destroy(); 524 CKEDITOR.remove(instanceName); 525 } 526 CKEDITOR.replaceAll(); // ?? ??????, ?? ???????? ?????? ???. TODO: ????? ?????? ? ??????????? ???????? ???????? ?? ??? ?????!!!!!!!!!!!!!! 527 //CKEDITOR.replace(instanceName); 528} 529 530 531function onCtrlEnter(e, params) { 532 if (((e.keyCode == 13) || (e.keyCode == 10)) && (e.ctrlKey == true)) { 533 if (params && params[0]) { 534 return params[0].toLowerCase(); 535 } 536 } 537 return true; 538} 539 540/* 541function ctrl_enter(e, params) 542{ 543 if (((e.keyCode == 13) || (e.keyCode == 10)) && (e.ctrlKey == true)) { 544 var e = $(document).cascade().createEventX(eventName.toLowerCase(), this, e); 545 $(document).cascade().triggerCascade(e); 546 } 547} 548*/ 549 550//function move(e, params) { 551// $(this).css('display', 'none'); 552//} 553 554 555 556//function activate(e, param) { 557// $(this).addClass('active'); 558//// if (param && param[0]) { 559//// var e = $(document).cascade().createEventX(param[0].toLowerCase(), this); 560//// $(document).cascade().triggerCascade(e); 561//// } 562//} 563// 564//function deactivate(e, param) { 565// $(this).removeClass('active'); 566//// if (param && param[0]) { 567//// var e = $(document).cascade().createEventX(param[0].toLowerCase(), this); 568//// $(document).cascade().triggerCascade(e); 569//// } 570//} 571 572//function sso(e) { 573// $.post(url, {command: commands[0], data: data}, function (data) { 574// var next_command = data.indexOf('Exception') < 0 ? commands[0] : commands[1]; 575// var e = $(document).cascade().createEventX(next_command.toLowerCase(), tag, data); 576// $(document).cascade().triggerCascade(e); 577// }); 578//} 579 580function sprintf( ) { // Return a formatted string 581 // 582 // + original by: Ash Searle (http://hexmen.com/blog/) 583 // + namespaced by: Michael White (http://crestidg.com) 584 585 var regex = /%%|%(\d+\$)?([-+#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g; 586 var a = arguments, i = 0, format = a[i++]; 587 588 // pad() 589 var pad = function(str, len, chr, leftJustify) { 590 var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr); 591 return leftJustify ? str + padding : padding + str; 592 }; 593 594 // justify() 595 var justify = function(value, prefix, leftJustify, minWidth, zeroPad) { 596 var diff = minWidth - value.length; 597 if (diff > 0) { 598 if (leftJustify || !zeroPad) { 599 value = pad(value, minWidth, ' ', leftJustify); 600 } else { 601 value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length); 602 } 603 } 604 return value; 605 }; 606 607 // formatBaseX() 608 var formatBaseX = function(value, base, prefix, leftJustify, minWidth, precision, zeroPad) { 609 // Note: casts negative numbers to positive ones 610 var number = value >>> 0; 611 prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || ''; 612 value = prefix + pad(number.toString(base), precision || 0, '0', false); 613 return justify(value, prefix, leftJustify, minWidth, zeroPad); 614 }; 615 616 // formatString() 617 var formatString = function(value, leftJustify, minWidth, precision, zeroPad) { 618 if (precision != null) { 619 value = value.slice(0, precision); 620 } 621 return justify(value, '', leftJustify, minWidth, zeroPad); 622 }; 623 624 // finalFormat() 625 var doFormat = function(substring, valueIndex, flags, minWidth, _, precision, type) { 626 if (substring == '%%') return '%'; 627 628 // parse flags 629 var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false;
630 for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) { 631 case ' ': positivePrefix = ' '; break; 632 case '+': positivePrefix = '+'; break; 633 case '-': leftJustify = true; break; 634 case '0': zeroPad = true; break; 635 case '#': prefixBaseX = true; break; 636 } 637 638 // parameters may be null, undefined, empty-string or real valued 639 // we want to ignore null, undefined and empty-string values 640 if (!minWidth) { 641 minWidth = 0; 642 } else if (minWidth == '*') { 643 minWidth = +a[i++]; 644 } else if (minWidth.charAt(0) == '*') { 645 minWidth = +a[minWidth.slice(1, -1)]; 646 } else { 647 minWidth = +minWidth; 648 } 649 650 // Note: undocumented perl feature: 651 if (minWidth < 0) { 652 minWidth = -minWidth; 653 leftJustify = true; 654 } 655 656 if (!isFinite(minWidth)) { 657 throw new Error('sprintf: (minimum-)width must be finite'); 658 } 659 660 if (!precision) { 661 precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0); 662 } else if (precision == '*') { 663 precision = +a[i++]; 664 } else if (precision.charAt(0) == '*') { 665 precision = +a[precision.slice(1, -1)]; 666 } else { 667 precision = +precision; 668 } 669 670 // grab value using valueIndex if required? 671 var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++]; 672 673 switch (type) { 674 case 's': return formatString(String(value), leftJustify, minWidth, precision, zeroPad); 675 case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad); 676 case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 677 case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 678 case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 679 case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase(); 680 case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad); 681 case 'i': 682 case 'd': { 683 var number = parseInt(+value); 684 var prefix = number < 0 ? '-' : positivePrefix; 685 value = prefix + pad(String(Math.abs(number)), precision, '0', false); 686 return justify(value, prefix, leftJustify, minWidth, zeroPad); 687 } 688 case 'e': 689 case 'E': 690 case 'f': 691 case 'F': 692 case 'g': 693 case 'G': 694 { 695 var number = +value; 696 var prefix = number < 0 ? '-' : positivePrefix; 697 var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())]; 698 var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2]; 699 value = prefix + Math.abs(number)[method](precision); 700 return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform](); 701 } 702 default: return substring; 703 } 704 }; 705 706 return format.replace(regex, doFormat); 707} 708
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.