Train Graphic
Great Western Passengers' Forum Great Western Coffee Shop - [home] and [about]
Read about the forum [here].
Register and contribute [here] - it's free.
 today - PEW, Wolmar, to edge of world
15/11/2018 - WWRUG - Westbury
16/11/2018 - TWSW AGM
17/11/2018 - GWRA Auction, Pershore
21/11/2018 - First Bath Bus panel
21/11/2018 - Consultation end - Angel Road
Random Image
Train Running @GWR Twitter Acronyms/Abbreviations Station Comparator Rail News GWR co. site Site Style 1 2 3 4 Chat on off
November 13, 2018, 08:39:29 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
Forgotten your username or password? - get a reminder
Most liked recent subjects
[106] How much will it cost? Expanding the network.
[76] 43185 in 1988 Swallow livery
[69] Four track for Filton Bank - ongoing discussion
[46] IETs into passenger service from 16 Oct 2017 and subsequent pe...
[46] MetroBus
[25] Cotswold Line - 2018 cancellation and amendments log
News: A forum for passengers ... with input from rail professionals welcomed too
 
   Home   Help Search Calendar Login Register  
Pages: 1 [2] 3 4
  Print  
Author Topic: The like button - what it does and does not do  (Read 25593 times)
thetrout
Hero Member
*****
Posts: 2612



View Profile
« Reply #15 on: August 05, 2014, 10:43:13 am »

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 Wink )
Logged

Grin Grin Grin Grin
grahame
Administrator
Hero Member
*****
Posts: 22445



View Profile WWW Email
« Reply #16 on: January 19, 2015, 08:51:14 am »

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
Logged

Coffee Shop Admin, Member of Melksham Rail User Group, on the board of TravelWatch SouthWest and some more things besides
grahame
Administrator
Hero Member
*****
Posts: 22445



View Profile WWW Email
« Reply #17 on: April 01, 2015, 06:25:14 am »

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
Logged

Coffee Shop Admin, Member of Melksham Rail User Group, on the board of TravelWatch SouthWest and some more things besides
Cynthia
Sr. Member
****
Posts: 298


View Profile Email
« Reply #18 on: April 01, 2015, 07:33:20 am »

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!
Logged

Trying to break ones addiction to car travel is much harder than giving up ciggies!
grahame
Administrator
Hero Member
*****
Posts: 22445



View Profile WWW Email
« Reply #19 on: April 01, 2015, 07:45:26 am »

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 ...  Wink Cheesy Grin - it would be greatly appreciated.
Logged

Coffee Shop Admin, Member of Melksham Rail User Group, on the board of TravelWatch SouthWest and some more things besides
Timmer
Global Moderator
Hero Member
*****
Posts: 4841


View Profile
« Reply #20 on: April 01, 2015, 05:15:00 pm »

I really like the 'Like' button, very useful.
Logged
thetrout
Hero Member
*****
Posts: 2612



View Profile
« Reply #21 on: April 01, 2015, 05:32:44 pm »

Pressing the like button on Google Chrome does indeed do something strange:







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 Smiley
Logged

Grin Grin Grin Grin
Brucey
Global Moderator
Hero Member
*****
Posts: 2259


View Profile WWW
« Reply #22 on: April 01, 2015, 08:09:18 pm »

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.
Logged
grahame
Administrator
Hero Member
*****
Posts: 22445



View Profile WWW Email
« Reply #23 on: April 02, 2015, 06:42:53 am »

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  Undecided

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.
Logged

Coffee Shop Admin, Member of Melksham Rail User Group, on the board of TravelWatch SouthWest and some more things besides
Brucey
Global Moderator
Hero Member
*****
Posts: 2259


View Profile WWW
« Reply #24 on: April 02, 2015, 08:28:41 pm »

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.
Logged
Chris from Nailsea
Administrator
Hero Member
*****
Posts: 17461


I am not railway staff


View Profile Email
« Reply #25 on: April 02, 2015, 10:54:37 pm »

What really needs to change is the redirect should trigger an asynchronous request to the PHP script ...

Easy for you to say.  Roll Eyes Shocked Grin
Logged

William Huskisson MP was the first person to be killed by a train while crossing the tracks, in 1830.  Many more have died in the same way since then.  Don't take a chance: stop, look, listen.

"Level crossings are safe, unless they are used in an unsafe manner."  Discuss.
Brucey
Global Moderator
Hero Member
*****
Posts: 2259


View Profile WWW
« Reply #26 on: April 04, 2015, 10:39:49 am »

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.
Logged
grahame
Administrator
Hero Member
*****
Posts: 22445



View Profile WWW Email
« Reply #27 on: April 05, 2015, 02:48:57 pm »

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!
Logged

Coffee Shop Admin, Member of Melksham Rail User Group, on the board of TravelWatch SouthWest and some more things besides
grahame
Administrator
Hero Member
*****
Posts: 22445



View Profile WWW Email
« Reply #28 on: April 05, 2015, 05:54:25 pm »

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!
Logged

Coffee Shop Admin, Member of Melksham Rail User Group, on the board of TravelWatch SouthWest and some more things besides
bignosemac
Transport Scholar
Hero Member
******
Posts: 16207


Question everything.


View Profile
« Reply #29 on: April 05, 2015, 06:53:46 pm »

Works for me. I'm no longer getting another tab open in Chrome when I 'like' a post.
Logged

Former FGW/GWR regular passenger. No more. Despicable company.
Do you have something you would like to add to this thread, or would you like to raise a new question at the Coffee Shop? Please [register] (it is free) if you have not done so before, or login (at the top of this page) if you already have an account - we would love to read what you have to say!

You can find out more about how this forum works [here] - that will link you to a copy of the forum agreement that you can read before you join, and tell you very much more about how we operate. We are an independent forum, provided and run by customers of Great Western Railway, for customers of Great Western Railway and we welcome railway professionals as members too, in either a personal or official capacity. Views expressed in posts are not necessarily the views of the operators of the forum.

As well as posting messages onto existing threads, and starting new subjects, members can communicate with each other through personal messages if they wish. And once members have made a certain number of posts, they will automatically be admitted to the "frequent posters club", where subjects not-for-public-domain are discussed; anything from the occasional rant to meetups we may be having ...

 
Pages: 1 [2] 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
This forum is provided by a customer of Great Western Railway (formerly First Great Western), and the 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 the content provided by one of our posters contravenes our posting rules (email link). Forum hosted by Well House Consultants