Remove a hyperlink with YUI - yui

I have the following in my html:
Logged in as <a title="View Profile" href="http://xxx/user/profile.php?">Peter Pan</a>
I would like to just remove the hyperlink form the above, so that is still displays "Logged in as Peter Pan" but just without Peter Pan linking to anywhere.
Thanks

Assuming YUI 3: node.set('innerHTML', node.get('innerHTML').replace(/<[^>]+>/g, ''));
Note that this doesn't require YUI as much as plain regexp :)

Use the Node.removeAttribute method to remove the anchor's href.
Take a look at its documentation in the YUI API:
http://yuilibrary.com/yui/docs/api/classes/Node.html#method_removeAttribute
Y.one('some selector for the anchor here').removeAttribute('href');

Related

Can i use {{sometitle}} as text (without parsing as chunk) in modx evo?

I just got a problem using revolution slider in modx evolution.
My slider have jquery code
tabs: {
tmp:'<div class="tp-tab-content"> <span class="tp-tab-date">{{param1}}</span> <span class="tp-tab-title">{{title}}</span></div><div class="tp-tab-image"></div>'}
and modx of course parsing {{param1}} and {{title}} as chunks, but its part of revoslider's jquery.
so after parsign page html code looks like this
tabs: {
tmp:'<div class="tp-tab-content"> <span class="tp-tab-date"></span> <span class="tp-tab-title"></span></div><div class="tp-tab-image"></div>'}
and revolution slider shows incorrect
i tried calling revoslider code from html file using snipnet with php funtion include, but it also got parsed by modx engine
can i solve this problem without changing revoslider jquery code?
thanks to your ansewers!
I am not an EVO expert, but I could suggest several tricks that may help:
Try to escape the curly braces like \{\{param1\}\}
Try to breake the sequence like {[*fakeTemplateVar*]{param1}[*fakeTemplateVar*]}*
Try an empty TV like [*fakeTemplateVar*:ifempty={{param1}}]
*fakeTemplateVar will finally evaluate to an empty place in the template.

How to locate the element as per the HTML through FindElementByXPath in Selenium Basic

I'm writing a VBA code to login into a webpage and load some information i have in an excel worksheet.
I'm new in Selenium. I already got the login part right, but now i need to click in an element and i keep getting errors.
I need to click in the Company 2 button.
This is what i've got so far:
bot.FindElementByXPath("//input[#value=""Company 1""]").Click
Outputs NoSuchElementError
bot.FindElementByXPath("//input[#value=""Company 2""]").Click
Outputs ElementNotVisible
I don't know what i'm doing wrong, i think that the first input being hidden has something to do. Hope anyone can help me.
Might help you to know you can also use ByCss in most circumstances, in which case you can use:
bot.FindElementByCss("input[value='Company 1']").Click
That is nice and short.
The CSS selector is input[value='Company 1']. This says find element with input tag having attribute value with value of 'Company 1'.
XPath might be incorrect. Please try the following syntax:
FindElementByXPath("//input[#value='Company 1']")
First of all, use CSS selectors whenever possible. They are much easier to handle.
Now if you are using CSS selectors try to find the second button using something like
input[value="Company 2"]
For more info on this selector, look at https://www.w3schools.com/cssref/sel_attribute_value.asp
You can use any xpath, in first look I found your xpath is incorrect, try this:
//input[#type='button'][#value='Company 2']
//input[#type='button'&& #value='Company 2']
//input[#role='button'][#value='Company 2']
You can also use findelements() to store are all buttons and using if else you can extract the company 2 button
As per the HTML you have shared to invoke click() on the desired elements you can use the following solution:
To click on the element with text as Company 1:
bot.FindElementByXPath("//input[#class='btn_empresa ui-button ui-widget ui-state-default ui-corner-all' and #value='Company 1']").Click
To click on the element with text as Company 2:
bot.FindElementByXPath("//input[#class='btn_empresa ui-button ui-widget ui-state-default ui-corner-all' and #value='Company 2']").Click
Have you tried right-clicking the HTML in inspect and going to Copy>Copy XPath? That might give you something different. Maybe the buttons are created from Javascript and so the WebDriver can't actually see them?
Or try
Company_1 = bot.find_element_by_xpath("//input[#value='Company 1']")
Company_1.click()
Company_2 = bot.find_element_by_xpath("//input[#value='Company 2']")
Company_2.click()
And change the syntax with the ' ' quotes like someone else mentioned.

Is it possible to add some arrows to ms2gallery and use it as carousel?

I have project on modx and there is used ms2gallery to show images. And customer want to add some arrows(prev, next) to use this ms2gallery as carousel or slider. Is it possible to build-in this functional into ms2gallery? If not could you advice something to solve this task?
You can use the pdoPage snippet for just this purpose. Here's the example form the ms2Gallery documentation:
[[!pdoPage?
&element=`ms2GalleryResources`
&parents=`0`
&tpl=`#INLINE
<p>
[[+pagetitle]]
<img src="[[+120x90]]" title="[[+120x90.name]]" />
</p>
`
&typeOfJoin=`inner`
&includeThumbs=`120x90`
&includeOriginal=`1`
]]
[[!+page.nav]]
You will need to add some extra properties to the snippet call to get more than one result. All the available options and several examples are documented on the pdoPage readme.

Hide Sign Out Link in Liferay 6.2 Dockbar

In Liferay 6.1, we created a hook to hide the sign out link in the dockbar. However, when I look at the code for 6.2, I see the following:
<c:if test="<%= themeDisplay.isShowSignOutIcon() %>">
<aui:nav-item cssClass="sign-out" href="<%= themeDisplay.getURLSignOut() %>" iconCssClass="icon-off" label="sign-out" />
</c:if>
No matter how much I google, I can't find any reference to themeDisplay.isShowSignOutIcon(), aside from the API reference, which does me no good, as it is not commented at all. I did find the page that discusses the native LR theme properties and apparently determining whether to show/hide a sign out linkn is not one of the native theme properties.
Does anyone know if you can set the theme itself to show/hide the sign out link and how you would go about doing it?
I too analyzed ServicePreAction code, and found that all this code does is:
checks if the user is logged in or not
if yes, shows 'sign out' link, not otherwise
You can simply create a hook to override html/portlet/dockbar/view_user_account.jspf to either remove that code snippet from this jsp to hide it for all scenarios OR modify the condition to show/hide as per your requirements.
The only place that I've found where ThemeDisplay.setShowSignOutIcon is called is in ServicePreAction (linking master branch here). That being said, it looks like it's not configurable, but you can easily create another ServicePreAction in a hook. Please see an example in this plugin (referencing portal.properties and liferay-hook.xml, but naturally there's also code that I'm sure you'll find. It's not big)
Another option - if you just want to unconditionally get rid of the link: Use CSS to hide it. Yes, it will still be there, but any way you choose to hide the link, the actopm at /c/portal/logout will still be available...

On codaset, in a ticket description: is it possible to render raw text instead of markdown processed markup?

Well, everything is in the title ;-)
Thanks
Fro_oo
Codaset twitter answer :
All descriptions are rendered via Markdown by default, and that cannot be disabled.

Resources