News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Like Posts

Started by vbgamer45, June 29, 2013, 09:29:03 AM

Previous topic - Next topic

Joker™

Quote from: Exsharaen on August 20, 2013, 03:16:39 AM
Hi Joker,

I have the same issue as drfun:
Quote from: drfun on July 19, 2013, 07:44:25 AM
1. When i click on LIKE, it takes me to the top page, without any change
2. within the post message, if i click LIKE, it takes me to the top page,without any change also
3. On replied post, when i click LIKE, it takes me to the top page, without any change

This was tested on my system with the default smf theme

I decided to look at Chrome's console and discovered this:

(whoops sorry for that Steam popup :D)

I'm not really familiar with JavaScript, but a quick search reveals that it is a use of jQuery. I checked my head section and did not discover any external script link to jQuery (and I didn't remember I used one). Does this mod use jQuery?

As a temporary remedy while waiting for your answer, I tried to manually edit my Load.php by changing your code from this:
if (isset($_GET['board']) || isset($_GET['topic'])) {
        $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/LikePosts.css" />';
    }

into this:
if (isset($_GET['board']) || isset($_GET['topic']) || (isset($_GET['area']) && $_GET['area'] == 'likeposts')) {
        $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url']. '/css/LikePosts.css" />';
$context['html_headers'] .= '<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>'; // maybe this one can be omitted?
    }

and LikePosts.php from this:
if (!window.jQuery) {
document.write("<script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\"><\/script>");
}

into this:
if (!window.jQuery) {
document.write("<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.10.2.min.js\"><\/script>");
}

and now it works like a charm.

Except that somehow my likes on message lists are reset on page refreshes, although my profile still keep tracks of it. Still don't know why this happens and how to fix it.

Thank you anyway for this mod, I like it!

EDIT:
Silly me, I missed your statement here:
Quote from: Joker™ on July 29, 2013, 01:24:54 PM
Quote from: MechSpecs on July 29, 2013, 11:46:02 AM
I played with this on my sandbox and have a couple of suggestions; shot you a PM
Ok seen the UI of buttons and looks nice.

Well I have made certain UI changes with Like/Dislike buttons and still waiting to hear from you guys :P.

Major thing with this mod is that it makes usage of ajax to interact with server, so in terms of UI it need to show some sort of fadeIn/fadeOut sort of effect etc. Lol, using bit more of jQuery this time I have introduced slide + fade effect.

Still I'm all ears, and if you guys have suggestions please do post them :).

Guess this is what I get when skipping breakfast :D

I'm on SMF 2.0.5 by the way.
It seems like some other mod is also loading jQuery due to which something something is happening :P. Lol, in simple words jQuery is fighting against each other. I've fixed this in one of  my mods, I'll be porting the fix over here as well.

* Joker™ claps for Exsharaen, for providing such an excellent screenshot of issue.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

ScrumpyJack

#61
Hi Joker!

I also really like this mod...although for some reason it is only working with the default theme of my message board.

On alternative themes, you can see the like button but it doesn't do anything.

I uninstalled and reinstalled it, making sure that all of the themes were included (all were confirmed as successful) but this still didn't work.

Do you have any idea what might be causing this please?

Thanks

Lee
:)

Joker™

Quote from: ScrumpyJack on August 20, 2013, 12:45:41 PM
Hi Joker!

I also really like this mod...although for some reason it is only working with the default theme of my message board.

On alternative themes, you can see the like button but it doesn't do anything.

I uninstalled and reinstalled it, making sure that all of the themes were included (all were confirmed as successful) but this still didn't work.

Do you have any idea what might be causing this please?

Thanks

Lee
:)
Umm can you tell me the theme names, as I will be able to debug the issue more easily.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

ScrumpyJack

I have also noticed another weird problem........

If I click on a thread to like it....it recognises that I have liked it as you would expect.

When I have refreshed the page in the Board view....I can still Like it again (Unlike isn't showing).

If I actually go into the post view, It shows that I already like the post.

Themes where I have found that it either does nothing, or returns me to the top of the page

Firox Multicolor
Astonished
Bluez
X-Mas
Happy New Year
Blu
Carbonate
Coalblack
CleanTek

Thanks

Lee
:)

Joker™

Quote from: ScrumpyJack on August 21, 2013, 01:27:44 PM
I have also noticed another weird problem........

If I click on a thread to like it....it recognises that I have liked it as you would expect.

When I have refreshed the page in the Board view....I can still Like it again (Unlike isn't showing).

If I actually go into the post view, It shows that I already like the post.

Themes where I have found that it either does nothing, or returns me to the top of the page

Firox Multicolor
Astonished
Bluez
X-Mas
Happy New Year
Blu
Carbonate
Coalblack
CleanTek

Thanks

Lee
:)
Thanks for the themes, but with these themes I'm not able to reproduce both of the issues mentioned above

-  Clicking like page goes to top, and
- Like/unlike not toggle on board view

I'll try my best to reproduce the issue :).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

pevanis

#65
Hi Joker!
Thanks for good ideea :-)

I also really like this mod...although for some reason it is not working you can see the like button but it doesn't do anything.

I uninstalled and reinstalled it, but this still didn't work.
same as drfun.
1. When i click on LIKE, it takes me to the top page, without any change
2. within the post message, if i click LIKE, it takes me to the top page,without any change also
3. On replied post, when i click LIKE, it takes me to the top page, without any change

Theme on my forum is Blackjack ( http://custom.simplemachines.org/themes/index.php?lemma=2360 )



Joker™

Just before pushing out a new version with changes, anyone want to try them out?

This fix is only for the users who are facing an issue while liking/unliking a post, i.e page just scrolls to top.

Well I was able to replicate the issue by turning of the internet or removing jQuery object from dom.

Note - these changes can break something else in terms of funcnality, so please make backup of files before changing anything


1. To make sure jQuery is loaded at any cost

Code (Find:Source/LikePosts.php) Select

function LP_includeAssets() {
global $settings, $context;

$context['insert_after_template'] .= '
<script type="text/javascript"><!-- // --><![CDATA[
if (!window.jQuery) {
document.write("<script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\"><\/script>");
}
if (!window.lpObj) {
document.write(\'<script src="' . $settings['default_theme_url'] . '/scripts/LikePosts.js"><\/script>\');
}
// ]]></script>';
}


Code (Replace it with:) Select

function LP_includeAssets() {
global $settings, $context;

$context['insert_after_template'] .= '
<script type="text/javascript"><!-- // --><![CDATA[
if (!window.jQuery) {
document.write("<script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js\"><\/script>");
}

var lpLoaded = !window.lpObj ? false : true;
function isJqueryLoaded() {
if (window.jQuery) {
if (!lpLoaded) {
lpLoaded = true;
var head= document.getElementsByTagName("head")[0];
var script= document.createElement("script");
script.type= "text/javascript";
document.write("<script type=\"text/javascript\" src=\"'. $settings['default_theme_url']. '/scripts/LikePosts.js\"><\/script>");
}
} else {
setTimeout(isJqueryLoaded, 100);
}
}
isJqueryLoaded();
// ]]></script>';
}


With the above code you need to replace LikePosts.js with the attached file.

Location -> themes/default/Scripts/LikePosts.js
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Burke ♞ Knight

Noticed typo that causes errors in Load.php file:

if (isset($_GET['board']) || isset($_GET['topic'])) {
        $context['html_header'] .= '<link rel="stylesheet" type="text/css" href="'. $settings['theme_url']. '/css/likeposts.css" />';


Needs to be:

if (isset($_GET['board']) || isset($_GET['topic'])) {
        $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="'. $settings['theme_url']. '/css/likeposts.css" />';


Missing s in html_headers

:)

Joker™

Quote from: BurkeKnight on August 25, 2013, 09:21:08 AM
Noticed typo that causes errors in Load.php file:

if (isset($_GET['board']) || isset($_GET['topic'])) {
        $context['html_header'] .= '<link rel="stylesheet" type="text/css" href="'. $settings['theme_url']. '/css/likeposts.css" />';


Needs to be:

if (isset($_GET['board']) || isset($_GET['topic'])) {
        $context['html_headers'] .= '<link rel="stylesheet" type="text/css" href="'. $settings['theme_url']. '/css/likeposts.css" />';


Missing s in html_headers

:)
Thanks for pointing that out :), but thats already fixed in
- Latest version 1.1
- Also on gitHub
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

impreza

And if it get connected with karma in some way. It would be even better
Portal ToTemat.pl - treści w postaci artykułów i filmów tematycznych.

Joker™

Quote from: impreza on August 27, 2013, 08:47:05 AM
And if it get connected with karma in some way. It would be even better
Umm not sure about that at this point, but who knows what can happen with the mods :P.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Motorhed

Would love if the Like Button was moved up to float left of the "Report to moderator" and "IP Logged" area beneath the post. That way it doesn't create its own otherwise blank line.

Unfortunately, it still doesn't work for me even with the new .js file.

I look forward to someday being able to use it, however.

Line:56
Char:9
Code:0
Error:Expected identifier, string or number
URL:http://tangledwebbing.com/forum/Themes/default/scripts/LikePosts.js

Joker™

Quote from: Motorhed on September 02, 2013, 01:56:40 AM
Would love if the Like Button was moved up to float left of the "Report to moderator" and "IP Logged" area beneath the post. That way it doesn't create its own otherwise blank line.

Unfortunately, it still doesn't work for me even with the new .js file.

I look forward to someday being able to use it, however.

Line:56
Char:9
Code:0
Error:Expected identifier, string or number
URL:http://tangledwebbing.com/forum/Themes/default/scripts/LikePosts.js

At last someone showed the courage to try it out. Thanks a lot man.

Try the new attached file. Above file had a small JS error which fails in strict mode of JS.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Motorhed

Yeah. I'm pretty awesome.

It's working now! This is one of so many Mods you'd expect to already BE there, but no. Thanks for taking the initiative.


Also, I just let the domain name "LoveThatJoker.com" expire. A line from the 80s Bat-Film. Coincidence!

Motorhed

Sorry, I was mistaken. Still not recording Likes.

Line:122
Char:9
Code:0
Error:Expected identifier, string or number
URL:http://tangledwebbing.com/forum/Themes/default/scripts/LikePosts.js

Joker™

Quote from: Motorhed on September 02, 2013, 08:11:34 PM
Sorry, I was mistaken. Still not recording Likes.

Line:122
Char:9
Code:0
Error:Expected identifier, string or number
URL:http://tangledwebbing.com/forum/Themes/default/scripts/LikePosts.js

Fixed. Hope this one works.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

mrbig

Thank you - I actually used the previous .js file you posted yesterday and it works great on my forum

Motorhed

"Liking" works!

Clicking "You Liked This" doesn't yet. :D Getting there.

Line:131
Char:21
Code:0
Error:'avatar.href' is null or not an object
URL:http://tangledwebbing.com/forum/Themes/default/scripts/LikePosts.js

mrbig

As far as I can see all the functions are working on my forum
When clicking "You liked this" or "x people liked this" it shows the names and avatars in a pop=up

I use a very slightly modified version of the Default template

Joker™

Quote from: Motorhed on September 03, 2013, 02:57:29 PM
"Liking" works!

Clicking "You Liked This" doesn't yet. :D Getting there.

Line:131
Char:21
Code:0
Error:'avatar.href' is null or not an object
URL:http://tangledwebbing.com/forum/Themes/default/scripts/LikePosts.js

Alrighty then. Joker installed something outstanding in his editor which is helping him to write JS in strict mode, and removal or errors has became easier then everzzz :P.


Quote from: mrbig on September 04, 2013, 09:19:05 AM
As far as I can see all the functions are working on my forum
When clicking "You liked this" or "x people liked this" it shows the names and avatars in a pop=up

I use a very slightly modified version of the Default template
Well its an error in load of jQuery and conflict b/w different jQuery versions.

Well I've fixed the JS on gitHub completely.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Advertisement: