()
| 170 | |
| 171 | |
| 172 | function openFolder() { |
| 173 | var t = $(this); |
| 174 | var state = {}; |
| 175 | if (history) |
| 176 | state = history.state || state; |
| 177 | if (!this._opened) { |
| 178 | this._opened = true; |
| 179 | var p = t.attr("data-path") + "/"; |
| 180 | var subPath = path=="" ? p : p.substr(path.length); |
| 181 | t.text("[-]"); |
| 182 | var content = $("<table/>"); |
| 183 | var dict = {}; |
| 184 | var toOpenNow = []; |
| 185 | for (var i=0; i < fileIndex.length; ++i) { |
| 186 | var f = fileIndex[i]; |
| 187 | if (f.indexOf(p) == 0) { |
| 188 | var sl = f.indexOf('/', p.length + 1); |
| 189 | |
| 190 | if (sl !== -1) { |
| 191 | var name = f.substr( p.length, sl - p.length); |
| 192 | if (dict[name]) |
| 193 | continue; |
| 194 | dict[name] = true; |
| 195 | content.append("<tr><td class='folder'><a class='opener' data-path='" + p + name + "' href='"+subPath + name+"'>[+]</a> " + |
| 196 | "<a href='" + subPath + name + "/'>" + name + "/</a></td></tr>\n"); |
| 197 | if (state[p+name]) |
| 198 | toOpenNow.push(p+name); |
| 199 | } else { |
| 200 | var name = f.substr(p.length); |
| 201 | content.append("<tr><td class='file'> <a href='" + subPath + name + ".html'>" + name + "</a></td></tr>\n"); |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | content.find(".opener").click(openFolder); |
| 206 | t.parent().append(content); |
| 207 | state[t.attr("data-path")]=true; |
| 208 | toOpenNow.forEach(function(toOpen) { |
| 209 | var e = $("a[data-path='"+toOpen+"']").get(0) |
| 210 | if (e) |
| 211 | openFolder.call(e); |
| 212 | }); |
| 213 | } else { |
| 214 | t.parent().find("> table").empty(); |
| 215 | t.text("[+]"); |
| 216 | this._opened = false; |
| 217 | state[t.attr("data-path")]=false; |
| 218 | } |
| 219 | if (history && history.replaceState) |
| 220 | history.replaceState(state, undefined); |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | $(".opener").click(openFolder); |
| 225 | var state; |
nothing calls this directly
no outgoing calls
no test coverage detected