Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
ccfca9d5
Commit
ccfca9d5
authored
Mar 27, 2017
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix empty script tag
Clean up some of the JS code
parent
833153ec
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
17 deletions
+25
-17
page.php
qa-include/app/page.php
+10
-7
question-view.php
qa-include/pages/question-view.php
+13
-8
qa-theme-base.php
qa-include/qa-theme-base.php
+2
-2
No files found.
qa-include/app/page.php
View file @
ccfca9d5
...
...
@@ -337,15 +337,19 @@ function qa_output_content($qa_content)
if
(
isset
(
$qa_content
[
'script_rel'
]))
{
$uniquerel
=
array_unique
(
$qa_content
[
'script_rel'
]);
// remove any duplicates
foreach
(
$uniquerel
as
$script_rel
)
foreach
(
$uniquerel
as
$script_rel
)
{
$script
[]
=
'<script src="'
.
qa_html
(
qa_path_to_root
()
.
$script_rel
)
.
'"></script>'
;
}
}
if
(
isset
(
$qa_content
[
'script_src'
]))
{
$uniquesrc
=
array_unique
(
$qa_content
[
'script_src'
]);
// remove any duplicates
foreach
(
$uniquesrc
as
$script_src
)
foreach
(
$uniquesrc
as
$script_src
)
{
$script
[]
=
'<script src="'
.
qa_html
(
$script_src
)
.
'"></script>'
;
}
}
// JS onloads must come after jQuery is loaded
if
(
isset
(
$qa_content
[
'focusid'
]))
{
$qa_content
[
'script_onloads'
][]
=
array
(
...
...
@@ -353,20 +357,19 @@ function qa_output_content($qa_content)
);
}
// JS onloads must come after jQuery is loaded
$script
[]
=
'<script>'
;
if
(
isset
(
$qa_content
[
'script_onloads'
]))
{
$script
[]
=
'<script>'
;
$script
[]
=
'$(window).load(function() {'
;
foreach
(
$qa_content
[
'script_onloads'
]
as
$scriptonload
)
{
foreach
((
array
)
$scriptonload
as
$scriptline
)
foreach
((
array
)
$scriptonload
as
$scriptline
)
{
$script
[]
=
"
\t
"
.
$scriptline
;
}
}
$script
[]
=
'});'
;
}
$script
[]
=
'</script>'
;
}
if
(
!
isset
(
$qa_content
[
'script'
]))
{
$qa_content
[
'script'
]
=
array
();
...
...
qa-include/pages/question-view.php
View file @
ccfca9d5
...
...
@@ -973,23 +973,25 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question,
$captchaloadscript
=
qa_set_up_captcha_field
(
$qa_content
,
$form
[
'fields'
],
$errors
,
qa_captcha_reason_note
(
$captchareason
));
if
(
strlen
(
$captchaloadscript
))
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_show
=
function() { '
.
$captchaloadscript
.
' };'
;
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_show
=
function() { '
.
$captchaloadscript
.
' };'
;
}
if
(
!
$loadnow
)
{
if
(
method_exists
(
$editor
,
'load_script'
))
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_load
=
function() { '
.
$editor
->
load_script
(
'a_content'
)
.
' };'
;
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_load
=
function() { '
.
$editor
->
load_script
(
'a_content'
)
.
' };'
;
$form
[
'buttons'
][
'cancel'
][
'tags'
]
.=
' onclick="return qa_toggle_element();"'
;
}
if
(
!
$formrequested
)
{
if
(
method_exists
(
$editor
,
'focus_script'
))
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_focus
=
function() { '
.
$editor
->
focus_script
(
'a_content'
)
.
' };'
;
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_focus
=
function() { '
.
$editor
->
focus_script
(
'a_content'
)
.
' };'
;
}
if
(
count
(
$onloads
))
if
(
count
(
$onloads
))
{
$qa_content
[
'script_onloads'
][]
=
$onloads
;
}
break
;
}
...
...
@@ -1118,22 +1120,25 @@ function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captch
$captchaloadscript
=
qa_set_up_captcha_field
(
$qa_content
,
$form
[
'fields'
],
$errors
,
qa_captcha_reason_note
(
$captchareason
));
if
(
strlen
(
$captchaloadscript
))
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_show
=
function() { '
.
$captchaloadscript
.
' };'
;
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_show
=
function() { '
.
$captchaloadscript
.
' };'
;
}
if
(
!
$loadfocusnow
)
{
if
(
method_exists
(
$editor
,
'load_script'
))
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_load
=
function() { '
.
$editor
->
load_script
(
$prefix
.
'content'
)
.
' };'
;
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_load
=
function() { '
.
$editor
->
load_script
(
$prefix
.
'content'
)
.
' };'
;
if
(
method_exists
(
$editor
,
'focus_script'
))
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_focus
=
function() { '
.
$editor
->
focus_script
(
$prefix
.
'content'
)
.
' };'
;
$onloads
[]
=
'document.getElementById('
.
qa_js
(
$formid
)
.
').qa_focus
=
function() { '
.
$editor
->
focus_script
(
$prefix
.
'content'
)
.
' };'
;
$form
[
'buttons'
][
'cancel'
][
'tags'
]
.=
' onclick="return qa_toggle_element()"'
;
}
if
(
count
(
$onloads
))
if
(
count
(
$onloads
))
{
$qa_content
[
'script_onloads'
][]
=
$onloads
;
}
break
;
}
$form
[
'id'
]
=
$formid
;
$form
[
'collapse'
]
=
!
$loadfocusnow
;
$form
[
'style'
]
=
'tall'
;
...
...
qa-include/qa-theme-base.php
View file @
ccfca9d5
...
...
@@ -411,8 +411,8 @@ class qa_html_theme_base
{
$this
->
output
(
'<script>'
,
"var b
=
document.getElementsByTagName('body')[0];"
,
"b.className
=
b.className.replace('qa-body-js-off', 'qa-body-js-on');"
,
"var b
=
document.getElementsByTagName('body')[0];"
,
"b.className
=
b.className.replace('qa-body-js-off', 'qa-body-js-on');"
,
'</script>'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment