Forum

Hide open anchors when clicking on HTML link

15 August 2018 20:54
Are you using an older version? The int sources were moved from "src" to "src/intern" in v17.12, and the sources have changed. So, what you get in "Line 217" is not what others get. Webplayer has changed too.

Also, your solution gives the same ID to every anchor.

P.S.: What function did you add your line to? Was it "create_annotation(anchor)"?
16 August 2018 10:19
Are you using an older version?
Yes.


Also, your solution gives the same ID to every anchor.
That was the plan, so now it's possible to easily style the (standard) anchors. Like add a little glow around it:


P.S.: What function did you add your line to? Was it "create_annotation(anchor)"?

Yes:
function create_annotation(anchor) {
var obj = anchor.obj;

var canvas_cont = m_cont.get_container();
var meta_tags = m_obj.get_meta_tags(obj);

var title_text = obj.name;
var descr_text = "";

var anchor_cont_elem = document.createElement("div");
anchor_cont_elem.id = "anchorbtn";
var title_wrap_elem = anchor_cont_elem.cloneNode(false);
16 August 2018 18:41
I found this thread. You have to (re-)compile the engine ("make compile_b4w") after making changes.

A simpler, quick workaround would be to add your line directly to the minimized "final" version (the output you get after build/deploy/export etc.). You only have to find the passage:
function create_annotation(anchor) {
    var obj = anchor.obj;

    var canvas_cont = m_cont.get_container();
    var meta_tags = m_obj.get_meta_tags(obj);

    var title_text = obj.name;
    var descr_text = "";

    var anchor_cont_elem = document.createElement("div");

    var title_wrap_elem = anchor_cont_elem.cloneNode(false);
    var title_elem = document.createElement("span");
I could identify this by searching for .createElement("span") which only appears twice in the minimized source. With the context, I could easily locate the passage in the minimized file. It is this:

var c=X.get_meta_tags(e);e=e.name;var d="",k=document.createElement("div"),g=k.cloneNode(!1),m=document.createElement("span");

So, "k" is "anchor_cont_elem". I simply insert the code at the end:

var c=X.get_meta_tags(e);e=e.name;var d="",k=document.createElement("div"),g=k.cloneNode(!1),m=document.createElement("span");k.id="anchorbtn";

It's not a great solution but it works. (There is no great solution for changing the source code anyway because it's messy and will no longer work when you upgrade to a new B4W version. Also, you cannot share your project sources with other people since they don't have your changes.)

P.S.: I asked for this to be included in the next version.
 
Please register or log in to leave a reply.