Directory: | ./ |
---|---|
File: | tmp_project/PhoenixTex2Html/src/PLatexObj/redirect_html.cpp |
Date: | 2025-03-24 18:12:43 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 33 | 33 | 100.0% |
Branches: | 36 | 36 | 100.0% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | |||
8 | #include "redirect_html.h" | ||
9 | |||
10 | ///Create the redirection page to get page with label name as reference | ||
11 | /** @param fileName : file to be created | ||
12 | * @param mapLabel : map of label to be used | ||
13 | * @return true on success, false otherwise | ||
14 | */ | ||
15 | 127 | bool redirect_html(const PPath & fileName, const PMapLabel & mapLabel){ | |
16 |
1/1✓ Branch 1 taken 127 times.
|
127 | PString body("<!DOCTYPE html>\n"); |
17 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "<html lang=\"fr\">\n"; |
18 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t<head>\n"; |
19 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t<meta charset=\"utf-8\" />\n"; |
20 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t<title>Page redirection</title>\n"; |
21 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t<link rel=\"stylesheet\" href=\"style.css\" />\n"; |
22 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t<script type=\"text/javascript\">\n"; |
23 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\tfunction redirectionWithLabelReference(){\n"; |
24 | |||
25 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\tvar parameters = location.search.substring(1).split(\"?\");\n"; |
26 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\tvar tmp = parameters[0].split(\"=\");\n"; |
27 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\treferenceName = unescape(tmp[1]);\n"; |
28 | |||
29 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\tvar dictReference = {"; |
30 | 127 | bool isComma(false); | |
31 |
2/2✓ Branch 3 taken 242 times.
✓ Branch 4 taken 127 times.
|
369 | for(PMapLabel::const_iterator it(mapLabel.begin()); it != mapLabel.end(); ++it){ |
32 |
3/3✓ Branch 0 taken 228 times.
✓ Branch 1 taken 14 times.
✓ Branch 3 taken 228 times.
|
242 | if(isComma){body += ",";} |
33 |
5/5✓ Branch 3 taken 242 times.
✓ Branch 6 taken 242 times.
✓ Branch 9 taken 242 times.
✓ Branch 12 taken 242 times.
✓ Branch 15 taken 242 times.
|
242 | body += "\n\t\t\t\t\t\""+it->first+"\": \""+it->second.first+"\""; |
34 | 242 | isComma = true; | |
35 | } | ||
36 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\n\t\t\t\t};\n"; |
37 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\tif(referenceName in dictReference){\n"; |
38 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\t\tdocument.location.href=dictReference[referenceName];\n"; |
39 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\t}else{\n"; |
40 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\t\tdocument.location.href=\"index.html\";\n"; |
41 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t\t}\n"; |
42 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t\t}\n"; |
43 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t</script>\n"; |
44 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t</head>\n"; |
45 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t<body onLoad=\"setTimeout('redirectionWithLabelReference()', 1000)\">\n"; |
46 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t\t<div>Dans 2 secondes vous allez être redirigé vers la page que vous avez demandée... normalement</div>\n"; |
47 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "\t</body>\n"; |
48 |
1/1✓ Branch 1 taken 127 times.
|
127 | body += "</html>\n\n"; |
49 |
1/1✓ Branch 1 taken 127 times.
|
254 | return fileName.saveFileContent(body); |
50 | 127 | } | |
51 | |||
52 | |||
53 | |||
54 |