How to convert existing PHP POKER's js/poker to views/js ?

Sorry, should have posted this here and not originally as a page...

 

I am using http://subversion.assembla.com/svn/x3msvn/poker/ , well a branch of it in Elgg 1.8.6

 

The poker.php runs until the end of the file, but since there is no javascript, poker_push or push_Chat, ect. it loads the 1st bit of data from the DB and then nothing happens. If the push_talk() function is inside of < script javascript> section, then it works, as it does the " document.talk.talk.value = ""; and blanks out the chat input onClick of the button that calls Push_talk(). But it doesnt post to /includes/push_chat.php?msg='+ / I dont know how to handle that in the start.php so that path in mode/poker/vendors/include works for this call ( the full push_talk() is below? 

need to convert the js folder files into the views js/poker setup.. 

I have elgg euthentication, bypassing login and lobby, and joining a static room, and buying in and buying a seat ( for now I just have it using seat 1 ), dont join in elgg more then once.

 

my start.php has..

$actionspath = $CONFIG->pluginspath . "poker/actions/poker";
elgg_register_action("poker/push_chat", "$actionspath/push_chat.php");
elgg_register_action("poker/poker", "$actionspath/poker.php");
elgg_register_action("poker/sitout", "$actionspath/sitout.php");


$libpath = elgg_get_plugins_path() . 'poker/lib/poker.php';
elgg_register_library('poker', $libpath);


$poker_js = elgg_get_simplecache_url('js', 'poker/poker');
elgg_register_simplecache_view('js/poker/poker');
elgg_register_js('elgg.poker', $poker_js);
elgg_load_js('elgg.poker');

..to start with.

and main page handler only..

function poker_page_handler($page) {
$base = elgg_get_plugins_path() . 'poker/pages/poker/';

 

I dont know what page handler need to make mod/poker/vendors/pokerincludes/push_chat.php?msg= accept the  msg variable?

http://www.noahswitzer.com/poker  ( is gatekeepered, will need a account on the root page - Facebook login is fine )

join a 2nd account at http://noahswitzer.com/noahpoker (non elgg )interacts and runs fine. ( uses same db and you will see the elgg user logged in. )

I don't follow ajax, or veiws/js/default/poker/ so the javascript to fresh chat and start card dealing doesnt work, so the user at the table will timeout, and continually join the tabe if thier page is left open, this locks up the real game until they leave the table after thier 1st disconnect..

 

How would I convert the javascript action that I have in mod/poker/vendors/poker/js/poker.php

(Full js/poker.php http://subversion.assembla.com/svn/x3msvn/poker/js/poker.php will be putting each of these functions into the veiws/js or will they be actions/poker/? )

Can I just put them as functions in the vendors/poker.php that should be the main (table )page the player stays on after anuthentication? 

 

function push_talk(){

 var msg = document.talk.talk.value; var url = document.location.href;

thisurl ='/poker/vendors/poker/includes/push_chat.php?msg='+ msg;

checkloadfile(thisurl, "js"); document.talk.talk.value = ""; }

 

 

into  veiws/default/js/poker/poker.php as:

 

<?php

elgg.poker.run = function() {

var msg = document.talk.talk.value; var url = document.location.href;

thisurl ='/poker/vendors/poker/includes/push_chat.php?msg='+ msg;

checkloadfile(thisurl, "js"); document.talk.talk.value = ""; }


};

 or?


elgg.poker.chat = function() {
var url = elgg.normalize_url("/mod/poker/vendors/poker/includes/push_chat.php?msg=");
var messages = elgg.getJSON(
url,

{
success: function(+ msg) {
if (data.messages) {
// Append messages to chat
}});}

elgg.register_hook_handler('ready', 'system', elgg.poker.ready);

Do I require ajax if the orignal js didnt? Can I simplify it by keeping a java function? and just pasting the code from the function into the veiws/default/js/poker/poker.php as thier own function?

 

if so, I dont follow how I would convert all the functions.. If someone ( Rich? ) can convert the above javascript push_talk() function to what it needs to be inside of views/.../poker.js to work properly? I can do the rest if I have a understandable example from anyone who's smart? 

=)

 Can Anyone fill in the blanks and get me started by answering any of the questions that might make sense to you?

Thanks,

John

  • John, the poker script your using seems really messy. Since your problem is quite complex and not directly related to Elgg, I think you may have problem with getting detailed answer - someone would have to experiment with the code to give it to you, and this would take time.

     

    As a sidenote - I would be interrested in seeing final result of your work :) We will be probably building poker website based on Elgg in a not so far future.