Great Western Coffee Shop

Sideshoots - associated subjects => News, Help and Assistance => Topic started by: grahame on June 08, 2014, 05:27:55



Title: The like button - what it does and does not do
Post by: grahame on June 08, 2014, 05:27:55
Thus far, 28 of our members have used the "like" button on a total of 71 posts. 

The "like" button - familiar to those of us who are regular Facebook users - is a great way to acknowledge and agree with a post, or show your appreciation, without having to write a somewhat banal positive yet null message. 

The way we've implemented the button on our very mature software is to simply turn the work "like" into "yum" when someone presses the button ... and at all future views of the page the name of the liker is shown up.   And if you've liked a post and change your mind, you can "unlike" once you've refreshed and your like is gone without trace (unless I were to trawl back through backups of the database!).

User names showing up on the 'like' are current ones - if you should change your visible user name (something we strongly discourage for the most part) then it will change on posts that you have liked to reflect your new persona.

At the present time there are no facilities to compress liker lists ("and 6 others") and no facilities for our members to do anything like sent personal messages or alerts to everyone who's liked a post, or who has liked any post within a thread, and there are no plans for such facilities.

I am aware that on the end of notifications sent by email, you may be getting an extra [like] word in the text.  Sorry about that - as the software wasn't written with the thought of having the like button, the fix doesn't look trivial and I'm concentrating more on getting passengers on the TransWilts line, a good input to the DfT consultation so that we can continue to get these good passenger numbers ( cos we still have an appropriate service - see http://www.railcustomer.info ), and on earning money to do the above and to feed ourselves, family and team.


Title: Re: The like button - what it does and does not do
Post by: Red Squirrel on June 08, 2014, 10:58:08

The way we've implemented the button on our very mature software is to simply turn the work "like" into "yum" when someone presses the button ...


Presumably that was to avoid confusion with the Yellowdog Updater, Modified?


Title: Re: The like button - what it does and does not do
Post by: LiskeardRich on June 08, 2014, 14:45:54
Grahame, when I liked your opening post here I was redirected to a blank page. Is that meant to happen?


Title: Re: The like button - what it does and does not do
Post by: grahame on June 08, 2014, 15:29:33
Grahame, when I liked your opening post here I was redirected to a blank page. Is that meant to happen?

Which browser are you using?   The server responds to the "like" with a 204 status code (no content) so it should not happen.


Title: Re: The like button - what it does and does not do
Post by: LiskeardRich on June 08, 2014, 22:13:12
Grahame, when I liked your opening post here I was redirected to a blank page. Is that meant to happen?

Which browser are you using?   The server responds to the "like" with a 204 status code (no content) so it should not happen.

I was on my ipad at the time, Safari of some kind

I've just liked the above post on IE10 and it goes into a load and continuously loads but going nowhere.


Title: Re: The like button - what it does and does not do
Post by: grahame on June 10, 2014, 06:02:58
Grahame, when I liked your opening post here I was redirected to a blank page. Is that meant to happen?

Which browser are you using?   The server responds to the "like" with a 204 status code (no content) so it should not happen.

I was on my ipad at the time, Safari of some kind

I've just liked the above post on IE10 and it goes into a load and continuously loads but going nowhere.

Hmm ... Status code 204 (the one I've used) is defined as follows:

Quote
10.2.5 204 No Content

The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant.

If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.

The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.

Any geek-types like to advise me of a better alternative?  200 would always redraw the page ... can I write a form of "target = null" into my Javascript request to prevent display at the client end?


Title: Re: The like button - what it does and does not do
Post by: 81F on June 10, 2014, 06:55:18
I tried to "like" Grahame's original post, and received

This page can^t be displayed
^Make sure the web address http://www.firstgreatwestern.info is correct.
^Look for the page with your search engine.
^Refresh the page in a few minutes.

My "like" does not appear to have registered.
Using IE (9?) on aol desktop


Title: Re: The like button - what it does and does not do
Post by: Brucey on June 10, 2014, 07:13:15
Try something like this, using jQuery (untested):

In the body:
Code:
<span id="txt155611" class="likebutton"><a href="#" class="likebutton">like</a></span>

In the head:
Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).on('click', "a.likebutton", function() {
    var spanID = $(this).parent("span").attr("id");
    var targetURL = '/coffeeshop/lyke.php?id=' . spanID;
var jqxhr = $.ajax(targetURL).done(function() {
$('#'.spanID).html = 'yum!';
});
});
</script>

