Following this tutorial I was able to retrieve data form the clipboard.
But I have no idea (nither there's something in the API) about how to insert my string into the xul browser (say, when the user open the 'edit' menu and click 'paste').
Any idea?
--update
There's a cmd_paste here, but there's no hint if I can (and how to) use it to paste in a browser. Also the browser's API available documentation have nothing about.
I tried make it work creating a browser, setting the command attribute (not sure if it exists, the API says nothing, but it's a wiki not much reliable) and a button to paste:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window width="400" height="300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<browser id="mybrowser" command="cmd_paste" type="content" src="http://www.google.com/" flex="1" />
<button label="TEST PASTE" command="document.getElementById('mybrowser').doCommand();" />
</window>
Nothing happens when I press the button (with data on my clipboard, and a text field selected inside the browser).
--in the xulrunner source
within toolkit.jar, at content/global/editMenuOverlay.xul there's the definition:
<command id="cmd_paste" oncommand="goDoCommand('cmd_paste')"/>
but no "goDoCommand" method is defined there, nither in the only javascript file included: editMenuOverlay.js.
Do you really need a "paste" command? Couldn't you just retrieve the data from the clipboard using the tutorial you found and copy it into the currently focused text elements when the past button is pressed?
After finding the goDoCommand (see the question update) I found out that the function was in the globalOverlay.js file.
So I added to my Xul:
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js" />
and used the goDoCommand command.
Not yet sure if it's the best or even correct approach to add this js to my Xul, but look likes ok.
Related
I need to create a footer in a Liferay-project, that can be modified from the instance. I've been trying various things in my footer-code and instance, but haven't figured out how to do it.
Any content inside the footer can't be touched and in page edit mode, Liferay says "This area is defined by the theme. You can change the theme settings by clicking more in the Page Design Options panel on the sidebar". I didn't get any help from Page Design Options either. Is there a way to do this?
I found the answer after hours of work and searching and want to share it with everyone here. The working solution was found here, in one of the comments.
You need to write some code (I use Freemarker/ftl) and then configure the site pages a bit, but here's how it works:
Put a new setting inside liferay-look-and-feel.xml:
<settings>
<setting key="footer-article-id" value="" configurable="true" type="text"/>
</settings>
This will create a new configurable option in page options, allowing you to input the ID of the web content.
NOTE: <theme> might get underlined red "The content of element type "theme" must match". This still prints everything correctly, but the tags are given in a wrong order. Inside my <theme>, I have <template-extension>, <settings> and <portlet-decorator> in that order, which removes the error.
Assign a variable in init_custom.ftl (cleans up the footer-code):
<#assign footer_article_id = getterUtil.getString(themeDisplay.getThemeSetting("footer-article-id"))/>
And then add this to the footer-code, to create the spot, where the content is visible:
<#liferay_journal["journal-article"]
articleId=footer_article_id
groupId=page_group.groupId
/>
After this, everything should be ready code-wise.
Create a Web Content for your footer. In the creation screen, there's an ID on the panel on the right. Publish your content and grab the ID.
Finally, go to Site Builder --> Pages and click on configuration from the top bar (behind three dots). You should see the input field like in the first picture: That's where you add the ID.
Save the settings and your web content should now be in the footer.
Hope this helps!
I've been playing around with Extension Library Navigator for a while and I can't figure out how to make the selected (or the current opened pages basic node) node to change any of the looks properties, for example font or color. I'm trying to do that so that user can tell what page is currently opened. Any tips on how to do that?
Another option, which is not as simple as the one suggested by Per, is to do the customization via a bit of script.
For example, I have built my site navigation with pure HTML and bootstrap.
My link HTML looks like this
<a id="YOURLINKIDHERE" href="vwBringUpsByDate.xsp">Bring ups</a>
When a page loads, you can then then use the below script to customize your selected menu item exactly how you like, fonts, colours, backgrounds etc just by referencing the link ID....
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[$("*[id$='YOURLINKIDHERE']").css('background-color', '#eeeeee');]]></xp:this.script>
</xp:eventHandler>
Not ideal, as you have to put the script on each page that you want to modify a menu link with, but gives you some good customization options...
I want to collect pictures from Google image search. However, I am constantly notified with an error.
For example, the URL https://www.google.com/search?q=banana&hl=en&gws_rd=ssl&tbm=isch is fine in my browser, but in web harvest it reports that: the reference to entity "gws_rd" must end with the ';' delimiter.
I guess '&' is a special character in webharvest, but I cannot find information about it. Can you figure out why?
This is the code:
<var-def name="search" overwrite="false">banana</var-def>
<var-def name="url"><template>http://images.google.com/images?q=${search}&hl=en</template></var-def>
<var-def name="xml">
<html-to-xml>
<http url="${url}"/>
</html-to-xml>
</var-def>
<var-def name="largeImgUrl">
<xpath expression="//*[#id='irc_cc']/div[4]/div[1]/div/div[2]/div[1]/a/img">
<var name="xml"/>
</xpath>
</var-def>
from experience you will need to first store the url in a variable, and then refer to the variable from within the http processor call
EDIT
I notice you have pasted your code. Good.
1) remember that all the webharvest config files are written in XML, and amersand & is a special character in XML, as it is part of the entity declaration
In webharvest i normaly avoid this issue by using CDATA sections within <template> or <code> blocks.
2)when using webharvest graphical interface, you can easily debug your xpath expressions. Run your code as normal, and then on the toolbar at the top click the icon with a magniffying glass. Then choose "xml" (name of your variable you have set). This will open a new window, with a preview of your xml. Make sure the "view as" dropdown is set to xml.
You should now have a "xpath expression" box where you can test your xpath.
3)I strongly discourage from writing xpaths referring to numbered elements. (eg div[4]/div[1]/div/div[2]/div[1]/). Any small change in the underlying page usually breaks the code. It is much better to select elements based on id or other properties.
I'm having some problems using MooDialog using its confirmLinkClick option.
In the html section I have:
<a title="Delete Link" id="confirmLinkClick"
href="admin_delete_link.php?links_id=<?php echo $row_view_links['links_id'];?>">
<img src="../images/link_delete.png" alt="Delete Link" />
</a>
In my script section I have:
window.addEvent('domready', function(){
$('confirmLinkClick').confirmLinkClick(
'Are you sure you wish to delete this link?');
});
Up top I have the CSS link to the MooDialog.css, links to mootools.js (latest), Overlay.js, Moodialog.js, and moodialog.confirm.js
I have basically copied the way the sample file that came with MooDialog shows how to call the confirm dialog (http://www.aryweb.nl/projects/MooDialog/), but I do not get anything coming up at all.
Testing the sample file, I get the confirm pop up. Using the above code (which is even using the same sample id setting), nothing, it completely ignores the javascript.
I've googled and stackoverflowed but can't seem to find any hints, and yes I'm new to this as well.
I'm sure it's probably something very simple that I'm overlooking, but I just can't seem to get it.
I'm making an html autorun, loading it with default browser has lots of issues, rendering inconsistencies, and more issues when it's loaded internet explorer like users has to click on allow at the top when some javascript is loaded etc. What is the best solution to create a small standalone app with just a full browser control in it which will load an html file say index.html from the application path.
That is if I have browser.exe in a cd, it will load index.html from the cd directory. The browser should be based webkit or Gecko. So far i have been using xulrunner... but its a overkill especially when the file to load is just few kbs. Its using lot of system resources.
I have experience in vb.net(but it requires the .net framework) and php on windows. And basic python, c and javascript. Where should i start and what are your suggestions?
Update:
This is meant to be a wrapper or a chromeless browser that will load the html. So the only functionality needed is autorun and load the html in full screen, thats it! So air, .net etc wont do the work. It should be an standalone exe.
As no answer for this, I will post how you can use XULRunner for this purpose.
Getting Started etc could be found here.
I'm just putting my layout code in which how I achieved a chrome less browser window that
loads my particular page for autorun purpose.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="Edusoft" hidechrome="true" sizemode="maximized" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!--This Sets the browser control and loads index.html and sets clip menu as the popup menu -->
<browser id="1" type="content" src="chrome://myapp/content/theme1/index.html" flex="1" context="clipmenu"/>
<!-- Clips menu -->
<popupset>
<menupopup id="clipmenu">
<menuitem label="Go Back" oncommand="document.getElementById('1').goBack()"/>
<menuseparator/>
<menuitem label="About" oncommand="" />
<menuseparator/>
<menuitem label="Exit" oncommand="close();" />
</menupopup>
</popupset>
</window>
This is the window that loads first when XULRunner is run. It's defined in prefs.js
Thing will be clear when you read through this.