Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Danny Froberg
steempress_amn
Commits
ff7c4e6e
Commit
ff7c4e6e
authored
Aug 28, 2018
by
Martin Lees
Browse files
Fixed the front page display errors
parent
d9dbc5a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/class-steempress_sp-public.php
View file @
ff7c4e6e
...
...
@@ -109,6 +109,7 @@ class Steempress_sp_Public {
if
(
!
isset
(
$options
[
"twoway"
]))
$options
[
"twoway"
]
=
"off"
;
...
...
@@ -122,6 +123,7 @@ class Steempress_sp_Public {
$payout
=
""
;
$data
=
""
;
$comments
=
""
;
$front_page
=
""
;
if
(
sizeof
(
$username
)
==
1
and
sizeof
(
$permlink
)
==
1
and
sizeof
(
$tag
)
==
1
)
{
...
...
@@ -129,18 +131,17 @@ class Steempress_sp_Public {
$permlink
=
$permlink
[
0
];
$tag
=
$tag
[
0
];
$data
=
"<div
id
=
\"
steempress_sp_username
\"
style=
\"
display: none;
\"
>"
.
$username
.
"</div>"
;
$data
.
=
"<div
id
=
\"
steempress_sp_permlink
\"
style=
\"
display: none;
\"
>"
.
$permlink
.
"</div>"
;
$data
.
=
"<div
id
=
\"
steempress_sp_tag
\"
style=
\"
display: none;
\"
>"
.
$tag
.
"</div>"
;
$data
=
"<div
name
=
\"
steempress_sp_username
\"
style=
\"
display: none;
\"
>"
.
$username
.
"</div>"
;
$data
.
=
"<div
name
=
\"
steempress_sp_permlink
\"
style=
\"
display: none;
\"
>"
.
$permlink
.
"</div>"
;
$data
.
=
"<div
name
=
\"
steempress_sp_tag
\"
style=
\"
display: none;
\"
>"
.
$tag
.
"</div>"
;
$payout
=
"<div id='steempress_sp_price'>0.000$</div>"
;
$payout
=
"<div name='steempress_sp_price'>0.000$</div>"
;
if
(
!
is_front_page
())
$comments
=
"<br/><div name='steempress_sp_comments'></div>"
;
// comment zone
$comments
=
"<br/><div id='steempress_sp_comments'></div>"
;
}
return
$content
.
$data
.
$payout
.
$comments
;
return
$content
.
$data
.
$payout
.
$comments
.
$front_page
;
}
else
return
$content
;
...
...
public/js/steempress_sp-public.js
View file @
ff7c4e6e
...
...
@@ -2,48 +2,77 @@
(
function
(
$
)
{
'
use strict
'
;
// Create the XHR object.
function
createCORSRequest
()
{
var
url
=
"
http://localhost:8002
"
var
xhr
=
new
XMLHttpRequest
();
if
(
"
withCredentials
"
in
xhr
)
{
// XHR for Chrome/Firefox/Opera/Safari.
xhr
.
open
(
"
POST
"
,
url
,
true
);
}
else
if
(
typeof
XDomainRequest
!=
"
undefined
"
)
{
// XDomainRequest for IE.
xhr
=
new
XDomainRequest
();
xhr
.
open
(
"
POST
"
,
url
);
}
else
{
// CORS not supported.
xhr
=
null
;
}
return
xhr
;
}
function
post_request
(
username
,
permlink
,
tag
,
steempress_sp_price
,
steempress_sp_comment
)
{
var
xhr
=
createCORSRequest
();
if
(
steempress_sp_comment
===
null
)
var
params
=
"
username=
"
+
username
+
"
&permlink=
"
+
permlink
+
"
&tag=
"
+
tag
+
"
&display_comment=false
"
;
else
var
params
=
"
username=
"
+
username
+
"
&permlink=
"
+
permlink
+
"
&tag=
"
+
tag
+
"
&display_comment=true
"
;
xhr
.
setRequestHeader
(
"
Content-type
"
,
"
application/x-www-form-urlencoded
"
);
xhr
.
setRequestHeader
(
"
Content-length
"
,
params
.
length
);
if
(
!
xhr
)
{
return
;
}
xhr
.
steempress_sp_price
=
steempress_sp_price
;
xhr
.
steempress_sp_comment
=
steempress_sp_comment
;
xhr
.
username
=
username
;
xhr
.
permlink
=
permlink
;
// Response handlers.
xhr
.
onload
=
function
()
{
var
data
=
JSON
.
parse
(
xhr
.
responseText
);
this
.
steempress_sp_price
.
innerHTML
=
data
.
payout
;
if
(
this
.
steempress_sp_comment
!==
null
)
this
.
steempress_sp_comment
.
innerHTML
=
data
.
comments
;
};
xhr
.
send
(
params
);
}
function
load_steem_capabilities
()
{
const
username
=
$
(
"
#steempress_sp_username
"
)[
0
].
innerText
;
const
permlink
=
$
(
"
#steempress_sp_permlink
"
)[
0
].
innerText
;
const
tag
=
$
(
"
#steempress_sp_tag
"
)[
0
].
innerText
;
// Create the XHR object.
function
createCORSRequest
(
method
,
url
)
{
var
xhr
=
new
XMLHttpRequest
();
if
(
"
withCredentials
"
in
xhr
)
{
// XHR for Chrome/Firefox/Opera/Safari.
xhr
.
open
(
method
,
url
,
true
);
}
else
if
(
typeof
XDomainRequest
!=
"
undefined
"
)
{
// XDomainRequest for IE.
xhr
=
new
XDomainRequest
();
xhr
.
open
(
method
,
url
);
}
else
{
// CORS not supported.
xhr
=
null
;
}
return
xhr
;
}
const
usernames
=
document
.
getElementsByName
(
"
steempress_sp_username
"
);
const
permlinks
=
document
.
getElementsByName
(
"
steempress_sp_permlink
"
);
const
tags
=
document
.
getElementsByName
(
"
steempress_sp_tag
"
);
const
front_page
=
(
document
.
getElementsByName
(
"
steempress_sp_comments
"
).
length
===
0
);
var
steempress_sp_prices
=
document
.
getElementsByName
(
"
steempress_sp_price
"
);
var
steempress_sp_comments
=
document
.
getElementsByName
(
"
steempress_sp_comments
"
);
var
url
=
"
http://localhost:8002
"
;
for
(
var
i
=
0
;
i
<
usernames
.
length
;
i
++
)
{
var
xhr
=
createCORSRequest
(
'
POST
'
,
url
);
var
params
=
"
username=
"
+
username
+
"
&permlink=
"
+
permlink
+
"
&tag=
"
+
tag
;
xhr
.
setRequestHeader
(
"
Content-type
"
,
"
application/x-www-form-urlencoded
"
);
xhr
.
setRequestHeader
(
"
Content-length
"
,
params
.
length
);
if
(
!
xhr
)
{
return
;
}
var
username
=
usernames
[
i
].
innerText
;
var
permlink
=
permlinks
[
i
].
innerText
;
var
tag
=
tags
[
i
].
innerText
;
// Response handlers.
xhr
.
onload
=
function
()
{
var
data
=
JSON
.
parse
(
xhr
.
responseText
);
$
(
"
#steempress_sp_price
"
)[
0
].
innerHTML
=
data
.
payout
;
$
(
"
#steempress_sp_comments
"
)[
0
].
innerHTML
=
data
.
comments
;
};
var
steempress_sp_price
=
steempress_sp_prices
[
i
];
var
steempress_sp_comment
=
(
!
front_page
?
steempress_sp_comments
[
i
]
:
null
);
xhr
.
send
(
params
);
post_request
(
username
,
permlink
,
tag
,
steempress_sp_price
,
steempress_sp_comment
);
}
}
$
(
window
).
load
(
load_steem_capabilities
)
...
...
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