Get lyke.php to respond with 200.


Title: Re: The like button - what it does and does not do
Post by: Godfrey Tables on June 10, 2014, 20:54:25
Quote
Any geek-types like to advise me of a better alternative?

I can highly recommend the dojo library which has a nice API for handling AJAX requests...
http://dojotoolkit.org/
.. or more specifically:
http://dojotoolkit.org/reference-guide/1.9/dojo/_base/xhr.html#dojo-base-xhr

Alternatively, would it be possible to just use the 'target' attribute of the anchor tag to load the anything returned by the server into a hidden iframe? That should 'contain' anything returned by the server without affecting the parent document, so it would be free to return a 200. This is a slightly hacky approach but it might be quick to implement...


Title: Re: The like button - what it does and does not do
Post by: grahame on June 11, 2014, 07:58:00
Those look like a couple of good ideas.  I'm a bit reluctant to start pulling in larger libraries although JQuery is getting to be pretty standard;  I will probably go with the "quick to implement" hack of redirecting to a hidden iFrame.   BIG pile of stuff on my plate for the next couple of days - probably a Sunday project for me to take further.


Title: Re: The like button - what it does and does not do
Post by: LiskeardRich on July 12, 2014, 00:59:37
Grahame, I'm using safari on iPad, and when clicking on like I just get a blank screen still. I couldn't gather from the above technical jargon whether this should have been rectified.
Screen print attached of what I am redirected to.


Title: Re: The like button - what it does and does not do
Post by: grahame on July 14, 2014, 07:00:40
Grahame, I'm using safari on iPad, and when clicking on like I just get a blank screen still. I couldn't gather from the above technical jargon whether this should have been rectified.
Screen print attached of what I am redirected to.

Not yet rectified - too busy with time-dependent stuff (walking in the carnival parade) and stuff that could go badly wrong if not handled ("Reading on Train" thread and fallout).  Busy "real job" week here too, so essentially don't expect a change in the next week - sorry.

As an aside, 390 registered "like"s to date. June forum posts down last month / a pattern we saw in June 2013 and June 2012 too; Some of that might (this year) be due to people clicking "like" who would otherwise have added a little comment to acknowledge reading and approving of the post.


Title: Re: The like button - what it does and does not do
Post by: grahame on August 04, 2014, 13:43:47
Pinging this up to the top of the pile ...

I've put in a mechanism to try and make it work nicer on other devices (a hidden iFrame) ... works on my browser, but please let me know how it works for you.

Up to 711 likes by 81 different members now ... so it's caught on a bit


Title: Re: The like button - what it does and does not do
Post by: TeaStew on August 04, 2014, 13:59:18
Seems to work fine for me using Safari on my phone!


Title: Re: The like button - what it does and does not do
Post by: brompton rail on August 04, 2014, 14:49:35
Yeh, works for me on my iPad!


Title: Re: The like button - what it does and does not do
Post by: thetrout on August 05, 2014, 10:43:13
Samsung Galaxy S4 it works but is glitchy.

When I click the like button I get taken to this URL in a new tab: http://www.firstgreatwestern.info/coffeeshop/lyke.php?id=158740

Which opens an empty page with just a dot. However if you refresh the "liked" page in the browser the "Like" button has registered.

Haven't tried a samsung tablet though (and don't have one to hand. Know someone who does though ;) )


Title: Re: The like button - what it does and does not do
Post by: grahame on January 19, 2015, 08:51:14
I have some test / demo code around that identifies the most recently liked articles ... the idea being that if it works nicely over a few weeks, we can have the first few posts identified highlighted at the top of the main page.    Take a look, and please like some posts.  Feedback welcome.

