Dartlang attach link to LIElement - dart

Is it possible to make LIElement into a link, and how can it be done?
I have tried
var li = new LIElement();
li.text = text;
li.href = "http://www.google.com";
But it does not seem to work.
Any help would be greatly appreciated.

You have to add an anchor element, just like you would do it in HTML.
LIElement li = new LIElement();
AnchorElement a = new AnchorElement();
a.text = "I'm a <li> with an <a>!";
a.href = "http://www.google.com";
li.append(a);

There's no href setter on LIElement. Alternativly, you can add a listener on click to change the location of the page.
var li = new LIElement();
li.text = text;
li.onClick.listen((e) => window.location.assign("http://www.google.com"));

Related

Wordpress YouTheme Logo Link Change

This one little issue is driving me mad and i am hope someone could help
All i need to do is change the home url of the logo to another link
$config = $theme->get('logo', []);
$attrs_link = [];
$attrs_image = [];
// Logo Text
$logo = $config['text'];
// Link
$attrs_link['href'] = $theme->get('site_url');
$attrs_link['class'][] = isset($class) ? $class : '';
$attrs_link['class'][] = 'uk-logo';

using katex, '&' alignment symbol displays as 'amp;'

I am using katex to render math.
https://github.com/Khan/KaTeX
Generally, to get this to work I link to the files katex.min.js and katex.min.css from a cdn, which is one of the ways the directions suggest.
I wrap what needs to be rendered in tags and give all the same class. For example:
<span class='math'>\begin{bmatrix}a & b \\c & d\end{bmatrix}</span>
And inside a script tag I apply the following:
var math = document.getElementsByClassName('math');
for (var i = 0; i < math.length; i++) {
katex.render(math[i].innerHTML, math[i]);
}
So, my implementation works but there is a problem in what katex returns. The output of the above gives me:
This exact same question is asked here:
https://github.com/j13z/reveal.js-math-katex-plugin/issues/2
But I can't understand any of it.
The solution is to use element.textContent, not element.innerHTML.
If I use a form like what follows, the matrix will be rendered properly.
var math = document.getElementsByClassName('math');
for (var i = 0; i < math.length; i++) {
katex.render(math[i].textContent, math[i]); // <--element.textContent
}
A solution that works for me is the following (it is more of a hack rather than a fix):
<script type="text/javascript">
//first we define a function
function replaceAmp(str,replaceWhat,replaceTo){
replaceWhat = replaceWhat.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var re = new RegExp(replaceWhat, 'g');
return str.replace(re,replaceTo);
}
//next we use this function to replace all occurences of 'amp;' with ""
var katexText = $(this).html();
var html = katex.renderToString(String.raw``+katexText+``, {
throwOnError: false
});
//hack to fix amp; error
var amp = '<span class="mord mathdefault">a</span><span class="mord mathdefault">m</span><span class="mord mathdefault">p</span><span class="mpunct">;</span>';
var html = replaceAmp(html, amp, "");
</script>
function convert(input) {
var input = input.replace(/amp;/g, '&'); //Find all 'amp;' and replace with '&'
input=input.replace(/&&/g, '&'); //Find all '&&' and replace with '&'. For leveling 10&x+ &3&y+&125&z = 34232
var html = katex.renderToString(input, {
throwOnError: false});
return html
}
Which version are you using?
Edit the src/utils.js and comment line number 51 to 55 after updated run in terminal npm run build command.

Using Zend\Dom\Query

I am useing Zend\Dom\Query to get specific content from a webpage.
This is the html:
<div class="menuName darkGreen leftMenu">
Mouse
</div>
How can I get the value Mouse ??
Thanks
Try this:
$dom = new \Zend\Dom\Query($html);
$results = $dom->execute('div.menuName a');
$doc = $results->current();
var_dump($doc->nodeValue);
Try this:
$doc->getAttribute('src');

add collapsible into another collapsibles (nested collapsibles) in JQM

I want to get this:
But I need to create the HTML dynamically because it's loaded via AJAX from an external ressource.
I already asked this question here (JQM: Dynamic nested collapsibles - $(collapsible).collapsible() & $(collapsible).trigger('create')) but I got it completly wrong with lists and collapsibles, so I figured a new question would be better.
Here is what I got so far:
function loadTipps() {
console.log("Lade Tipps..");
var categoriesURL = tippsURL+"?type=kategorien&callback=?"; // url for the categories
$.getJSON(categoriesURL,function(data) {
console.log("Lade Kategorien..");
var DIV_tipps_komplett = $("#tipps_komplett");
$.each(data, function(key,value){
var kategorie_ID = value.id;
var kategorie_NAME = value.name;
var collapsible_HTML = $('<div data-role="collapsible"></div>');
var kategorie_Ueberschrift_HTML = $('<h3>'+kategorie_NAME+'</h3>');
var tipps_kategorie_HTML = $('<div id="tipps_kategorie'+kategorie_ID+'" data-role="collapsible-set"></div>');
var tippURL = tippsURL+"?type=tipp&kat_id="+value.id+"&callback=?"; // url for the tipps of the current category
$.getJSON(tippURL,function(data2) {
$.each(data2, function(key2,value2){
var tipp_Ueberschrift_Text_HTML = '<div data-role="collapsible"><b>'+value2.name+'</b><p>'+value2.text+'</p><br></div>';
tipps_kategorie_HTML.append(tipp_Ueberschrift_Text_HTML);
}); //<--each
});//<--getJSON
collapsible_HTML.append(kategorie_Ueberschrift_HTML);
collapsible_HTML.append(tipps_kategorie_HTML);
DIV_tipps_komplett.append(collapsible_HTML);
});//<--each
DIV_tipps_komplett.trigger('create');
});//<--getJSON
}
This results in:
As you can see, the items in the first collapsible set are not in another collapsible set. Any ideas why?
Try changing the line:
var tipp_Ueberschrift_Text_HTML = '<div data-role="collapsible"><b>'+value2.name+'</b><p>'+value2.text+'</p><br></div>';
to
var tipp_Ueberschrift_Text_HTML = '<div data-role="collapsible"><h3>'+value2.name+'</h3><p>'+value2.text+'</p><br></div>';
The Collapsible needs the <h3> element instead of <b> to render.
Here is a demo of your exact code with the AJAX calls removed: http://jsfiddle.net/ezanker/RkLuV/
By the way, this is pretty much the answer I gave you here: collapsible list with collapsed items in jqm, it would probably have been better to continue the conversation there.

Programmatically added SummaryLinkWebPart doesn't display Links

I am using below code to Add SummaryLinkWebPart to a Page and also adding few links to that wehbpart. I can see the webpart now on the page but it doesn't have any links inside it. Does anyone know what is wrong with the code?
var wpm = web.GetLimitedWebPartManager("Pages/default.aspx", PersonalizationScope.Shared);
SummaryLinkWebPart slwp = new SummaryLinkWebPart();
for (int counter = 0; counter < list.ItemCount; counter++)
{
urlField = list.Items[counter]["URL"].ToString().Split(',');
SummaryLink link = new SummaryLink(urlField[1].Trim());
slwp.SummaryLinkValue.SummaryLinks.Add(link);
slwp.SummaryLinkValue.SummaryLinks[counter].OpenInNewWindow = true;
slwp.SummaryLinkValue.SummaryLinks[counter].LinkUrl = urlField[0].Trim();
slwp.SummaryLinkValue.SummaryLinks[counter].Description = urlField[1];
slwp.Style = "Image on left";
Console.WriteLine(link.LinkUrl + link.Title);
}
wpm.AddWebPart(slwp, lvwp.ZoneID, slwp.ZoneIndex + 1);
Hmm this seems to be the hack but the only thing that solves this issue is reassigning the SummaryLinkValue Property back again its value.
slwp.SummaryLinkValue = slwp.SummaryLinkValue;
use
SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
then when done call page.Update(). something like this
SPFile page = web.GetFile(string.Format("Pages/{0}", this.FileName.Replace("html", "aspx")));
SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
SummaryLinkWebPart webpart = new SummaryLinkWebPart();
if (!string.IsNullOrEmpty(RelatedTopic1))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic1));
if (!string.IsNullOrEmpty(RelatedTopic2))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic2));
if (!string.IsNullOrEmpty(RelatedTopic3))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic3));
if (!string.IsNullOrEmpty(RelatedTopic4))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic4));
if (webpart.SummaryLinkValue.SummaryLinks.Count > 0)
{
wpManager.AddWebPart(webpart, "BottomPanel", 0);
page.Update();
}

Resources