1/* 2 * legendary.js 3 */ 4if ( typeof LD == "undefined" ) { 5 var LD = {}; 6} 7if ( typeof $ == "undefined" || $ == null ) { 8 var $ = jQuery; 9} 10/* Helper method for slugifying strings */ 11LD.slugify= function(string) { 12 const a = 'à áâäæãåÄÄÄ Ã§ÄÄÄÄèéêëÄÄÄÄÄǵḧîïÃīįìÅḿñÅǹÅôöòóÅøÅõÅá¹ÅÅÃÅÅ¡ÅÈÅ¥ÈûüùúūÇůűųáºáºÃ¿Ã½Å¾ÅºÅ¼Â·/_,:;' 13 const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------' 14 const p = new RegExp(a.split('').join('|'), 'g') 15 16 return string.toString().toLowerCase() 17 .replace(/\s+/g, '-') // Replace spaces with - 18 .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters 19 .replace(/&/g, '-and-') // Replace & with 'and' 20 .replace(/[^\w\-]+/g, '') // Remove all non-word characters 21 .replace(/\-\-+/g, '-') // Replace multiple - with single - 22 .replace(/^-+/, '') // Trim - from start of text 23 .replace(/-+$/, '') // Trim - from end of text 24} 25 26/* Currently unused method for opening details from inside a standard listw widget */ 27LD.openDetails = function(node, basepg) { 28 var recId = $(node).attr("rec-id"); 29 var rNam = $(node).attr("rec-name"); 30 window.location.href='/'+basepg+'/?/view/'+recId+'/'+LD.slugify(rNam); 31} 32
33/* init page method called inline from plugins to instantiate the page */ 34LD.initialized = typeof LD.initialized == "boolean" ? LD.initialized : false; 35LD.profileInitialized = typeof LD.profileInitialized == "boolean" ? LD.profileInitialized : false; 36/*LD.buildListLink = function(list, basepg) { 37 let url = typeof list.URL == "string" && list.URL != null ? list.URL : ""; 38 let itemId = typeof list.LISTID == "number" ? "" : "sf"+list.FILEID+"/"; 39 return url.toLowerCase().indexOf("http") == 0 ? url : '/'+basepg+'/'+itemId+url;//itemId+'/'+LD.slugify( list.NAME ); 40}*/ 41LD.buildListLink = function(list, basepg) { 42 let url = typeof list.URL == "string" && list.URL != null ? list.URL : ""; 43 let id = list.LISTID*1; 44 let itemId = typeof id == "number" && !isNaN(id) ? "" : "sf"+list.FILEID+"/"; 45 return url.toLowerCase().indexOf("http") == 0 ? url : '/'+basepg+'/'+itemId+url;//itemId+'/'+LD.slugify( list.NAME ); 46} 47LD.bookmarkDownloader = null; 48LD.initPage = function() { 49 if ( LD.initialized === true ) return; 50 LD.initialized = true; 51 var basepg = $('[ldl-basepg]').attr("ldl-basepg"); 52 /* overrides the native MYTHYR method for refactoring internal links based on the list object -- this makes the links 53 * internally consistent within the wordpress plugin */ 54 $MYTHYR.buildListLink = function(list) { 55 if ( typeof $MYTHYR.altBuildListLink == "function" ) return $MYTHYR.altBuildListLink( list ); 56 return LD.buildListLink( list, basepg ); 57 } 58 $MYTHYR.widget.profileAnchor = "#ldl-bookmarks-anchor:not([anchor-disabled])"; 59 if ( typeof LD.bookmarkDownloader == "object" && LD.bookmarkDownloader != null && typeof $MYTHYR.bookmarker != "undefined" ) { 60 $MYTHYR.bookmarker.download = LD.bookmarkDownloader; 61 } 62 /* find all instances of attribute [ldl-list-id] and use as the basis for creating an interactive list on the page, using the native MYTHYR list 63 * widget -- see constructor $MYTHYR.widget */ 64 $( '[ldl-list-id]:not(.ignore-core-init)' ).each( function() { 65 var node = $(this); 66 var listId = node.attr( "ldl-list-id" ); 67 var host = node.attr( "ldl-host" ); 68 var views = node.attr("ldl-views"); 69 var dsearch = node.attr( "ldl-dsearch" ) == "true"; 70 var aViews = []; 71 var allowedOpts = ["list","pie","series","map"]; 72 if ( views != null && views.length > 0 ) { 73 var ar = views.split( "," ); 74 for ( var i=0; i<ar.length; i++ ) { 75 var opt = ar[i]; 76 if ( allowedOpts.indexOf( opt ) == -1 ) continue; 77 if ( opt == "map" && typeof google == "undefined" ) continue; 78 aViews.push( opt ); 79 } 80 } 81 if ( aViews.length == 0 ) { 82 aViews = ["list"]; 83 } 84 var cfg = {id:listId, prefix:"ldldata", directory:false, dsearch:dsearch, sorter:false, hideTitle:false, key:"", libhost:host, host:"/wp-admin/admin-ajax.php?action=ldl_relay&mode=estore&url=", views:aViews, ecomAjaxMethod:"POST"}; 85 var qKey = node.attr( "ldl-qkey"); 86 if ( typeof qKey == "string" && qKey != null && qKey.length > 0 ) { 87 cfg.q={key:qKey}; 88 } 89 var profilePg = node.attr( "ldl-profile-page" ); 90 if ( typeof profilePg == "string" && profilePg.length > 0 ) { 91 cfg.profilePath = "/"+profilePg+"/@@RECID@@/@@RECNAME@@"; 92 let dBookmarker = (node.attr( "ldl-bookmarks-enabled" ) == "false"); 93 cfg.disableBookmarker = dBookmarker; 94 } 95 if ( $MYTHYR.isMobile() ) { 96 cfg.chartOptions = {displayLegend:false,hideScales:true,responsive:false,legendPosition:"left",legendLabels:{usePointStyle: true,font:{size:7}},chartFont:{size:11}}; 97 } 98 if (node.attr("ldl-past-versions") == "true" ) cfg.pastVersions = true; 99 $MYTHYR.widget("list",cfg); 100 }); 101 102 /* find all instances of attribute [ldl-estore] and use as the basis for creating an interactive e-store on the page, using the nativ 103 * MYTHYR e-store widget -- see constructor $MYTHYR.estore */ 104 $( '[ldl-estore]').each( function() { 105 var node = $(this); 106 var host = node.attr("ldl-host"); 107 var cfg = {prefix:"ldldata", libHost:host}; 108 var qKey = node.attr( "ldl-qkey"); 109 cfg.esearch = true; 110 cfg.staticFileDetails = true; 111 if ( typeof qKey == "string" && qKey != null && qKey.length > 0 ) { 112 cfg.q={key:qKey}; 113 } 114 cfg.ajaxMethod="POST"; 115 cfg.host="/wp-admin/admin-ajax.php?action=ldl_relay&mode=estore&url="; 116 var limit = node.attr( "ldl-limit" ); 117 if ( limit != null && !isNaN( limit ) && limit*1 >= 10 ) cfg.limit = limit*1; 118 let placeholderText = node.attr("ldl-placeholder"); 119 if ( placeholderText != null && placeholderText.trim().length > 0 ) cfg.searchPlaceholder = placeholderText; 120 $MYTHYR.estore(cfg); 121 }); 122 /* find all instances of attribute ldl-resolve and use as the basis for hyperlinking names of published businesses and executives found 123 * within the body of a post on the page -- this is controlled in the admin tool under Enhanced ... */ 124 $( '[ldl-resolve]').each( function() { 125 var node = $(this); 126 var libHost = node.attr("ldl-host"); 127 var host = '/wp-admin/admin-ajax.php?action=ldl_relay&url='; 128 var postId = node.attr( "ldl-postid" ); 129 var ttl = node.attr("ldl-title"); 130 var dt = node.attr( "ldl-date" ); 131 var cfg = {prefix:"ldlresolve", host:host, libhost:libHost, pageId:postId, pageTitle:ttl, pageDt:dt, firstReferenceOnly:true }; 132 let excl = node.attr("ldl-excl"); 133 if ( excl != null && typeof excl == "string" && excl.length > 0 ) cfg.excludeHandle = excl; 134 let readonly = node.attr("ldl-readonly"); 135 let pgLink = $MYTHYR.resolve.getPageLink(postId); 136 if ( pgLink == null || pgLink.length == 0 || pgLink.indexOf( "?p="+postId ) != -1 ) { 137 /* 20260130 tdf added to prevent storing of scheduled articles */ 138 cfg.readOnly = true; 139 } else if ( readonly != null && typeof readonly == "string" && readonly.length > 0 && node.parent().find(readonly).length > 0 ) { 140 cfg.readOnly = true; 141 } 142 $MYTHYR.resolve(cfg); 143 }); 144 145} 146 147LD.initProfile = function() { 148 if ( LD.profileInitialized === true ) return; 149 LD.profileInitialized = true; 150 var basepg = $('[ldl-basepg]').attr("ldl-basepg"); 151 $MYTHYR.buildListLink = function(list) { 152 if ( typeof $MYTHYR.altBuildListLink == "function" ) return $MYTHYR.altBuildListLink( list ); 153 return LD.buildListLink( list, basepg ); 154 } 155 if ( typeof LD.bookmarkDownloader == "object" && LD.bookmarkDownloader != null && typeof $MYTHYR.bookmarker != "undefined" ) { 156 $MYTHYR.bookmarker.download = LD.bookmarkDownloader; 157 } 158 $( '[ldl-rec-id]' ).each( function() { 159 var node = $(this); 160 var recId = node.attr( "ldl-rec-id" ); 161 let guid = "ldl-profile-interface"; 162 node.attr( "mythyr-widget-guid", guid ); 163 let libhost = node.attr( "ldl-host" ); 164 let host = '/wp-admin/admin-ajax.php?action=ldl_relay&url='; 165 let profilePg = node.attr( "ldl-profile-page" ); 166 let dBookmarker = (node.attr( "ldl-bookmarks-enabled" ) == "false"); 167 let cfg = {guid:guid, host:host, libhost:libhost, prefix:"ldprofile", profileUrl:"/"+profilePg+"/@@RECID@@/@@RECNAME@@", disableBookmarker:dBookmarker}; 168 let includeTimeline = node.attr( "ldl-timeline" ) == "true"; 169 if ( includeTimeline ) { 170 cfg.timelineAnchor = '#ldprofile-timeline'; 171 } 172 $MYTHYR.profile(recId, cfg); 173 }); 174} 175/*LD.recentDocTemplate = '<div class="ldl-profile-recent-row"><figure>@THUMBNAIL@</figure><figcaption>
175<h3 class="article-title"><a href="@LINK@">@TITLE@</a></h3><div class="grid-item-metadata"><span class="author-links"><span class="item-metadata posts-author"><i class="far fa-user-circle"></i><a href="/author/@AUTHORNICE@/">@AUTHORDISPLAY@</a></span><span class="item-metadata posts-date"><i class="far fa-clock"></i>@DATE@</span><span id="ldl-article-bookmarker" rec-id="_@POSTID@" rec-name="" rec-typ="Document"><a class="ldata-rec-bookmark" data-hint="Un-bookmark document" is-bookmarked="true"><span class="icon icon-bookmark"></span> <label></label></a></span><div class="full-item-discription"><div class="post-description"><p>@EXCERPT@</p><div class="aft-readmore-wrapper"><a href="@LINK@" class="aft-readmore">Read More</a></div></div></figcaption><div style="clear:both;"></div></div>';*/ 176 177LD.recentDocTemplate = '<div class="ldl-profile-recent-row"><figure>@THUMBNAIL@</figure><figcaption><h3 class="article-title"><a href="@LINK@">@TITLE@</a></h3><div class="grid-item-metadata"><span class="item-metadata posts-date">@DATE@</span><span class="author-links"><span class="item-metadata posts-author"><a href="/author/@AUTHORNICE@/">@AUTHORDISPLAY@</a></span></span><span id="ldl-article-bookmarker" rec-id="__@POSTID@" rec-name="" rec-typ="Document"><a class="ldata-rec-bookmark" data-hint="Un-bookmark document"><span class="icon icon-bookmark"></span> <label></label></a></span></div><div class="full-item-discription"><div class="post-description"><p>@EXCERPT@</p><div class="aft-readmore-wrapper"><a href="@LINK@" class="aft-readmore">Read More</a></div></div></div></figcaption><div style="clear:both;"></div></div>'; 178 179LD.recentArticlesUI = function(recId, handle) { 180 this.recId = recId; 181 this.postIds = null; 182 if ( typeof recId == "object" ) { 183 this.recId = null; 184 this.postIds = JSON.stringify( recId ).replace("[","").replace("]","").replace(/"/g, ""); 185 } 186 this.parentNode = $(handle); 187 this.limit = typeof recId == "object" ? Math.min( recId.length, 30 ) : LD.recentArticlesUI.limit; 188 this.thumbAlias = LD.recentArticlesUI.thumbAlias; 189 this.offset = 0; 190 this.ele = $('<div class="ldl-recent-articles"></div>'); 191 this.loadbtn = $('<div class="profile-charts-nav"><a class="button load-charts-btn">More posts ...</a></div>'); 192 this.apply = function( docs ) { 193 if ( docs.length > 0 ) $("#ldl-profile-related-posts-intro").show(); 194 for ( let i=0; i<docs.length; i++ ) { 195 let doc = docs[i]; 196 let htm = LD.recentDocTemplate 197 .replace( /@TITLE@/g, doc.post_title ) 198 .replace( /@POSTID@/g, doc.post_id ) 199 .replace( /@LINK@/g, doc.post_permalink ) 200 .replace( '@THUMBNAIL@', (typeof doc.post_thumbnail != "string" ? "" : '<img src="'+doc.post_thumbnail+'" />') ) 201 .replace( /@DATE@/g, doc.post_date ) 202 .replace( /@EXCERPT@/g, doc.post_excerpt ) 203 .replace( /@AUTHORDISPLAY@/g, doc.post_author.display_name ) 204 .replace( /@AUTHORNICE@/g, doc.post_author.user_nicename ); 205 let node = $(htm); 206 node.find( '[rec-name]' ).attr( "rec-name", doc.post_title ); 207 this.ele.append( node ); 208 } 209 if ( docs.length == this.limit ) { 210 this.ele.append( this.loadbtn ); 211 } else { 212 this.loadbtn.hide(); 213 } 214 this.offset += this.limit; 215 } 216 this.build = function() { 217 $.ajax({ 218 method:"POST", 219 url: '/wp-admin/admin-ajax.php?action=ldl_recentposts', 220 data: (this.postIds!=null?'postIds='+this.postIds:'recId='+this.recId)+'&limit='+this.limit+'&offset='+this.offset+'&thumbAlias='+this.thumbAlias, 221 dataType: "json", 222 success:$.proxy( this.apply, this ), 223 error:$.proxy( function() { 224 this.apply( [] ); 225 }, this ) 226 }); 227 } 228 this.init = function() { 229 this.parentNode.append( this.ele ); 230 this.build(); 231 } 232 this.loadbtn.find( "a" ).on( "click", $.proxy( this.build, this ) ); 233 this.getEle = function() { 234 return this.ele; 235 } 236 this.init(); 237} 238LD.recentArticlesUI.limit = 3; 239LD.recentArticlesUI.thumbAlias="thumbnail"; 240 241LD.initBookmarker = function() { 242 if ( typeof LD.bookmarkDownloader == "object" && LD.bookmarkDownloader != null && typeof $MYTHYR.bookmarker != "undefined" ) { 243 $MYTHYR.bookmarker.download = LD.bookmarkDownloader; 244 } 245 $( 'body #ldl-bookmarks-anchor:first' ).each( function() { 246 let node = $(this); 247 let profilePg = node.attr("ldl-profile-page"); 248 let enabled = node.attr("ldl-bk-enabled") == "true"; 249 let hidden = node.attr("ldl-bk-disabled") == "true"; 250 var host = node.attr("ldl-host"); 251 let cfg = {host:host+"/",disabled:!enabled}; 252 if ( hidden ) cfg.hidden = true; 253 if ( typeof $MYTHYR.local.bookmarker == "undefined" ) { 254 $MYTHYR.local.bookmarker = new $MYTHYR.bookmarker("/"+profilePg+"/@@RECID@@/@@RECNAME@@", cfg); 255 $MYTHYR.local.bookmarker.anchorTo(node); 256 } 257 }); 258} 259$( document ).ready(function() { 260 LD.initBookmarker(); 261 LD.initPage(); 262});
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.