Go to the source code of this file.
◆ redirect_html()
bool redirect_html |
( |
const PPath & |
fileName, |
|
|
const PMapLabel & |
mapLabel |
|
) |
| |
Create the redirection page to get page with label name as reference.
- Parameters
-
fileName | : file to be created |
mapLabel | : map of label to be used |
- Returns
- true on success, false otherwise
Definition at line 15 of file redirect_html.cpp.
16 PString body(
"<!DOCTYPE html>\n");
17 body +=
"<html lang=\"fr\">\n";
19 body +=
"\t\t<meta charset=\"utf-8\" />\n";
20 body +=
"\t\t<title>Page redirection</title>\n";
21 body +=
"\t\t<link rel=\"stylesheet\" href=\"style.css\" />\n";
22 body +=
"\t\t<script type=\"text/javascript\">\n";
23 body +=
"\t\t\tfunction redirectionWithLabelReference(){\n";
25 body +=
"\t\t\t\tvar parameters = location.search.substring(1).split(\"?\");\n";
26 body +=
"\t\t\t\tvar tmp = parameters[0].split(\"=\");\n";
27 body +=
"\t\t\t\treferenceName = unescape(tmp[1]);\n";
29 body +=
"\t\t\t\tvar dictReference = {";
31 for(PMapLabel::const_iterator it(mapLabel.begin()); it != mapLabel.end(); ++it){
32 if(isComma){body +=
",";}
33 body +=
"\n\t\t\t\t\t\""+it->first+
"\": \""+it->second.first+
"\"";
36 body +=
"\n\t\t\t\t};\n";
37 body +=
"\t\t\t\tif(referenceName in dictReference){\n";
38 body +=
"\t\t\t\t\tdocument.location.href=dictReference[referenceName];\n";
39 body +=
"\t\t\t\t}else{\n";
40 body +=
"\t\t\t\t\tdocument.location.href=\"index.html\";\n";
41 body +=
"\t\t\t\t}\n";
43 body +=
"\t\t</script>\n";
44 body +=
"\t</head>\n";
45 body +=
"\t<body onLoad=\"setTimeout('redirectionWithLabelReference()', 1000)\">\n";
46 body +=
"\t\t<div>Dans 2 secondes vous allez être redirigé vers la page que vous avez demandée... normalement</div>\n";
47 body +=
"\t</body>\n";
48 body +=
"</html>\n\n";
bool saveFileContent(const PString &content) const
Save a PString in a file.
References PPath::saveFileContent().
Referenced by updateLabelRef().