Rev 17770 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 17770 | Rev 17773 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | const char * html_table = "<div id=\"mendeleiev_table\" style=\"position: relative\"><style>\n" |
1 | const char * html_table = "<div id=\"mendeleiev_table\" style=\"position: relative; width: 940px; height: 602px;\"><style>\n" |
2 | "div.element{display:inline-block;position:absolute;width:44px;height:56px;border:1px solid black;border-radius:3px;background:lightyellow}\n" |
2 | "div.element{display:inline-block;position:absolute;width:44px;height:56px;border:1px solid black;border-radius:3px;background:lightyellow}\n" |
3 | "p.symbol{position:absolute;top:-18px;width:44px;text-align:center;font-size:26px}\n" |
3 | "p.symbol{position:absolute;top:-18px;width:44px;text-align:center;font-size:26px}\n" |
4 | "p.Z{position:absolute;top:-16px;left:2px;font-size:14px}p.mass{position:absolute;top:28px;width:44px;text-align:center;font-size:12px}\n" |
4 | "p.Z{position:absolute;top:-16px;left:2px;font-size:14px}p.mass{position:absolute;top:28px;width:44px;text-align:center;font-size:12px}\n" |
5 | "p.str0{display:inherit;position:absolute;top:-4px;left:26px;font-size:4px;line-height:3.6px}\n" |
5 | "p.str0{display:inherit;position:absolute;top:-4px;left:26px;font-size:4px;line-height:3.6px}\n" |
6 | "div.r1{top:20px}div.r2{top:82px}div.r3{top:144px}div.r4{top:206px}div.r5{top:268px}\n" |
6 | "div.r1{top:20px}div.r2{top:82px}div.r3{top:144px}div.r4{top:206px}div.r5{top:268px}\n" |
Line 55... | Line 55... | ||
55 | " {top: top+\"px\", left: left+\"px\"});\n" |
55 | " {top: top+\"px\", left: left+\"px\"});\n" |
56 | " }\n" |
56 | " }\n" |
57 | " }(jQuery(\"#one_element\")));\n" |
57 | " }(jQuery(\"#one_element\")));\n" |
58 | " });\n" |
58 | " });\n" |
59 | " jQuery(\"#wait\").fadeOut();\n" |
59 | " jQuery(\"#wait\").fadeOut();\n" |
60 | "}\n" |
- | |
61 | "\n" |
- | |
62 | "/**\n" |
- | |
63 | " * imports jQuery (JS), jQuery-UI (JS and CSS)\n" |
- | |
64 | " * parametes url1 .. url3 are for jquery.js, jquery-ui.js, jquery-ui.css \n" |
- | |
65 | " **/\n" |
- | |
66 | "function importScript(url1, url2, url3){\n" |
- | |
67 | " var script1, script2, link;\n" |
- | |
68 | " script1 = document.createElement('script');\n" |
- | |
69 | " script1.src = url1;\n" |
- | |
70 | " document.head.appendChild(script1);\n" |
- | |
71 | " script2 = document.createElement('script');\n" |
- | |
72 | " script2.src = url2;\n" |
- | |
73 | " document.head.appendChild(script2);\n" |
- | |
74 | " link = document.createElement('link');\n" |
- | |
75 | " link.rel = \"stylesheet\";\n" |
- | |
76 | " link.type = \"text/css\";\n" |
- | |
77 | " link.href = url3;\n" |
- | |
78 | " document.head.appendChild(link);\n" |
- | |
79 | "}\n" |
60 | "}\n" |
80 | "\n" |
61 | "\n" |
81 | "function jQueryIsHere(){\n" |
62 | "function jQueryIsHere(){\n" |
82 | " result = true;\n" |
63 | " result = true;\n" |
83 | " try {\n" |
64 | " try {\n" |
84 | " if (! jQuery) result = false;\n" |
65 | " if (! jQuery) result = false;\n" |
85 | " }\n" |
66 | " }\n" |
86 | " catch(e) {\n" |
67 | " catch(e) {\n" |
87 | " if(e.name == \"ReferenceError\") {\n" |
68 | " if(e.name == \"ReferenceError\") {\n" |
88 | " result = false;\n" |
69 | " result = false;\n" |
89 | " }\n" |
70 | " }\n" |
90 | " }\n" |
71 | " }\n" |
91 | " return result\n" |
72 | " return result\n" |
- | 73 | "}\n" |
|
- | 74 | "\n" |
|
- | 75 | "function scriptLoader(scriptUrl){\n" |
|
- | 76 | " /* copied from https://stackoverflow.com/questions/538745/how-to-tell-if-a-script-tag-failed-to-load */\n" |
|
- | 77 | " return new Promise(function (res, rej) {\n" |
|
- | 78 | " let script = document.createElement('script');\n" |
|
- | 79 | " script.src = scriptUrl;\n" |
|
- | 80 | " script.type = 'text/javascript';\n" |
|
- | 81 | " script.onerror = rej;\n" |
|
- | 82 | " script.async = true;\n" |
|
- | 83 | " script.onload = res;\n" |
|
- | 84 | " script.addEventListener('error',rej);\n" |
|
- | 85 | " script.addEventListener('load',res);\n" |
|
- | 86 | " document.head.appendChild(script);\n" |
|
- | 87 | " }) \n" |
|
- | 88 | "}\n" |
|
- | 89 | "\n" |
|
- | 90 | "function cssLoader(cssUrl){\n" |
|
- | 91 | " return new Promise(function (res, rej) {\n" |
|
- | 92 | " let link = document.createElement('link');\n" |
|
- | 93 | " link.href = cssUrl;\n" |
|
- | 94 | " link.rel = 'stylesheet';\n" |
|
- | 95 | " link.type = 'text/css';\n" |
|
- | 96 | " link.onerror = rej;\n" |
|
- | 97 | " link.async = true;\n" |
|
- | 98 | " link.onload = res;\n" |
|
- | 99 | " link.addEventListener('error',rej);\n" |
|
- | 100 | " link.addEventListener('load',res);\n" |
|
- | 101 | " document.head.appendChild(link);\n" |
|
- | 102 | " }) \n" |
|
92 | "}\n" |
103 | "}\n" |
93 | "\n" |
104 | "\n" |
94 | "function tryLocal(){\n" |
105 | "function tryLocal(){\n" |
95 | " |
106 | " return Promise.all([\n" |
96 | " \"http://localhost/javascript/jquery/jquery.js\",\n" |
107 | " scriptLoader(\"http://localhost/javascript/jquery/jquery.js\"),\n" |
97 | " \"http://localhost/javascript/jquery-ui/jquery-ui.js\",\n" |
108 | " scriptLoader(\"http://localhost/javascript/jquery-ui/jquery-ui.js\"),\n" |
98 | " \"http://localhost/javascript/jquery-ui/css/smoothness/jquery-ui.css\"\n" |
109 | " cssLoader(\"http://localhost/javascript/jquery-ui/css/smoothness/jquery-ui.css\")]);\n" |
99 | " );\n" |
- | |
100 | "}\n" |
110 | "}\n" |
101 | "\n" |
111 | "\n" |
102 | "function tryRemote(){\n" |
112 | "function tryRemote(){\n" |
103 | " |
113 | " return Promise.all([\n" |
104 | " \"https://code.jquery.com/jquery-1.11.3.js\",\n" |
114 | " scriptLoader(\"https://code.jquery.com/jquery-1.11.3.js\"),\n" |
105 | " \"https://code.jquery.com/ui/1.13.2/jquery-ui.js\",\n" |
115 | " scriptLoader(\"https://code.jquery.com/ui/1.13.2/jquery-ui.js\"),\n" |
106 | " \"https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css\"\n" |
116 | " cssLoader(\"https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css\")\n" |
107 | " );\n" |
117 | " ]);\n" |
108 | " \n" |
- | |
109 | "}\n" |
118 | "}\n" |
110 | "\n" |
119 | "\n" |
111 | "window.onload = function(){\n" |
120 | "window.onload = function(){\n" |
112 | " |
121 | " let p1 = new Promise((res, rej) => {\n" |
113 | " if ( |
122 | " if (jQueryIsHere()) res(\"jQuery found immediately\");\n" |
- | 123 | " else rej(\"no jQuery immediately\")\n" |
|
114 | " } |
124 | " })\n" |
- | 125 | " .then((msg) => {\n" |
|
- | 126 | " console.log(msg);\n" |
|
115 | " |
127 | " add_interaction();\n" |
- | 128 | " })\n" |
|
116 | " |
129 | " .catch((msg) =>{\n" |
117 | " |
130 | " console.log(msg);\n" |
- | 131 | " tryLocal().then((values) => {\n" |
|
- | 132 | " console.log(values, \"local scripts and css files not found\");\n" |
|
118 | " |
133 | " add_interaction();\n" |
- | 134 | " }).catch((reason) => {\n" |
|
- | 135 | " console.log(reason);\n" |
|
- | 136 | " tryRemote().then((values) => {\n" |
|
- | 137 | " console.log(values);\n" |
|
119 | " add_interaction();\n" |
138 | " add_interaction();\n" |
- | 139 | " }).catch((reason) => {\n" |
|
- | 140 | " console.log(reason, \"remote scripts and css files not found\");\n" |
|
- | 141 | " });\n" |
|
120 | " |
142 | " });\n" |
- | 143 | " })\n" |
|
121 | "};\n" |
144 | "};\n" |
122 | "</script>\n" |
145 | "</script>\n" |
123 | "<div class=\"element c1 r1\" style=\"cursor: wait;\" title=\"1 H Hydrogen 1.008, row = 1, col = 1, elec. struct. 1s^{1}\"><p class=\"symbol\">H</p><p class=\"Z\">1</p><p class=\"mass\">1.008</p><p class=\"str0\"><span class=\"layer\">1s<sup>1</sup></span> </p></div>\n" |
146 | "<div class=\"element c1 r1\" style=\"cursor: wait;\" title=\"1 H Hydrogen 1.008, row = 1, col = 1, elec. struct. 1s^{1}\"><p class=\"symbol\">H</p><p class=\"Z\">1</p><p class=\"mass\">1.008</p><p class=\"str0\"><span class=\"layer\">1s<sup>1</sup></span> </p></div>\n" |
124 | "<div class=\"element c18 r1\" style=\"cursor: wait;\" title=\"2 He Helium 4.0026, row = 1, col = 18, elec. struct. 1s^{2}\"><p class=\"symbol\">He</p><p class=\"Z\">2</p><p class=\"mass\">4.0026</p><p class=\"str0\"><span class=\"layer\">1s<sup>2</sup></span> </p></div>\n" |
147 | "<div class=\"element c18 r1\" style=\"cursor: wait;\" title=\"2 He Helium 4.0026, row = 1, col = 18, elec. struct. 1s^{2}\"><p class=\"symbol\">He</p><p class=\"Z\">2</p><p class=\"mass\">4.0026</p><p class=\"str0\"><span class=\"layer\">1s<sup>2</sup></span> </p></div>\n" |
125 | "<div class=\"element c1 r2\" style=\"cursor: wait;\" title=\"3 Li Lithium 6.94, row = 2, col = 1, elec. struct. [He] 2s^{1}\"><p class=\"symbol\">Li</p><p class=\"Z\">3</p><p class=\"mass\">6.94</p><p class=\"str0\">[He] <span class=\"layer\">2s<sup>1</sup></span> </p></div>\n" |
148 | "<div class=\"element c1 r2\" style=\"cursor: wait;\" title=\"3 Li Lithium 6.94, row = 2, col = 1, elec. struct. [He] 2s^{1}\"><p class=\"symbol\">Li</p><p class=\"Z\">3</p><p class=\"mass\">6.94</p><p class=\"str0\">[He] <span class=\"layer\">2s<sup>1</sup></span> </p></div>\n" |