Roundup Tracker - Issues


Author rouilj
Recipients ber, rouilj
Date 2016-07-08.01:50:46
Message-id <>
I don't see any invalid html after applying the expression,
however the javascript used by the expression editor is:

function modify_main() {
    main = window.opener.document.getElementById("keywords_%(prop)s");
    main.innerHTML = main_content();

this takes the div that surrounds both the select element and the (edit)
link identified by keywords_keyword and replaces it with the contents of
main_content which is a hidden input element with the rpn expression
from the editor plus the text expressing the infix version of the

So that clobbers both the select and the (edit) link by design.

I tried playing around with some javascript to
replace just the select element using outerHTML. This
replaced the select leaving the (edit) in place.
Note this *requires* that the select be the first element
inside the div. If there is anything before it it breaks.
I don't like this fragility but I am not sure how to handle it.

But that left me without the select element to replace
if the (edit) link was clicked again, or if the editor's
apply button was pressed again.

So I changed main_content() to put in a span with an ID
of MCkeywords_%(prop)s and changed the logic in modify_main
to look for either the span with the unique id or the select
inside the div.

The code ended up looking like:

 function main_content() {
     var out = '';
+    out += '<span id="MCkeywords_%(prop)s">';
     out += '<input type="hidden" name="%(prop)s" value="' + current +
     out += parse(current).infix();
+    out += '</span>';
     return out;
 function modify_main() {
-    main = window.opener.document.getElementById("keywords_%(prop)s");
-    main.innerHTML = main_content();
+    main = window.opener.document.getElementById("MCkeywords_%(prop)s");
+    if ( main == null ) {
+        main = window.opener.document.getElementById("keywords_%(prop)s");
+        select = main.getElementsByTagName("SELECT")[0];
+        select.outerHTML = main_content();
+    } else {
+      main.outerHTML = main_content();
+    }

I used a span so the edit link would stay atthe end of the description.
If you use a div, the link is pushed to the next line.

This feels really icky and fragile.

Comments from somebody who knows javascript?

-- rouilj
Date User Action Args
2016-07-08 01:50:48rouiljsetmessageid: <>
2016-07-08 01:50:48rouiljsetrecipients: + rouilj, ber
2016-07-08 01:50:48rouiljlinkissue2550709 messages
2016-07-08 01:50:47rouiljcreate