Fix issue #10, newlines should be showing up now

Took 27 minutes
This commit is contained in:
Tobias Hopp 2020-10-04 21:04:25 +02:00
parent 10ae17b246
commit c2fe6c4d08
4 changed files with 29 additions and 14 deletions

31
.idea/workspace.xml generated
View File

@ -20,8 +20,9 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="fc13552d-b118-4828-b78f-fc8714e0cfdc" name="Default Changelist" comment="Final COMMIT!!!"> <list default="true" id="fc13552d-b118-4828-b78f-fc8714e0cfdc" name="Default Changelist" comment="Final COMMIT!!!">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/model/FaqModel.class.inc.php" beforeDir="false" afterPath="$PROJECT_DIR$/model/FaqModel.class.inc.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/faq.tmpl.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/faq.tmpl.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/vendor/js/faq.js" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/js/faq.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/vendor/js/faq.js" beforeDir="false" afterPath="$PROJECT_DIR$/vendor/js/faq.js" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -33,7 +34,7 @@
<execution /> <execution />
</component> </component>
<component name="DarkyenusTimeTracker"> <component name="DarkyenusTimeTracker">
<option name="totalTimeSeconds" value="84311" /> <option name="totalTimeSeconds" value="85844" />
<option name="gitIntegration" value="true" /> <option name="gitIntegration" value="true" />
<option name="naggedAbout" value="1" /> <option name="naggedAbout" value="1" />
</component> </component>
@ -79,7 +80,7 @@
<updated>1601618466935</updated> <updated>1601618466935</updated>
<workItem from="1601618467981" duration="36776000" /> <workItem from="1601618467981" duration="36776000" />
<workItem from="1601809534320" duration="1558000" /> <workItem from="1601809534320" duration="1558000" />
<workItem from="1601811106543" duration="13977000" /> <workItem from="1601811106543" duration="15934000" />
</task> </task>
<task id="LOCAL-00001" summary="Initial commit"> <task id="LOCAL-00001" summary="Initial commit">
<created>1601618764031</created> <created>1601618764031</created>
@ -242,7 +243,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1601836166244</updated> <updated>1601836166244</updated>
</task> </task>
<option name="localTasksCounter" value="24" /> <task id="LOCAL-00024" summary="Updating a little time-issue and install gitignore">
<created>1601836234258</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1601836234258</updated>
</task>
<option name="localTasksCounter" value="25" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -281,7 +289,8 @@
<MESSAGE value="Fixing answer text bug #6" /> <MESSAGE value="Fixing answer text bug #6" />
<MESSAGE value="Updating FAQ-Gui" /> <MESSAGE value="Updating FAQ-Gui" />
<MESSAGE value="Fix issue #9" /> <MESSAGE value="Fix issue #9" />
<option name="LAST_COMMIT_MESSAGE" value="Fix issue #9" /> <MESSAGE value="Updating a little time-issue and install gitignore" />
<option name="LAST_COMMIT_MESSAGE" value="Updating a little time-issue and install gitignore" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="728" y="326" width="800" height="683" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1601632929047"> <state x="728" y="326" width="800" height="683" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1601632929047">
@ -328,13 +337,17 @@
<screen x="0" y="34" width="1920" height="1046" /> <screen x="0" y="34" width="1920" height="1046" />
</state> </state>
<state x="809" y="122" width="639" height="876" key="com.intellij.database.view.ui.AbstractDbRefactoringDialog/0.34.1920.1046@0.34.1920.1046" timestamp="1601632983240" /> <state x="809" y="122" width="639" height="876" key="com.intellij.database.view.ui.AbstractDbRefactoringDialog/0.34.1920.1046@0.34.1920.1046" timestamp="1601632983240" />
<state x="739" y="469" width="432" height="182" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1601624836751"> <state x="739" y="469" width="442" height="182" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1601837188867">
<screen x="0" y="34" width="1920" height="1046" /> <screen x="0" y="34" width="1920" height="1046" />
</state> </state>
<state x="739" y="469" width="432" height="182" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601624836751" /> <state x="739" y="469" width="442" height="182" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2/0.34.1920.1046@0.34.1920.1046" timestamp="1601837188867" />
<state x="623" y="264" width="672" height="678" key="search.everywhere.popup" timestamp="1601644839580"> <state x="641" y="122" width="638" height="870" key="find.popup" timestamp="1601836650536">
<screen x="0" y="34" width="1920" height="1046" /> <screen x="0" y="34" width="1920" height="1046" />
</state> </state>
<state x="623" y="264" width="672" height="678" key="search.everywhere.popup/0.34.1920.1046@0.34.1920.1046" timestamp="1601644839580" /> <state x="641" y="122" width="638" height="870" key="find.popup/0.34.1920.1046@0.34.1920.1046" timestamp="1601836650536" />
<state x="623" y="264" width="672" height="678" key="search.everywhere.popup" timestamp="1601836633752">
<screen x="0" y="34" width="1920" height="1046" />
</state>
<state x="623" y="264" width="672" height="678" key="search.everywhere.popup/0.34.1920.1046@0.34.1920.1046" timestamp="1601836633752" />
</component> </component>
</project> </project>

View File

@ -83,14 +83,14 @@ class FaqModel
public function addQuestion(int $room_id, string $question, string $nickname ) public function addQuestion(int $room_id, string $question, string $nickname )
{ {
$stmnt = Database::getConnection()->prepare( 'INSERT INTO questions ( room_id, question, created_by ) VALUES ( :room_id, :question, :created_by )' ); $stmnt = Database::getConnection()->prepare( 'INSERT INTO questions ( room_id, question, created_by ) VALUES ( :room_id, :question, :created_by )' );
$stmnt->execute( array( 'room_id' => $room_id, 'question' => htmlspecialchars( $question ), 'created_by' => $nickname ) ); $stmnt->execute( array( 'room_id' => $room_id, 'question' => htmlspecialchars($question, ENT_QUOTES, 'UTF-8'), 'created_by' => $nickname ) );
} }
public function addAnswer(int $question_id, string $answer) public function addAnswer(int $question_id, string $answer)
{ {
$stmnt = Database::getConnection()->prepare( 'UPDATE questions SET answer = :answer WHERE id = :id' ); $stmnt = Database::getConnection()->prepare( 'UPDATE questions SET answer = :answer WHERE id = :id' );
$stmnt->execute( array( 'answer' => htmlspecialchars( $answer ), 'id' => $question_id ) ); $stmnt->execute( array( 'answer' => htmlspecialchars($answer, ENT_QUOTES, 'UTF-8'), 'id' => $question_id ) );
} }
@ -123,7 +123,7 @@ class FaqModel
{ {
return false; return false;
} }
$result['question'] = str_replace( "\n", '<br>', $result['question'] );
return $result; return $result;
} }
} }

View File

@ -141,7 +141,7 @@
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<span id="readMoreModalText" class="text-justify">Loading...</span> <span id="readMoreModalText" class="text-justify" style="white-space: pre-line;" >Loading...</span>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

4
vendor/js/faq.js vendored
View File

@ -157,7 +157,9 @@ function openAnswerModal( id )
answerModalTitle.html( 'Answer ' + result.data.created_by + "'s question" ); answerModalTitle.html( 'Answer ' + result.data.created_by + "'s question" );
if( result.data.answer !== null && result.data.answer.length > 5 ) if( result.data.answer !== null && result.data.answer.length > 5 )
{ {
answerText.val( result.data.answer ); let this_answer = result.data.answer;
this_answer.replace(/(?:\r\n|\r|\n)/g, '<br>');
answerText.val( this_answer );
} }
else else
{ {