Eric, thank you for showing what I've missed about macros, that is 
important for me! I will use that with any variable/macros used only in the 
Story River. 

But in this case and on the present time links are to be refreshed 
everywhere including the Sidebar. 

Here is my custom piece of link.js. Later i'll optimize it, as it is my 
first touch of JavaScript, styles, etc..
if(!this.isMissing && !this.isShadow) {
          var toTiddler = self.wiki.getTiddler(self.to),                
              toFreq = Number(toTiddler.getFieldString("freq")),
              toWeight = Number(toTiddler.getFieldString("weight")),
              highlightGain = 
Number(this.getVariable("hb-highlight-intensity-kw"));
            if (toWeight || toFreq) {
            
domNode.setAttribute("style","font-weight:"+(highlightGain*4.99*(toFreq)+400-200*highlightGain)+";
 background:rgba("+(150+toWeight)+","+(250-toWeight)+",235,"+ 
(highlightGain*(toFreq/(150)+0.5)) + "); text-decoration: none; color: 
inherit;border-color: rgba("+(155+toWeight)+","+(255-toWeight)+",255,"+ 
(highlightGain*(toFreq/(150)+0.5)) + "); border-radius: 4px; 
border-bottom-width: 0px; border-left-width: 2px; border-right-width: 2px; 
border-top-width: 0px; padding-inline-end: 1px; padding-inline-start: 
1px;border-style: solid");
           domNode.setAttribute("data-toWeight",toWeight);
        }  }


понедельник, 12 октября 2020 г. в 03:47:55 UTC+6, Eric Shulman: 

> On Sunday, October 11, 2020 at 11:51:14 AM UTC-7, Shareda wrote:
>>
>> TW Tones, yes, maybe I can do so, but.. I made this variable to get the 
>> desired value from inside of my custumized link.js widget, which redraws 
>> all internal links. The $:/hb/HighlightIntensityKW value can be changed 
>> only by RangeWidget from UI, that's what I need. It works as i need except 
>> of loosing  current scroll position. 
>>
>> Eric, can I get value of such  <<hb-highlight-intensity-kw>> macro inside 
>> of my customized link.js by some JavaScript  expression? 
>> If so, wouldn't that make it slower (compared to using a variable)? Now i 
>> have *10 109 * linked tiddlers, and soon there will be ~ 25 000.  
>
> Now I get value by this JS line: 
>> var highlightGain = Number(this.getVariable("hb-highlight-intensity-kw"));
>
>
> Macros *are* variables.  Internally, in the TWCore, they are one and the 
> same.
>
> The only difference is that the macro declaration syntax allows you to 
> pass in
> optional parameters to be substituted into the macro value before 
> returning.
>
> See https://tiddlywiki.com/#Macros, in which Jeremy writes:
>
>> Most macros are in fact just parameterised variables 
>> <https://tiddlywiki.com/#Variables>.
>
> and
>
>> The dumpvariables <https://tiddlywiki.com/#dumpvariables%20Macro> macro 
>> lists all variables (including macros) that are available at that position 
>> in the widget tree.
>
>
> You should be able to get the value of the macro using Javascript in your 
> customized
> link.js widget, as long as that widget is being rendered in a tiddler 
> view, since the
> macro/variable defininition is being loaded via $:/tags/Macro/View.
>
> However, I can't test this myself since I don't have your customized code.
>
> I suggest placing the <<dumpvariables>> macro somewhere just before an 
> occurrence of a link that uses your customized link.js code
> to see if it lists your hb-highlight-intensity-kw variable and value.
>
> You could also add
> console.log("highlight gain is:" + hightlightGain);
> somewhere in your link.js code, and then check the output in the browser's 
> developer console window.
>
> -e
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3d1fb434-4a79-4530-890e-a691a2c6c7e6n%40googlegroups.com.

Reply via email to