1 2 3var tagrefStack = new Array (); 4var ixTagrefStack = -1; //nothing on stack 5 6function removeDoubleSquareBrackets (s) { 7 if (beginsWith (s, "[" + "[")) { 8 s = stringDelete (s, 1, 2); 9 } 10 if (endsWith (s, "]]")) { 11 s = stringDelete (s, s.length - 1, 2); 12 } 13 14 if (beginsWith (s, "[")) { 15 s = stringDelete (s, 1, 1); 16 } 17 if (endsWith (s, "]")) { 18 s = stringDelete (s, s.length, 1); 19 } 20 21 return (s); 22 } 23function updateTagrefArrows () { 24 25 var flCanLeftArrow = ixTagrefStack > 0; 26 $("#idTagrefLeftArrow").css ("color", (flCanLeftArrow) ? "black" : "silver"); 27 28 var flCanRightArrow = ixTagrefStack < (tagrefStack.length - 1); 29 $("#idTagrefRightArrow").css ("color", (flCanRightArrow) ? "black" : "silver"); 30 31 var title = ""; 32 for (var i = tagrefStack.length - 1; i >= 0; i--) { 33 title += tagrefStack [i] + ", "; 34 } 35 if (title.length > 0) { 36 title = stringDelete (title, title.length - 1, 2); 37 } 38 $("#idTagrefLeftArrow").prop ("title", title); 39 } 40function leftArrowClick () { 41 if (ixTagrefStack > 0) { 42 ixTagrefStack--; 43 viewTagrefDialog (); 44 } 45 else { 46 speakerBeep (); 47 } 48 } 49function rightArrowClick () { 50 if (ixTagrefStack < (tagrefStack.length - 1)) { 51 ixTagrefStack++; 52 viewTagrefDialog (); 53 } 54 else { 55 speakerBeep (); 56 } 57 } 58 59function tagrefDialogClose () { 60 $("#idTagrefDialog").modal ("hide"); 61 } 62function setupTagrefDialogTemplate (callback) { 63 const urlDialogHtml = "https://s3.amazonaws.com/scripting.com/code/tagrefdialog/dialog.html"; //2/3/23 by DW 64 function showDialog () { 65 $("#idTagrefDialog").modal ("show"); 66 if (callback !== undefined) { 67 callback (); 68 } 69 } 70 if ($("#idTagrefDialog").length == 0) { //hasn't been loaded yet 71 readHttpFile (urlDialogHtml, function (htmltext) { 72 $("body").prepend (htmltext); 73 showDialog (); 74 $("#idTagrefLeftArrow").click (function () { 75 console.log ("You clicked on the left arrow."); 76 leftArrowClick (); 77 $(this).blur (); 78 $(".divTagrefArrows").blur (); 79 }); 80 $("#idTagrefRightArrow").click (function () { 81 console.log ("You clicked on the right arrow."); 82 $(this).blur (); 83 $(".divTagrefArrows").blur (); 84 rightArrowClick (); 85 }); 86 }); 87 } 88 else { 89 showDialog (); 90 } 91 } 92function viewTagrefDialog () { 93 var theTag = tagrefStack [ixTagrefStack]; 94 console.log ("tagrefDialog: theTag == " + theTag); 95 setupTagrefDialogTemplate (function () { 96 theTag = removeDoubleSquareBrackets (theTag); 97 var title = "Hooray for Tag Refs!"; 98 var url = "http://tags.scripting.com/gettagrefsjson?tag=" + urlEncode (theTag); 99 const urlDialogHtml = "https://s3.amazonaws.com/scripting.com/code/tagrefdialog/dialog.html"; //2/3/23 by DW 100 updateTagrefArrows (); 101 readHttpFile (url, function (jsontext) { 102 var theDialogBody = $("<div class=\"divTagrefDialogBody\"></div>"); 103 function add (objToAppend) { 104 $(theDialogBody).append (objToAppend); 105 } 106 if (jsontext === undefined) { 107 add ("There was a problem getting information from the tags server."); 108 } 109 else { 110 var theOutline; 111 try { 112 theOutline = JSON.parse (jsontext); 113 } 114 catch (err) { 115 add ("There was a problem getting information from the tags server."); 116 } 117 var nomad = theOutline.opml.body; 118 if ((nomad.subs === undefined) || (nomad.subs.length == 0)) { 119 add ($("<span>There are no posts tagged with \"" + theTag + ".\"</span>")); 120 } 121 else { 122 if (nomad.subs.length == 1) { 123 title = "1 post is tagged with \"" + theTag + ".\""; 124 } 125 else { 126 title = nomad.subs.length + " posts are tagged with " + theTag + "."; 127 } 128 var divRefList = $("<ol class=\"divRefList\"></ol>"); 129 nomad.subs.forEach (function (item) { 130 function getWhenString (when) { 131 when = new Date (when); 132 return (when.toLocaleDateString ()); 133 } 134 135 function getPermalink () { //temporary hack 136 function getPermalinkString (when) { //cribbed from oldSchoolBlog 137 function pad (num) { 138 return (padWithZeros (num, 2)); 139 } 140 var d = new Date (when); 141 return ("a" + pad (d.getUTCHours ()) + pad (d.getUTCMinutes ()) + pad (d.getUTCSeconds ())); 142 } 143 144 var splits = item.sourceUrl.split ("/"); 145 var year = splits [5];
146 var month = splits [6]; 147 var day = stringPopExtension (splits [7]); 148 149 var url = "https://s3.amazonaws.com/scripting.com/" + year + "/" + month + "/" + day + ".html#" + getPermalinkString (item.created); //2/3/23 by DW 150 151 return (url) 152 } 153 154 function processText (theText) { 155 var pattern = /\[{2}[^\[^\]]*\]{2}/gm; //looks for double-square bracketed tags 156 while (true) { 157 var result = pattern.exec (theText); 158 if (result == null) { 159 break; 160 } 161 var matchstring = result [0]; 162 theText = stringDelete (theText, result.index + 1, matchstring.length); 163 164 var replacestring = stringMid (matchstring, 2, matchstring.length - 2); //remove first [ and last ] 165 theText = stringInsert ("<span class=\"spTagref\">" + replacestring + "</span>", theText, result.index); 166 } 167 return (theText); 168 } 169 var divOneRef = $("<li class=\"divOneRef\"></li>"); 170 var divRefText = $("<div class=\"divOneRefText\">" + processText (item.text) + "</div>"); 171 var dirRefWhen = $("<div class=\"divOneRefWhen\">" + getWhenString (item.created) + "</div>"); 172 173 var difRefHeader = function (item) { 174 var divRefHeader = $("<div class=\"divOneRefHeader\"></div>"); 175 var urlFavIcon = "http://www.google.com/s2/favicons?domain=scripting.com"; 176 var urlPermalink = getPermalink (); 177 var divFeedTitle = $("<div class=\"divTagrefFeedTitle\"><a class=\"aRefFeed\" href=\"http://scripting.com\" target=\"_blank\">" + "Scripting News" + "</a></div>"); 178 var imgFavIcon = $("<img class=\"imgFavIcon\" src=\"" + urlFavIcon + "\" width=\"16\" height=\"16\">"); 179 var aRefWhen = $("<a class=\"aRefWhen\" href=\"" + urlPermalink + "\" title=\"Link to the item on the web\" target=\"_blank\">" + getWhenString (item.created) + "</a>"); 180 181 $(divRefHeader).append (aRefWhen); 182 $(divRefHeader).append (divFeedTitle); 183 184 return (divRefHeader); 185 186 } (item); 187 188 $(divOneRef).append (difRefHeader); 189 $(divOneRef).append (divRefText); 190 $(divRefList).append (divOneRef); 191 }); 192 $(theDialogBody).append (divRefList); 193 } 194 } 195 $("#idTagrefDialogTitle").html (title); 196 $("#idTagrefDialogHtml").empty (); 197 $("#idTagrefDialogHtml").append (theDialogBody); 198 199 $(".divOneRef .spTagref").click (function (event) { 200 var theNewTag = removeDoubleSquareBrackets ($(this).text ()); 201 if (stringLower (theNewTag) != stringLower (theTag)) { 202 var ctpop = tagrefStack.length - ixTagrefStack - 1; 203 for (var i = 1; i <= ctpop; i++) { 204 tagrefStack.pop (); 205 } 206 tagrefStack.push (theNewTag); 207 ixTagrefStack = tagrefStack.length - 1; 208 viewTagrefDialog (); //recurse 209 } 210 else { 211 speakerBeep (); 212 } 213 }); 214 }); 215 }); 216 } 217function tagrefDialogStartup () { 218 $(".spTagref").click (function (event) { 219 console.log ("You clicked on a tagref."); 220 tagrefStack = [$(this).text ()]; 221 ixTagrefStack = 0; 222 viewTagrefDialog (); 223 event.stopPropagation (); 224 event.preventDefault (); 225 }); 226 } 227function openTagrefDialogExternally (theTag) { 228 tagrefStack = [theTag]; 229 ixTagrefStack = 0; 230 viewTagrefDialog (); 231 }
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.