PhoenixLecture  2.0.0
Set of tools to make lectures
redirect_html.cpp File Reference
#include "redirect_html.h"
+ Include dependency graph for redirect_html.cpp:

Go to the source code of this file.

Functions

bool redirect_html (const PPath &fileName, const PMapLabel &mapLabel)
 Create the redirection page to get page with label name as reference. More...
 

Function Documentation

◆ 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.

15  {
16  PString body("<!DOCTYPE html>\n");
17  body += "<html lang=\"fr\">\n";
18  body += "\t<head>\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";
24 
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";
28 
29  body += "\t\t\t\tvar dictReference = {";
30  bool isComma(false);
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+"\"";
34  isComma = true;
35  }
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";
42  body += "\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";
49  return fileName.saveFileContent(body);
50 }
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
Extends the std::string.
Definition: PString.h:16

References PPath::saveFileContent().

Referenced by updateLabelRef().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: