Train GraphicClick on the map to explore geographics
 
I need help
FAQ
Emergency
About .
Travel & transport from BBC stories as at 20:15 28 Mar 2024
* Easter getaways hit by travel disruption
- Where Baltimore bridge investigation goes now
- How do I renew my UK passport and what is the 10-year rule?
- Passengers pleaded with knifeman during attack
- Family anger at sentence on fatal crash driver, 19
- Easter travel warning as millions set to hit roads
Read about the forum [here].
Register [here] - it's free.
What do I gain from registering? [here]
 02/06/24 - Summer Timetable starts
17/08/24 - Bus to Imber
27/09/25 - 200 years of passenger trains

On this day
28th Mar (1992)
MOD Kineton tour, branch line society (*)

Train RunningCancelled
18:30 Cardiff Central to Portsmouth Harbour
18:36 London Paddington to Plymouth
19:23 Reading to Gatwick Airport
19:33 London Paddington to Worcester Shrub Hill
19:35 Exeter St Davids to London Paddington
19:59 Gatwick Airport to Reading
20:13 Swindon to Westbury
20:16 Frome to Westbury
20:20 Reading to Shalford
20:49 Newbury to Bedwyn
20:54 Reading to Gatwick Airport
20:56 Worcester Foregate Street to London Paddington
21:16 Bedwyn to Newbury
21:16 Westbury to Swindon
21:30 Shalford to Reading
21:53 Newbury to Bedwyn
22:25 Bedwyn to Newbury
22:30 Gatwick Airport to Reading
22:30 Swindon to Westbury
22:47 Newbury to Bedwyn
Short Run
16:03 London Paddington to Penzance
16:19 Carmarthen to London Paddington
16:35 London Paddington to Plymouth
16:50 Plymouth to London Paddington
17:03 London Paddington to Penzance
17:30 London Paddington to Taunton
17:36 London Paddington to Plymouth
18:03 London Paddington to Penzance
18:54 Reading to Gatwick Airport
18:59 Gatwick Airport to Reading
19:04 Paignton to London Paddington
19:13 Salisbury to Bristol Temple Meads
19:29 Gatwick Airport to Reading
20:03 London Paddington to Plymouth
20:11 Salisbury to Bristol Temple Meads
20:42 Bedwyn to London Paddington
21:04 London Paddington to Plymouth
Delayed
16:15 Penzance to London Paddington
Additional 17:17 Exeter St Davids to Penzance
Additional 17:26 Castle Cary to Penzance
19:04 London Paddington to Plymouth
An additional train service has been planned to operate as shown 19:40 Redhill to Reading
19:54 Reading to Gatwick Airport
23:04 Reading to Bedwyn
PollsOpen and recent polls
Closed 2024-03-25 Easter Escape - to where?
Abbreviation pageAcronymns and abbreviations
Stn ComparatorStation Comparator
Rail newsNews Now - live rail news feed
Site Style 1 2 3 4
Next departures • Bristol Temple MeadsBath SpaChippenhamSwindonDidcot ParkwayReadingLondon PaddingtonMelksham
Exeter St DavidsTauntonWestburyTrowbridgeBristol ParkwayCardiff CentralOxfordCheltenham SpaBirmingham New Street
March 28, 2024, 20:26:59 *
Welcome, Guest. Please login or register.

Login with username, password and session length
Forgotten your username or password? - get a reminder
Most recently liked subjects
[118] West Wiltshire Bus Changes April 2024
[116] would you like your own LIVE train station departure board?
[89] Infrastructure problems in Thames Valley causing disruption el...
[46] Return of the BRUTE?
[38] If not HS2 to Manchester, how will traffic be carried?
[28] Reversing Beeching - bring heritage and freight lines into the...
 
News: the Great Western Coffee Shop ... keeping you up to date with travel around the South West
 
   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 35148 times)
thetrout
Hero Member
*****
Posts: 2612



View Profile
« Reply #15 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 Wink )
Logged

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



View Profile WWW Email
« Reply #16 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
Logged

Coffee Shop Admin, Acting Chair of Melksham Rail User Group, Option 24/7 Melksham Rep
grahame
Administrator
Hero Member
*****
Posts: 40690



View Profile WWW Email
« Reply #17 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
Logged

Coffee Shop Admin, Acting Chair of Melksham Rail User Group, Option 24/7 Melksham Rep
Cynthia
Sr. Member
****
Posts: 298


View Profile Email
« Reply #18 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!
Logged

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



View Profile WWW Email
« Reply #19 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 (Hypertext Markup Language) / CSS (Cascading Style Sheets) / Javascript expert around who has a bit of time to help ...  Wink Cheesy Grin - it would be greatly appreciated.
Logged

Coffee Shop Admin, Acting Chair of Melksham Rail User Group, Option 24/7 Melksham Rep
Timmer
Global Moderator
Hero Member
*****
Posts: 6293


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

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



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

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: 2260


View Profile WWW
« Reply #22 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.
Logged
grahame
Administrator
Hero Member
*****
Posts: 40690



View Profile WWW Email
« Reply #23 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  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, Acting Chair of Melksham Rail User Group, Option 24/7 Melksham Rep
Brucey
Global Moderator
Hero Member
*****
Posts: 2260


View Profile WWW
« Reply #24 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.
Logged
Chris from Nailsea
Administrator
Hero Member
*****
Posts: 17865


I am not railway staff


View Profile Email
« Reply #25 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.  Roll Eyes Shocked Grin
Logged

William Huskisson MP (Member of Parliament) 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: 2260


View Profile WWW
« Reply #26 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.
Logged
grahame
Administrator
Hero Member
*****
Posts: 40690



View Profile WWW Email
« Reply #27 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!
Logged

Coffee Shop Admin, Acting Chair of Melksham Rail User Group, Option 24/7 Melksham Rep
grahame
Administrator
Hero Member
*****
Posts: 40690



View Profile WWW Email
« Reply #28 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!
Logged

Coffee Shop Admin, Acting Chair of Melksham Rail User Group, Option 24/7 Melksham Rep
JayMac
Data Manager
Hero Member
******
Posts: 18894



View Profile
« Reply #29 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.
Logged

"Build a man a fire and he'll be warm for the rest of the day. Set a man on fire and he'll be warm for the rest of his life."

- Sir Terry Pratchett.
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 customers 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 to report). Forum hosted by Well House Consultants

Jump to top of pageJump to Forum Home Page