Skip to content

Commit

Permalink
Code formatting: applied rules defined in previous commit.
Browse files Browse the repository at this point in the history
(cherry picked from commit 2e96f3b162e74a7019fdf99ed5c30a80ebefb2f8)
  • Loading branch information
dennisguse committed May 2, 2017
1 parent e2a337d commit 9d0a277
Show file tree
Hide file tree
Showing 10 changed files with 420 additions and 395 deletions.
10 changes: 5 additions & 5 deletions examples/example.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
body {
margin: 5em 0 5% 0;
text-align: center;

/* Tip: Disable user selection everywhere. */
user-select: none;
}

body > div > div { /* Add space after every question. */
margin-bottom: 2em;
body>div>div {
/* Add space after every question. */
margin-bottom: 2em;
}

.write-border > div > canvas {
.write-border>div>canvas {
border-style: dotted;
}

.max-width > div:nth-child(2) {
.max-width>div:nth-child(2) {
width: 50%;
margin-left: auto;
margin-right: auto
Expand Down
185 changes: 95 additions & 90 deletions examples/example_basic.html
Original file line number Diff line number Diff line change
@@ -1,105 +1,110 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="example.css">
<style>
.undefinedRequired {
outline: none;
border-color: red;
box-shadow: 0 0 1em red;
}

.screenPreview table {
width: 100%;
border-collapse: collapse;
word-break: break-all;
}

.screenPreview table td, .screenPreview table th {
font-size: 1em;
border: 1px solid #98bf21;
padding: 3px 7px 2px 7px;
}
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="example.css">
<style>
.undefinedRequired {
outline: none;
border-color: red;
box-shadow: 0 0 1em red;
}

.screenPreview table {
width: 100%;
border-collapse: collapse;
word-break: break-all;
}

.screenPreview table td,
.screenPreview table th {
font-size: 1em;
border: 1px solid #98bf21;
padding: 3px 7px 2px 7px;
}

.screenPreview table th {
font-size: 1.1em;
text-align: left;
padding-top: 5px;
padding-bottom: 4px;
background-color: #A7C942;
color: #ffffff;
}

.screenPreview table tr.alt td {
color: #000000;
background-color: #EAF2D3;
}

.screenPreview table th {
font-size: 1.1em;
text-align: left;
padding-top: 5px;
padding-bottom: 4px;
background-color: #A7C942;
color: #ffffff;
}
</style>
<script src="../thefragebogen.js"></script>
<script>
//This array stores all screens that will be shown.
var screens = [];

.screenPreview table tr.alt td {
color: #000000;
background-color: #EAF2D3;
}
</style>
<script src="../thefragebogen.js">
</script>
<script>
//This array stores all screens that will be shown.
var screens = [];
//The welcome screen of this questionnaire with some text and a standard question.
var screen1 = new ScreenUIElements(
new UIElementHTML(undefined, "Welcome to the demo version of TheFragebogen!<br><br>This demo gives you an overview of the available features.<br>When you are ready, please press 'Next'."),
new QuestionnaireItemDefinedOne(undefined, "Are you ready?", true, ["Yes"])
);
screens.push(screen1);

//The welcome screen of this questionnaire with some text and a standard question.
var screen1 = new ScreenUIElements(
new UIElementHTML(undefined, "Welcome to the demo version of TheFragebogen!<br><br>This demo gives you an overview of the available features.<br>When you are ready, please press 'Next'."),
new QuestionnaireItemDefinedOne(undefined, "Are you ready?", true, ["Yes"])
);
screens.push(screen1);
//This screen shows some questions.
var screen2 = new ScreenUIElements(
new UIElementHTML(undefined, "Just some basic questions.<br>The 2nd must be answered."),
new QuestionnaireItemDefinedOne(undefined, "QuestionnaireItemDefinedOne: Question with a defined set of options, where only one option can be selected.", false, ["Option 1", "Option 2", "Option 3"]),
new QuestionnaireItemDefinedMulti(undefined, "QuestionnaireItemDefinedMulti: Question with a defined set of options, where multiple options can be selected.", true, ["Option 1", "Option 2", "Option 3"])
);
screens.push(screen2);

//This screen shows some questions.
var screen2 = new ScreenUIElements(
new UIElementHTML(undefined, "Just some basic questions.<br>The 2nd must be answered."),
new QuestionnaireItemDefinedOne(undefined, "QuestionnaireItemDefinedOne: Question with a defined set of options, where only one option can be selected.", false, ["Option 1", "Option 2", "Option 3"]),
new QuestionnaireItemDefinedMulti(undefined, "QuestionnaireItemDefinedMulti: Question with a defined set of options, where multiple options can be selected.", true, ["Option 1", "Option 2", "Option 3"])
);
screens.push(screen2);
//This screen that just waits for a defined time (in seconds).
var screen3 = new ScreenWait(undefined, 3, 'Just wait 3 seconds.');
screens.push(screen3);

//This screen that just waits for a defined time (in seconds).
var screen3 = new ScreenWait(undefined, 3, 'Just wait 3 seconds.');
screens.push(screen3);
//This screen "shows" questions that are answered automatically (and are not visible to the user).
var screen4 = new ScreenUIElements(
new UIElementHTML(undefined, "This screen stores data like the current data, the duration the screen was shown and the URL."),
new QuestionnaireItemSystemURL(),
new QuestionnaireItemSystemScreenDateTime(),
new QuestionnaireItemSystemScreenDuration(),
new QuestionnaireItemSystemConst("Default text", "Some stuff")
);
screens.push(screen4);

//This screen "shows" questions that are answered automatically (and are not visible to the user).
var screen4 = new ScreenUIElements(
new UIElementHTML(undefined, "This screen stores data like the current data, the duration the screen was shown and the URL."),
new QuestionnaireItemSystemURL(),
new QuestionnaireItemSystemScreenDateTime(),
new QuestionnaireItemSystemScreenDuration(),
new QuestionnaireItemSystemConst("Default text", "Some stuff")
);
screens.push(screen4);
//This screen shows a preview of the collected data.
screens.push(new ScreenDataPreview("screenPreview"));

//This screen shows a preview of the collected data.
screens.push(new ScreenDataPreview("screenPreview"));
//This screen triggers the download all collected data (CSV).
screens.push(new ScreenWaitDataDownload(undefined, "The End<br>All data should now be downloaded."));

//This screen triggers the download all collected data (CSV).
screens.push(new ScreenWaitDataDownload(undefined, "The End<br>All data should now be downloaded."));
//Most important: create the ScreenController
var screenController = new ScreenController(screens);

//Most important: create the ScreenController
var screenController = new ScreenController(screens);
</script>
<script type="text/javascript">
document.oncontextmenu = new Function("return false;") //Disable context menu (right click)
</script>
<script type="text/javascript">
document.oncontextmenu = new Function("return false;") //Disable context menu (right click)

//Having the start()-function in an extra script-tag makes sure that it will be executed even if there are errors in the script-tag configuring TheFragebogen.
function start() {
document.body.innerHTML += "TheFragebogen loaded.";
if (typeof(screenController) === "undefined") {
document.body.innerHTML += "<br><i>Something went wrong:<\/i> Please check that thefragebogen.js was loaded and that the configuration is ok.";
return;
//Having the start()-function in an extra script-tag makes sure that it will be executed even if there are errors in the script-tag configuring TheFragebogen.
function start() {
document.body.innerHTML += "TheFragebogen loaded.";
if (typeof(screenController) === "undefined") {
document.body.innerHTML += "<br><i>Something went wrong:<\/i> Please check that thefragebogen.js was loaded and that the configuration is ok.";
return;
}
screenController.init(document.body);
screenController.start();
}
screenController.init(document.body);
screenController.start();
}
</script>
</head>
<body onload="start()">
<p>
TheFragebogen will be shown here.<br>
If something fails while starting, an error message will be shown here.
</p>
</body>

</script>
</head>

<body onload="start()">
<p>
TheFragebogen will be shown here.<br> If something fails while starting, an error message will be shown here.
</p>
</body>

</html>
91 changes: 47 additions & 44 deletions examples/example_dynamic.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="example.css">
<script src="../thefragebogen.js">
</script>
<script>
var screenController = new ScreenController(
new ScreenUIElements(
new UIElementHTML(undefined, "Welcome!<br><br>This demo shows you how to create 'dynamic' or so-called responsive questionnaires."),
new UIElementHTML(undefined, "This questionnaire does not end and will always look the same.<br> Each time pressing 'next' a new Screen is created, which shows the time at which the previous screen was started."),
new QuestionnaireItemSystemScreenDateTime())

<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="example.css">
<script src="../thefragebogen.js"></script>
<script>
var screenController = new ScreenController(
new ScreenUIElements(
new UIElementHTML(undefined, "Welcome!<br><br>This demo shows you how to create 'dynamic' or so-called responsive questionnaires."),
new UIElementHTML(undefined, "This questionnaire does not end and will always look the same.<br> Each time pressing 'next' a new Screen is created, which shows the time at which the previous screen was started."),
new QuestionnaireItemSystemScreenDateTime())
);
</script>
<script type="text/javascript">
document.oncontextmenu = new Function("return false;") //Disable context menu (right click)

function start() {
document.body.innerHTML += "TheFragebogen loaded.";
if (typeof(screenController) === "undefined") {
document.body.innerHTML += "<br><i>Something went wrong:<\/i> Please check the configuration.";
return;

</script>
<script type="text/javascript">
document.oncontextmenu = new Function("return false;") //Disable context menu (right click)

function start() {
document.body.innerHTML += "TheFragebogen loaded.";
if (typeof(screenController) === "undefined") {
document.body.innerHTML += "<br><i>Something went wrong:<\/i> Please check the configuration.";
return;
}

screenController.init(document.body);

screenController.setCallbackScreenFinished(function() {
screenController.getCurrentScreenIndex();
var nextIndex = screenController.addScreen(new ScreenUIElements(
new UIElementHTML(undefined, "Welcome!<br><br>This demo shows you how to create 'dynamic' or responsive questionnaires."),
new UIElementHTML(undefined, "" + screenController.getCurrentScreen().uiElements[2].getAnswer()),
new QuestionnaireItemSystemScreenDateTime()
));
screenController.goToScreen(nextIndex);
return false;
});

screenController.start();
}

screenController.init(document.body);

screenController.setCallbackScreenFinished(function () {
screenController.getCurrentScreenIndex();
var nextIndex = screenController.addScreen(new ScreenUIElements(
new UIElementHTML(undefined, "Welcome!<br><br>This demo shows you how to create 'dynamic' or responsive questionnaires."),
new UIElementHTML(undefined, "" + screenController.getCurrentScreen().uiElements[2].getAnswer()),
new QuestionnaireItemSystemScreenDateTime()
));
screenController.goToScreen(nextIndex);
return false;
});

screenController.start();
}
</script>
</head>
<body onload="start()">
<p>
TheFragebogen will be shown here.<br>
If something fails while starting, an error message will be shown here.
</p>
</body>
</script>
</head>

<body onload="start()">
<p>
TheFragebogen will be shown here.<br> If something fails while starting, an error message will be shown here.
</p>
</body>

</html>
22 changes: 12 additions & 10 deletions examples/example_export_nodejs_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ nodejs example_export_nodejs_upload.js
var http = require('http');

//We need a function which handles requests and send response
function handleRequest(request, response){
function handleRequest(request, response) {
console.log("Got message:");

response.setHeader('Access-Control-Allow-Origin', '*');

var body = [];
request.on('data', function(chunk) {
body.push(chunk);
body.push(chunk);
}).on('end', function() {
body = Buffer.concat(body).toString();
console.log(body);
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end("");
console.log("===============================================\n");
body = Buffer.concat(body).toString();
console.log(body);
response.writeHead(200, {
'Content-Type': 'text/plain'
});
response.end("");
console.log("===============================================\n");
});
}

var server = http.createServer(handleRequest);
server.listen(8088, function(){
console.log("Server listening");
console.log("===============================================");
server.listen(8088, function() {
console.log("Server listening");
console.log("===============================================");
});
Loading

0 comments on commit 9d0a277

Please sign in to comment.