Tiki anchors on the same page - reference

I have a Tiki page with some headlines formatted like this.
!!!schedule(%milliSeconds, %method, %arguments)
On another place (same wiki page) I have a simplified reference.
schedule()
Can Tiki automatically make a reference from schedule() to schedule(%milliSeconds, %method, %arguments) Meaning that schedule () will reference !!!schedule (%milliSeconds, %method, %arguments)
I hope this description makes sense :)

OK, here is an example:
{JQ()}
$('.wikitext p').html( function(){
return $(this).html().replace(/\s([^\)\s)]+)\(\)/gi, ' $1()');
});
{JQ}
You can put this JQ plugin with jQuery code to top of a wiki page (or if you want it on every page then without the JQ plugin to the Customization > Custom JavaScript section of Look & Feel admin panel). Then if there is foo() or bar() or any function() mentioned in any paragraph of the page it will be converted to link pointing to an anchor on the same page, e.g.
function()
where _a_b_c_ are the params (a,b,c) in the heading, for example
!!Function(a,b,c)
You need to change that _a_b_c_ to match your anchors as they are rendered (check the HTML source) or adjust the regular expression. That is out of the scope of this answer. You can see a demo here.

I am not sure I understand correctly but perhaps you could use the Hotwords feature, where you define schedule() as a "hotword" linking to YourWikiPageName#schedule(%milliSeconds, %method, %arguments). Then every mention of schedule() in Tiki will point to that anchor on that page.

Related

Add an custom link to the MODX Evolution DLmenu

I'm trying to add a custom link to the menu on MODX Evolution by using DLMenu snippet. Menu displays pages, and after the second point I need to add an anchor link on the main page ... is it possible to somehow implement this at the template level, or apply certain filters?
Thanks for the help,
Alexey
Please share your DLMenu snippet call. If I understand correctly you need to use rowTpl/ rowHereTpl parameters, please use chunk here instead INLINE code and specify the next (snippet If is used):
<li[+classes+]>[+title+]</li>
[[if? &is=`[+iteration+]:=:2` &then=`<li>Home</li>`]]

PySide/PyQt Text in QTextBrowser disappears after clicking on a link in it

I have the following variable appended to 'QTextBrowser'. It does appear as a link, but when I click on it all the text in the 'QTextBrowser' disappears. All the function the 'anchorClicked' signal is connected to does is print something in the shell so that I know that the signal was received.
word = '<a href>' + '<span style="background-color:#C0C0C0">' + word + '</span>' +'</a>'
self.textBrowser.anchorClicked.connect(self.test)
def test(self,argv_1):
print('!!!')
Probably what's happening is that the text browser is attempting navigate to the href specified in the anchor. But since the href is empty, it just shows a blank page.
If you want to stop automatic link navigation, try this:
self.textBrowser.setOpenLinks(False)
(NB: the anchorClicked signal will still be sent when the link is clicked).
You can also prevent this behaviour by calling self.textBrowser.setSource(QtCore.QUrl()) in the function connected to the anchorClicked signal (in your case test()).
For an example, see what I did in my answer to your other question here: https://stackoverflow.com/a/19475367/1994235
This allows you to still have some links that take you to other pages, and some that don't (you call the above line of code to prevent the page change, only when certain urls are passed to your function)
Use html2text to download the URL to matching directory for every link on the page. Reformat as HTML, adding headers and rewiring the links. Then do this recursively every time you click on a link and you effectively have a working web browser. The links will actually work. I would like to see someone do it in less than 3 pages if they can.

Onload page make div slide visible with easing