http://www.wellho.net/demo/liked.php


Title: Re: The like button - what it does and does not do
Post by: grahame on April 01, 2015, 06:25:14
Been looking at some stats since the like button was added, month by month.  This in number of likes registered month by month (and remaining registered - unlikes for people who have changed their mind not included):

482 March 2015
357 February
513 January 2015
512 December 2014
398 November
397 October
369 September
454 August
402 July
209 June
48 May 2014

Total 4141


Title: Re: The like button - what it does and does not do
Post by: Cynthia on April 01, 2015, 07:33:20
Grahame, when I liked your opening post here I was redirected to a blank page. Is that meant to happen?

That happens to me, too.  But I have learned that although when returning to the 'Home' page, the 'Like' has changed to 'Yum!', eventually my name appears as a 'Like', so although the system seems a bit slow, I know my 'Like' will be acknowledged eventually.  I use Google Chrome as a browser, by the way, as I anticipate this will be Grahame's next question!


Title: Re: The like button - what it does and does not do
Post by: grahame on April 01, 2015, 07:45:26
Grahame, when I liked your opening post here I was redirected to a blank page. Is that meant to happen?

That happens to me, too.  But I have learned that although when returning to the 'Home' page, the 'Like' has changed to 'Yum!', eventually my name appears as a 'Like', so although the system seems a bit slow, I know my 'Like' will be acknowledged eventually.  I use Google Chrome as a browser, by the way, as I anticipate this will be Grahame's next question!

I'm very much aware that the button is far from perfect in how it operates for some people; there are hard decisions to make as to where to invest scarse time.    Over the next 3 days, I *am* planning to work out best use of time and resources for the next few months, and if we have an HTML / CSS / Javascript expert around who has a bit of time to help ...  ;) :D ;D - it would be greatly appreciated.


Title: Re: The like button - what it does and does not do
Post by: Timmer on April 01, 2015, 17:15:00
I really like the 'Like' button, very useful.


Title: Re: The like button - what it does and does not do
Post by: thetrout on April 01, 2015, 17:32:44
Pressing the like button on Google Chrome does indeed do something strange:

