I have a function with some variables and I want to make it visible outside this function, but the console does not recognize it
<b:tag name='script' type='text/javascript'>
(function(){var snapAuthor=AuthorsInfo.filter(function(a){return a.name==='<data:title/>'})[0];
if(snapAuthor!==undefined){
snapAuthor.provided=true;
<b:loop values='data:links' var='link'>
<b:if cond='data:link.name contains "-ad"'>snapAuthor['<data:link.name/>']='<data:link.target.jsEscaped/>';
<b:else/>
<b:switch var='data:link.name'>
<b:case value='rank'/>snapAuthor.rank='<data:link.target.escaped/>';
<b:case value='about'/>snapAuthor.about='<data:link.target.escaped/>';
<b:default/>snapAuthor.links['<data:link.name/>']='<data:link.target/>';
</b:switch></b:if></b:loop>}})();</b:tag>
and this is the recall function :
$("#Auth-Sec .LinkList").each(function(){
var e = $(this);
var getName= e.find(snapAuthor.name); // snapAuthor is not defined
if (getName=== AuthorName){
$("body").hide();
}
console.log(getName);
});
Note the name of the snapAuthour
variable.. i want a way to make it visible while remaining in place and thanks <3
I try make exmaple, but I don't see finally dom structure:
let snapAuthorList = {};
// there's LinkList class?
// <div class="LinkList">...
<b:tag name='script' type='text/javascript'>
// you must get somu unique ID there
var currentBlockID = 1;
(function() {
var snapAuthor=AuthorsInfo.filter(function(a) {
return a.name==="<data:title/>"
})[0];
// js undefined is type
if(typeof snapAuthor !== "undefined") {
snapAuthorList[currentBlockID] = snapAuthor;
snapAuthor.provided=true;
// pass currentBlockID into dom,
<b:tag name="div" data-id="__currentBlockID__" class="LinkListId">
<b:loop values='data:links' var='link'>
<b:if cond='data:link.name contains "-ad"'>snapAuthor["<data:link.name/>"]="<data:link.target.jsEscaped/>";
<b:else/>
<b:switch var='data:link.name'>
<b:case value='rank'/>
snapAuthor.rank="<data:link.target.escaped/>";
<b:case value='about'/>
snapAuthor.about="<data:link.target.escaped/>";
<b:default/>
snapAuthor.links["<data:link.name/>"]="<data:link.target/>";
</b:switch>
</b:if>
</b:loop>
</b:tag>
}
})();
</b:tag>
// </div>
...
...
...
// some nested scope
<script>
{
{ //
var currentBlockID = $("#Auth-Sec .LinkList .LinkListId").data('id'); // this may be in each loop if on child block
$("#Auth-Sec .LinkList").each(function() {
var e = $(this);
if (typeof snapAuthorList[currentBlockID] !== "undefined") {
var snapAuthor = snapAuthorList[currentBlockID];
var getName = e.find(snapAuthor.name);
if (getName === AuthorName) {
$("body").hide();
}
console.log(getName);
}
});
}
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.