I'd like to have a div (with class="top") come slide in from top:-300px; to top:40px; with some nice easing. I can't find any examples. Does anyone knows how to do this on load page?
Here's some JavaScript and CSS3:
The JavaScript:
<script>
document.getElementById("slide").style.top="40px";
</script>
And the CSS:
-webkit-transition:all 1s;-ms-transition:all 1s;-moz-transition:all 1s;-o-transition:all 1s;-webkit-transition:all 1s;
The element that would slide would have to have the id "slide". It would also need top have "position:absolute;top:-300px" in the CSS to make it -300px. You could also add "left:20%;" or something of the sort to the CSS to make it look better. Whatever works with your design.
You should look up about the CSS transition property. It's very nice for special effects. In this case, I made it take 1 second to slide. You could always change it.
This could also be implemented using jQuery, a JavaScript library, (which would take even less code), but I usually prefer regular JavaScript and CSS if I can help it.
Here's a demo of the code I wrote above: jsFiddle.
Oh, and PLEASE mark this question as the answer if it helped you. It will give me privileges and earn me more reputation.
Hope this helped!

Content scripts on prerendered pages?

Are Content Scripts (http://code.google.com/chrome/extensions/content_scripts.html) injected into prerendered pages (document.webkitVisibilityState== 'prerender') ?
I’ve been reading https://developers.google.com/chrome/whitepapers/prerender and https://developers.google.com/chrome/whitepapers/pagevisibility, and am trying to figure out how Content Scripts work with page prerendering/prefetching.
Thanks
TheZ, tomdemuyt: I’m afraid you guys are missing the point. ‘run_at’ specifies whether the content script is injected before or after the DOM is constructed.
However, I am talking about document.webkitVisibilityState, which can be ‘prerender’ (when the page is in a background/invisible tab), ‘hidden’, or ‘visible’. Note that webkitVisibilityState can transition from ‘prerender’ to ‘hidden’ or ‘visible’, or back and forth between ‘hidden’ and ‘visible’, without any changes being made to the DOM. (In order to better understand this, read the articles linked in my original post.)
I think I’ve been able to determine that content scripts ARE injected into prerendered pages. Here’s the problem, however: let’s say my content script does something that should not occur on a prerendered page. For instance, it does pageview count, or adds animation, neither of which should begin until the user is actually viewing the page. So it seems that my content script should do something like what’s shown in the code examples on https://developers.google.com/chrome/whitepapers/pagevisibility - check document.webkitVisibilityState, and also listen to the ‘webkitvisibilitychange’ event, and only do pageview count/start the animation when document.webkitVisibilityState is, or has transitioned to, ‘visible’.
I may have just answered my own question, but I just wanted to make sure that I was on the right track.
Thanks
As TheZ mentioned, you should ues the run_at setting.
Link to docs : http://code.google.com/chrome/extensions/content_scripts.html#registration

Can I link to an HTML file in my project from a UIWebView?

If I load a string containing HTML into a UIWebView, and that string contains objects (hyperlinks) that are relative to that string, i.e. , where there is some object with id "something," then the link works - click on it and the web view jumps to the referenced object.
What I want is to get navigation to a different file in my project, in other words as though the path to the different file were a URL.
I have found that if the href IS a URL, such as href="http://www.amazon.com", then the link works.
If I put the name of a file, OR the [NSBundle mainBundle] pathForResource: ] of that name, in the href, then the link does not work.
Is there some way I can generate the equivalent of a URL pointing to an HTML file that is in the project, so that an can link to that HTML file?
I found a solution at this link:
How to use Javascript to communicate with Objective-c code?
Essentially, the solution is to implement the UIWebViewDelegate protocol's shouldStartLoadWithRequest method, and "trap" a particular value of scheme. So my links, instead of saying something like:
<a href="http://someplace.location">
are like:
<a href="mylink://#filename.ext">
By catching attempts to load anything with scheme "mylink," I can use:
[[request URL] fragment]
within shouldStartLoadWithRequest, and get the filename.ext. I then release my previous UIWebView, load in the contents of the specified file, and make that the contents of a new UIWebView. The effect is that the links work with normal appearance, even though they are being implemented with my code. I return NO because I don't want the usual loading to take place. If the scheme is NOT mylink, I can return YES to allow normal operation.
Regrettably, I still have no way to jump TO a fragment within a web view. In linking to a real URL, you can say something like "www.foo.org#page50" and jump straight to wherever an object on the new page has an id of "page50." With my method, I can only go to the top of the page.
This is also not going to give me a "go-back" function unless I record the filenames and implement it myself.

Resources