(http://i.imgur.com/3oTSdCE.png)

(http://i.imgur.com/YxAu0Am.png)

(http://i.imgur.com/8mtZfQJ.png)

I'm no expert in PHP, but I would either suggest this is just a Google Chrome issue, or that it's a feedback of the PHP script throwing up the Asterisk * as a feedback of conclusion.

But without seeing the code or testing on another browser, I am purely speculating :)


Title: Re: The like button - what it does and does not do
Post by: Brucey on April 01, 2015, 20:09:18
The like button does two things:
1. An "onClick" changes the text from "like" to "yum!"
2. Redirects the user to /coffeesgop/lyke.php?id=[post-id] - I assume this script adds the like into the database and returns the asterisk

What really needs to change is the redirect should trigger an asynchronous request to the PHP script (i.e. do it in the background without the user ever noticing).  I would choose to do this with jQuery, but without this being installed on the site, it is possible (with slightly more coding) in JavaScript.


Title: Re: The like button - what it does and does not do
Post by: grahame on April 02, 2015, 06:42:53
The like button does two things:
1. An "onClick" changes the text from "like" to "yum!"
2. Redirects the user to /coffeesgop/lyke.php?id=[post-id] - I assume this script adds the like into the database and returns the asterisk

What really needs to change is the redirect should trigger an asynchronous request to the PHP script (i.e. do it in the background without the user ever noticing).  I would choose to do this with jQuery, but without this being installed on the site, it is possible (with slightly more coding) in JavaScript.

I've looked (still look) to avoid jQuery because of the download bloat - especially for on-train connections; here's the stuff I need to fix (PHP generating JavaScript) ... I know PHP but not Javascript.

Code:
$vv1 = 'onClick='."'".'document.getElementById("txt'."$cache_id".'").innerHTML="yuk!";' ."'";
$vv2 = 'onClick='."'".'document.getElementById("txt'."$cache_id".'").innerHTML="yum!";' ."'";
if ($ilike) {
                $message .= "<div style='text-align: right'>[<a href=/coffeeshop/lyke.php?id=$cache_id $vv1 target='bob'><span id='txt$cache_id'>unlike</span></a>] $ii</div>";
} else {
                $message .= "<div style='text-align: right'>[<a href=/coffeeshop/lyke.php?id=$cache_id $vv2 target='bob'><span id='txt$cache_id'>like</span></a>] $ii</div>";
}

My PHP does indeed return just "*" - I have previously tested it with
Code:
header("HTTP/1.1: 204 No Content");
but (as I recall) that was worser  :-\

If you're able to help with the JavaScript I need / what to return / do in my PHP,  I can see if I can implement that and make this work better for everyone.   What we have at the moment is a quick hack in response to requests and not a proud solution.


Title: Re: The like button - what it does and does not do
Post by: Brucey on April 02, 2015, 20:28:41
If you're able to help with the JavaScript I need / what to return / do in my PHP,  I can see if I can implement that and make this work better for everyone.   What we have at the moment is a quick hack in response to requests and not a proud solution.
I'll hack something together in the next few days.  Should be quite a simple and lightweight solution really.


Title: Re: The like button - what it does and does not do
Post by: Chris from Nailsea on April 02, 2015, 22:54:37
What really needs to change is the redirect should trigger an asynchronous request to the PHP script ...

Easy for you to say.  ::) :o ;D


Title: Re: The like button - what it does and does not do
Post by: Brucey on April 04, 2015, 10:39:49
Put this into the header:
Code:
<script type="text/javascript">
function likePost(postId) {
var httpreq;
if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        httpreq = new XMLHttpRequest();
} else {
        // code for IE6, IE5
        httpreq = new ActiveXObject("Microsoft.XMLHTTP");
}
httpreq.onreadystatechange = function() {
if(httpreq.readyState == 4  && httpreq.status == 200) {
var elementName = 'txt' + postId;
document.getElementById(elementName).innerHTML = 'yum!';
}
}
httpreq.open('GET', 'http://www.firstgreatwestern.info/coffeeshop/lyke.php?id=' + postId, true);
httpreq.send();
return;
}
</script>
Then replace the like button with this, but use the PHP variables to populate the post ID:
Code:
<a href="javascript:likePost(173763)"><span id="txt173763">like</span></a>

For the less techies, the JavaScript code for the page header creates a function that is called by the like button.  The button sends the post ID to the function, which in turn creates a call (in the background) to the like function on the server.  When the server responds with an "OK" (response code 200), then the like gets changed to yum.

Haven't been able to test this with the Coffee Shop as my browser blocks the cross-domain query.  But tested against a script on my own server and it works fine.


Title: Re: The like button - what it does and does not do
Post by: grahame on April 05, 2015, 14:48:57
Thanks, Brucey ...

I shall be experimenting over the next hour or so ... please excuse any glitches in the forum and unlikable likes I may sign up to!   When done I'll open the floor for "unwanted feature" [bug] reporting!


Title: Re: The like button - what it does and does not do
Post by: grahame on April 05, 2015, 17:54:25
I think it SHOULD work with Brucey's code (blame my lack of understanding if it doesn't) for "like"s.   If you unlike, still the old code while we test.

Unexpected bookings / goings on - a quiet day has become busier so I'm not around to code / check as much as I would like, but "open house" now to let me know of bugs!


Title: Re: The like button - what it does and does not do
Post by: JayMac on April 05, 2015, 18:53:46
Works for me. I'm no longer getting another tab open in Chrome when I 'like' a post.


Title: Re: The like button - what it does and does not do
Post by: Red Squirrel on April 05, 2015, 20:46:15
All good in FF36.0.4 too.


Title: Re: The like button - what it does and does not do
Post by: Chris from Nailsea on April 05, 2015, 21:15:50
"Easy for you to say."  :P ::) ;D


Title: Re: The like button - what it does and does not do
Post by: grahame on November 08, 2016, 13:13:21
In answer to a comment on the forum / no reason for stopping users who wish to 'like' their own posts. Some may think it's an odd thing to do - but I can imagine liking one of my own posts if (for example) one of the moderators has gone in, sorted my spelling out again, and commented to the effect in the post.


Title: Re: The like button - what it does and does not do
Post by: Chris from Nailsea on November 10, 2016, 22:33:32
Whoever would do such a thing?  :o ::) ;D



Title: Re: The like button - what it does and does not do
Post by: JayMac on November 10, 2016, 23:06:56
I've no Idea.  ;)


Title: Re: The like button - what it does and does not do
Post by: SandTEngineer on November 10, 2016, 23:20:41
Personally I think there should be an 'unliked' button for some of the posts we get..... ::)


Title: Re: The like button - what it does and does not do
Post by: grahame on November 11, 2016, 00:07:39
Personally I think there should be an 'unliked' button for some of the posts we get..... ::)

We could add an "interesting but I disagree" button, an "I acknowledge your post and the effort put not it and thank you for it but have nothing to add" button, and a "this is too technical for me to understand" button.  I would then, no doubt, be asked to add an "I can't read this on my phone because the screen is too cluttered with buttons" button ...


Title: Re: The like button - what it does and does not do
Post by: grahame on April 24, 2018, 15:32:42
The "recent likes" on the top of this forum - for members logged in - has lead to a page of topics that have generated such feedback for a while now.

Initially to see what members think of the idea, I have added an extra graphic on the top of our pages which is reporting the  top six stories - making the front page of the forum (and the bit 'above the fold') a one-stop shop for a service amendment map and hot news.   I will see what feedback I get as to whether this becomes permanent; if it's useful, I could update it so that clicking on a story would jump to it ... but that's a bit more work from where I started.


Title: Re: The like button - what it does and does not do
Post by: SandTEngineer on April 24, 2018, 16:37:49
Hi Grahame, I noticed that earlier and thought it a good idea.  Would be nice if you could click on the topic line and it takes you to your latest unread post in the topic (other forums do that; WNXX an example).  But please don't struggle with something that might be difficult to achieve.  I enjoy the forum as it is now, so any additions you can make are a bonus :D


Title: Re: The like button - what it does and does not do
Post by: grahame on April 24, 2018, 16:57:20
Hi Grahame, I noticed that earlier and thought it a good idea.  Would be nice if you could click on the topic line and it takes you to your latest unread post in the topic (other forums do that; WNXX an example).  But please don't struggle with something that might be difficult to achieve.  I enjoy the forum as it is now, so any additions you can make are a bonus :D

Linking direct to the thread (and to the liked article in it) should be possible - "your latest unread" would be a bit harder.



Title: Re: The like button - what it does and does not do
Post by: grahame on April 24, 2018, 21:58:43
Hi Grahame, I noticed that earlier and thought it a good idea.  Would be nice if you could click on the topic line and it takes you to your latest unread post in the topic (other forums do that; WNXX an example).  But please don't struggle with something that might be difficult to achieve.  I enjoy the forum as it is now, so any additions you can make are a bonus :D

Linking direct to the thread (and to the liked article in it) should be possible - "your latest unread" would be a bit harder.



OK ... let's see how that looks.   Installed / under test.    Members may like to note that "liking" a message will promote its thread.


Title: Re: The like button - what it does and does not do
Post by: SandTEngineer on April 25, 2018, 09:41:14
Hi Grahame.  Well done.  That works really well if you just want to dive in quickly and see whats currently the 'hot' topics!


Title: Re: The like button - what it does and does not do
Post by: JayMac on April 25, 2018, 10:10:07
Doesn't render brilliantly on my Android phone. Font is larger than other boxes either side. Leaves a lot of dead space.


