How to add a title to your Lightbox (v.2.5) - hyperlink

This is not a Question, just some advise I want to give to you.
After hours of googling and testing out, I didn't find a solution that worked on my lightbox. I don't know why, but I just couldn't apply a link into the title, not with htmlentities() etc.
So I came up with my own solution, which is just a workaround.
I'm not really satisfied with myself but it's the only way it works for me.
So, if you're having the same troubles like me, just add this line of code:
Search for this line of Code in lightbox.js (In my file it was the line 277):
$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast');
and replace it with this:
$lightbox.find('.lb-caption').html('<span onclick="window.location.href=\'http://yourdomain.com\'">'+this.album[this.currentImageIndex].title+"</span>").fadeIn('fast');
What did I do?
Since .lb-caption is added to display the title attribute, i just wrap the original output in an element and bind a click event to a certain location.
Problem with it:
Since I wrapped around the whole title attribute, the whole title attribute becomes a link.
To get the cursor: pointer; effect in css and your standard link layout, just make the title a link. In this way it doesnt has to be htmlentities() decoded link.
Example:
This link opens a new page
Another problem is: Now is the link static. (Since we're not using the href of our link).
Solution:
To add One $_GET Attribute to the link, we just need to fix a few lines.
What you do is, in your image call (the part) you add the attribute "rev", means:
Instead of This link opens a new page,
you now use (add the "rev" attribute"):
This link opens a new page
Now to the Javascript part...
Search for:
if ($link.attr('rel') === 'lightbox') {
this.album.push({
this part, and replace:
link: $link.attr('href'),
title: $link.attr('title'),
with
link: $link.attr('href'),
title: $link.attr('title'),
rev: $link.attr('rev')
If you go a few lines down you'll see the same part with link: $…., title: $…., replace that part with:
link: $(a).attr('href'),
title: $(a).attr('title'),
rev: $(a).attr('rev')
Now we just need to modify our wrapper: (Go back to now line 279, before the $_GET part it was line 277)
$lightbox.find('.lb-caption').html('<span onclick="window.location.href=\'http://yourdomain.comindex.php?page=contact&t='+this.album[this.currentImageIndex].rev+'\'">'+this.album[this.currentImageIndex].title+"</span>").fadeIn('fast');
We add now '+this.album[this.currentImageIndex].rev+' instead of the static part.
You can repeat this method to add infinite $_GET parameters, just add a new attribute to your image call, and change the javascript like we did in my explanation.
This is a really complicated and unusual way to solve the link in title problem, but its the only way how it will work in my script.
I hope that I helped someone! :)

Related

Jump to part of page through URL

Consider the following link:
https://bittrex.com/Market/Index?MarketName=USDT-neo
I need to somehow manipulate the URL so that when it's clicked, it jumps straight to the Order Book section of the webpage.
I've tried finding the ID for that part and appending it the URL, but that wouldn't work because the ID isn't generated when you enter the page through the normal URL.
Does anyone know how to manipulate the link so it jumps straight to the Order Book part?
To be clear, I do not want to use JS. I want to have a pure link which I can click and will take me to the Order Book.
I need this so I could take a screenshot of the chart using a node module called Pageres.
If anyone has any different idea as of how to download the chart of the Order Book to a png, it'd be awesome (Or even more generally, download a chart of any cryptocurrency's Order Book to a png, using any website).
Many thanks,
~Yuval
Using javascript, you can handle the click in the following way:
<a id="fake_link" class="fake-link" href="https://bittrex.com/Market/Index?MarketName=USDT-neo">Click me</a>
<script>
var elem = document.getElamentById("fake_link");
elem.addEventListener("click",function(e){
e.stopPropagation();
e.preventDefault();
window.location = "YOUR NEW LOCATION";
},false);
</script>
In the general case, all you need is add the id of the part of the page that you want to go to. The section you mention starts with:
<div class="row" id="rowTable">
So all you have to do is add #rowTable to your URL:
https://bittrex.com/Market/Index?MarketName=USDT-neo#rowTable
That will instruct the browser to look for the part of the page with the id that you mention.
But you are right, the id part of the page is generated after it is loaded. In your case it only works if you change the URL with the page already loaded.
You could try using an intermediate page with a bit of javascript that will first load the page, then jump to the part you want.
You can use the location.hash property in java script to grab the hash of the current page
use is like this:
var hash = window.location.hash;
if(hash == "#tabChartOrderBook"){
//function to switch tab
}
I wrote this for your url
https://bittrex.com/Market/Index?MarketName=USDT-neo#tabChartOrderBook
and as I said in code your url hash is #tabChartOrderBook

Remove bloggers automatic 'add URL' feature to menu items

My Blogger template (klarity) automatically adds my domain name infront of any link I want to add to my menu. For example: I want to create a link to my page 'about'. All I need to do is create a list item with a link pointing towards /about.html.
This is a problem when I want to link a menu item with an external domain. So if I want to create a link between the menu item 'shop' and www.myshop.com I cannot simply change the href of the link to www.myshop.com because blogger adds my domain name infront of it, making it look like: www.mydomain.com/www.myshop.com.
From what I understand Blogger does this through the following code: data:post.url or similar. I have looked for that kind of code and tried cutting it out but so far I have not managed to get rid of www.mydomain.com infront of every list item.
How can I remove www.mydomain.com from my menu items? This is the only solution I could think of, if there are any others please do suggest them!
So I actually figured out the problem, it was really easy:
Just change the link so that it looks like this:
My domain
Make sure you don't forget the http, otherwise you are going to get errors (thats's the mistake I made)

How to properly encode links to external URL in MVC Razor

This view suppose to show a list of hyperlinks, each pointing to an external URL. The goal is for the user to click one of these links and have their browser open a new tab with the selected URL.
Currently I have the following markup:
#Html.ActionLink("SomeSite", "http://subdomain.mydomain.com/SomeSite")
This markup produces:
http://localhost:58980/AccessInstance/http%3a/subdomain.mydomain.com/SomeSite
instead of :
http://subdomain.mydomain.com/SomeSite
What can I change in my markup to make this work as I expect?
You don't need to use #Html.ActionLink for that. Just use a plain A tag:
SomeSite
Html.ActionLink is specifically for generating links to actions defined in MVC controllers, in the same app. Since you're linking to an absolute URL, you don't need any of the functionality that Html.ActionLink provides.
Two ways :
1. update the database column with full link:
eg SQL:
update ProductTable set ProductLink='http://www.example.com/Product/Mobiles' where ID=123
In asp mvc view
View
2. Hardcode the http part and list from model
View
Hope helps someone.
While a ViewBag is overused and not the best choice most of the time this is something that I had done when inheriting someone else's mvc app to do a quick fix for a URL that I needed to redirect to with a specific dynamically changing querystring parameter
<a target="_parent" href="http://localhost:56332/services/#ViewBag.factory">View Service</a>
Using .NET Core 6
This seems to be the most correct answer:
Link
This will generate the following result:
As you can see at the bottom left corner of the window before clicking the link, the URL address was rendered as it is (NOTE: The cursor was recorded out of place for some reason, that's a ShareX problem, ignore it).
Than link will be directly saved as a nvarchar(750) type (probably any character like type will do the work). No changes to the original link were made before saving it or on reading:
You need to take into account your RouteConfiguration.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}"
because you are specifying the action link as the entire link that you want to redirect.
I would recommend that you use the #rossipedia answer because you can make tricky things like putting a span inside the link
Here to display link that are clickable in index page
<td>
#Html.ActionLink(item.FileName, "../Uploads/Catalogue/"+item.FileName)
</td>

How to add comment in h:panelGrid without causing it to generate empty TD

I've found that if I add comment inside panelgrid tag, it will generate an empty <td> for it. I've found this link about this issue: https://java.net/jira/browse/JAVASERVERFACES-1768. According to this link, it is not a bug and marked as WONTFIX. In the link, someone has provided these workarounds, I wonder if there are better solutions than these:
Let Facelets ignore all comments, if you do not want to keep them at all. There is a javax.faces.FACELETS_SKIP_COMMENTS switch for that in web.xml.
Move the comment into the <h:panelGroup>, if you want to keep them.
Use <ui:remove><!-- first column --></ui:remove>, you could then also ignore the XML comment-style and come up with something fancier.

way to reinitialize a page each time it is shown

I have some pages which are filled dynamically by content loaded with Ajax. My problem is that each time I go to this page, the old content is still there if it hasn't been replaced by new content...
I've thought about 2 home solutions like:
Creating a "template" page. By calling "pagebeforeshow", I'll copy the code from the template in the target page, and add there the dynamic content...
Each DOM where dynamic content must be put into, I had a class "clearcache" and by calling "pagebeforeshow" I do a $(".clearcache").empty();
I don't know how to deal with that. Have you ever got the same issue?
EDIT:
I bind the "tap" event to store the block-id into localstorage, to load dynamic content in the #PageBlock
Everything works very well (tap event, localstorage for the var, ajax loading). The issue comes really when I go from block to other blocks. The new content overwrite old content instead of beginning from a new "blank" page.
For example I have a list where I append datas I get from Ajax. If I switch to another block, the list is completed and not refreshed..
I could do something like empty the list, and then appending content, but I'd like something better because I have several pages/lists/dom like that...
Thanks for your help ;)
I faced a similar problem where the new contents where not shown on the page when i tried to append it.There is a simple solution where you can just replace append with prepend.
Example:
Replace
$("#divid").append(content)
with
$("#divid") .prepend(content)

Resources