comparison lib/js/urweb.js @ 1802:e3ec868567ce

Undo change to script evaluation, originally made to support <active> + 'giveFocus'; alternate approach to making 'giveFocus' work in dynamic code generatione
author Adam Chlipala <adam@chlipala.net>
date Fri, 03 Aug 2012 08:38:47 -0400
parents 10a2cb93d175
children d2383ffc18ab
comparison
equal deleted inserted replaced
1801:5c51ae0d643b 1802:e3ec868567ce
813 if (pnode == "table") { 813 if (pnode == "table") {
814 normalizeTable(x.parentNode); 814 normalizeTable(x.parentNode);
815 815
816 var dummy = document.createElement("body"); 816 var dummy = document.createElement("body");
817 dummy.innerHTML = "<table>" + html + "</table>"; 817 dummy.innerHTML = "<table>" + html + "</table>";
818 runScripts(dummy);
818 var table = x.parentNode; 819 var table = x.parentNode;
819 820
820 if (table) { 821 if (table) {
821 firstChild = null; 822 firstChild = null;
822 var tbody; 823 var tbody;
840 firstChild = document.createElement("script"); 841 firstChild = document.createElement("script");
841 table.insertBefore(firstChild, x); 842 table.insertBefore(firstChild, x);
842 for (var node = tbody.firstChild; node; node = next) { 843 for (var node = tbody.firstChild; node; node = next) {
843 next = node.nextSibling; 844 next = node.nextSibling;
844 table.insertBefore(node, x); 845 table.insertBefore(node, x);
845 runScripts(node);
846 } 846 }
847 } 847 }
848 } else if (pnode == "tr") { 848 } else if (pnode == "tr") {
849 var dummy = document.createElement("body"); 849 var dummy = document.createElement("body");
850 dummy.innerHTML = "<table><tr>" + html + "</tr></table>"; 850 dummy.innerHTML = "<table><tr>" + html + "</tr></table>";
851 runScripts(dummy);
851 var table = x.parentNode; 852 var table = x.parentNode;
852 853
853 if (table) { 854 if (table) {
854 var arr = dummy.getElementsByTagName("tr"); 855 var arr = dummy.getElementsByTagName("tr");
855 firstChild = null; 856 firstChild = null;
863 firstChild = document.createElement("script"); 864 firstChild = document.createElement("script");
864 table.insertBefore(firstChild, x); 865 table.insertBefore(firstChild, x);
865 for (var node = tr.firstChild; node; node = next) { 866 for (var node = tr.firstChild; node; node = next) {
866 next = node.nextSibling; 867 next = node.nextSibling;
867 table.insertBefore(node, x); 868 table.insertBefore(node, x);
868 runScripts(node);
869 } 869 }
870 } 870 }
871 } else { 871 } else {
872 firstChild = document.createElement("span"); 872 firstChild = document.createElement("span");
873 firstChild.innerHTML = html; 873 firstChild.innerHTML = html;
874 runScripts(firstChild);
874 if (x.parentNode) 875 if (x.parentNode)
875 x.parentNode.insertBefore(firstChild, x); 876 x.parentNode.insertBefore(firstChild, x);
876 runScripts(firstChild);
877 } 877 }
878 }; 878 };
879 879
880 addNode(x); 880 addNode(x);
881 populate(x); 881 populate(x);
1861 function fresh() { 1861 function fresh() {
1862 return "uw" + (--nextId); 1862 return "uw" + (--nextId);
1863 } 1863 }
1864 1864
1865 function giveFocus(id) { 1865 function giveFocus(id) {
1866 var node = document.getElementById(id); 1866 window.setTimeout(function() {
1867 1867 var node = document.getElementById(id);
1868 if (node) 1868
1869 node.focus(); 1869 if (node)
1870 else 1870 node.focus();
1871 er("Tried to give focus to ID not used in document: " + id); 1871 else
1872 er("Tried to give focus to ID not used in document: " + id);
1873 }, 0);
1872 } 1874 }
1873 1875
1874 1876
1875 // App-specific code 1877 // App-specific code