Title: Re: The like button - what it does and does not do
Post by: Western Pathfinder on April 25, 2018, 10:10:41
Yes it does work well ,however might we go back to the format of earlier this morning?
Where the unread posts were displayed in more of a landscape format .


Title: Re: The like button - what it does and does not do
Post by: Adelante_CCT on April 25, 2018, 10:22:58
Agree with the last two posts, last night it looked ok, now appears to 'in your face'


Title: Re: The like button - what it does and does not do
Post by: SandTEngineer on April 25, 2018, 10:42:27
Very strange.  Looks OK on my SAMSUNG Tablet.


Title: Re: The like button - what it does and does not do
Post by: grahame on April 25, 2018, 10:44:20
OK ... I have been playing.   Smaller font size, slightly reduced box.  But always a messy compromise here with the variety of browsers and the limited number (and time) I have to try.   Also been playing with the number of rows to show.

The idea of the section is to highlight transport activity, rather than our activity here, so any likes in "News and Assisitance" don't appear in these headlines, though they do appear in the "recent likes" link at the page top - which I will be moving onto the "most recent liked" topics as a link once the current format issues are compromised as appropriate.  Likes on "Frequent Poster" and other such board threads are also not going to appear at the top of every page; it's a standard banner for whether people are logged on or not, and irrespective of member groups.



Title: Re: The like button - what it does and does not do
Post by: SandTEngineer on April 25, 2018, 10:47:24
As I said earlier, don't spend too much time on this.  More important things in life to do  :)


Title: Re: The like button - what it does and does not do
Post by: JayMac on April 25, 2018, 23:10:25
Text gone big again. Takes up half my mobile screen.


Title: Re: The like button - what it does and does not do
Post by: grahame on May 02, 2018, 03:59:15
Question asked ... "what do those number on the 'Most Recent Likes' mean"

It's a scoreboard system designed to make Eurovision scoring look fair and simple  ;D  ... Most recent 60 likes are extracted from database.  Most recent of all scores 56 points, second most recent 53, third 50, and so on - a 6% decay on each like.  By the time you've gone back 20 likes, you're adding just 17 to the score, and you're adding just 5 by the time you've gone back 40 likes.  The algorithm is coded at http://www.wellho.net/resources/ex.php?item=h308/liked.php .

Currently I see:

Quote
Most liked recent subjects
[158] More dangerous overcrowding to the Westcountry
[97] Purton Museum: New exhibition explores history of village rail...
[80] GWR mobile tickets
[72] 24 hour trains
[56] GWR Website problems
[46] Some say Somerset is behind the times...
there are 5 recent(ish) likes on a post in "More dangerous overcrowding to the Westcountry", four quite recent likes on Purton museum, a couple also on GWR mobile tickets, and so on.

I have tuned the algorithm so that a couple of likes will quickly bring subjects to the fore, but then they will fade off quite quickly; the idea is to be something that people can see what's trending rather than giving any sort of longer term view.

The "recent likes" button at the top of the page brings in a lot more subjects - the algorithm is the same, but the factors and number of likes analysed differ to give a more general trend and less volatile report.  Top of each page for headlines, if you click on the full report you get a much longer story from where you can go through each of the posts selected in a separate frame.  I may rename this button to clarify the difference ...


Title: Re: The like button - what it does and does not do
Post by: Phantom on May 02, 2018, 10:13:22
Text gone big again. Takes up half my mobile screen.

When I was typing a reply on another thread, the text went over the top of the reply button so was unable to "hit reply"
Had to delete some of what was written so the screen scrolled up again



This page is printed from the "Coffee Shop" forum at http://gwr.passenger.chat which is provided by a customer of Great Western Railway. Views expressed are those of the individual posters concerned. Visit www.gwr.com for the official Great Western Railway website. Please contact the administrators of this site if you feel that content provided contravenes our posting rules ( see http://railcustomer.info/1761 ). The forum is hosted by Well House Consultants - http://www.wellho.net