• (12 Pages)
  • +
  • « First
  • 9
  • 10
  • 11
  • 12

Simple Text Chat Box Learn how to use a simple idea to make text chat web application Rate Topic: ****- 3 Votes

#151 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Posted 08 June 2013 - 06:11 PM

Well, What I mean is a link (url) to your website where you upload the code so I can tested online

for your current setup, clicking sign in button must redirect you to a fake sign in page which should be replaced by yours or use included facebook loing page

anyway, I didn't find any problem running the code (you uploaded) on my localhost,
note: make sure to add write permission to the data folder or to be more specific to (alias, bannedusers, groupusers, kickedusers, onlineusers, room) files
Was This Post Helpful? 0
  • +
  • -

#152 steekster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-June 13

Posted 08 June 2013 - 06:58 PM

View Postahmad_511, on 08 June 2013 - 06:11 PM, said:

Well, What I mean is a link (url) to your website where you upload the code so I can tested online

for your current setup, clicking sign in button must redirect you to a fake sign in page which should be replaced by yours or use included facebook loing page

anyway, I didn't find any problem running the code (you uploaded) on my localhost,
note: make sure to add write permission to the data folder or to be more specific to (alias, bannedusers, groupusers, kickedusers, onlineusers, room) files


Oh sorry, here it is Website
Aditional: I'm on a mac
Was This Post Helpful? 0
  • +
  • -

#153 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Posted 08 June 2013 - 08:02 PM

Quote

Keep an eye on your server response, it may add something you don't expect


above advice is not just for you but for me too as I trusted the server response and since I'm getting the response I expected I didn't check

in your case the hosting company adds the following code which breaks JSON response
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->



a similar problem has been posted here before so I hope he can find this reply

the fix will be simply forcing the response content type and hoping your web host will not add the analytics code to it

1- open server.php file
2- at the bottom and just before the echo line add this
header("Content-Type: application/json");


even if that doesn't work, keep it and don't remove it, it's better like this

anyway, it's my fault I didn't check this before :) sorry

let me know if it works for you
Was This Post Helpful? 1
  • +
  • -

#154 steekster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-June 13

Posted 09 June 2013 - 02:44 AM

Sadly this didn't fix it, but thanks for all the speedy responses and taking your own time to help me fix them :)
Was This Post Helpful? 0
  • +
  • -

#155 steekster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-June 13

Posted 09 June 2013 - 03:08 AM

Sorry for double post, but its important. Looks like I'm getting 2 errors when I run it in my local network...

XMLHttpRequest cannot load file://localhost/Users/syatko/Desktop/ChatBox_6-2/server.php. Cross origin requests are only supported for HTTP. index.htm:1
Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 

Was This Post Helpful? 0
  • +
  • -

#156 steekster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-June 13

Posted 09 June 2013 - 03:28 AM

Gah, they really need to add an edit button... But looks like I'm missing all my emoticons when I run it locally... I think its something in the script
Was This Post Helpful? 0
  • +
  • -

#157 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Posted 09 June 2013 - 03:52 AM

Hello again,

Quote

Sadly this didn't fix it

just to make sure I want you to call the server.php from your browser and then view the document source and see whether or not the analytics code mentioned previously appears or not

Quote

Looks like I'm getting 2 errors when I run it in my local network

Quote

But looks like I'm missing all my emoticons when I run it locally... I think its something in the script

I guess you run the file directly from your hard drive and not from the browser
you have to run it something like this
http://localhost/My_web_app


Was This Post Helpful? 0
  • +
  • -

#158 steekster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-June 13

Posted 09 June 2013 - 03:56 AM

View Postahmad_511, on 09 June 2013 - 03:52 AM, said:

Hello again,

Quote

Sadly this didn't fix it

just to make sure I want you to call the server.php from your browser and then view the document source and see whether or not the analytics code mentioned previously appears or not

Quote

Looks like I'm getting 2 errors when I run it in my local network

Quote

But looks like I'm missing all my emoticons when I run it locally... I think its something in the script

I guess you run the file directly from your hard drive and not from the browser
you have to run it something like this
http://localhost/My_web_app



Yeah that code was still there, and it's giving me a 404 error
Was This Post Helpful? 0
  • +
  • -

#159 steekster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-June 13

Posted 09 June 2013 - 04:07 AM

This is the directory in my browser when I run it
file://localhost/Users/syatko/Desktop/ChatBox_6%202/index.htm
Looks like the .CSS is the only file that loads into it
Was This Post Helpful? 0
  • +
  • -

#160 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Posted 10 June 2013 - 04:54 PM

this is not the correct way to browse a website hosted locally, you have to use http protocol not the file protocol

to make sure you localhost is working
try to type localhost or 127.0.0.1 in your browser address bar, hit [Enter] key and see if the server will respond, the result depends on the web server you have installed/enabled on your system (could be "It Works" on Apache, Welcome page on IIS, ...)
Was This Post Helpful? 0
  • +
  • -

#161 jamesrayner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-June 13

Posted 17 June 2013 - 04:12 AM

please can you let me know how to sign out the chat user when their browser is closed?
Was This Post Helpful? 0
  • +
  • -

#162 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Posted 17 June 2013 - 05:23 AM

Hello jamesrayner,

theoretically, we may use the onunload, onbeforeunload events,
<body onload="initiateChatBox()" onbeforeunload="signout()">


but practically this is not applicable due to:
1- browser support
2- the browser will close before being able to make a complete sign-out request
3- this will be called on page refresh to and breaks the auto-signin feature and will sign-out the user if he refreshed the page

however, when user stopped posting for a while (defined in the config.php OFFLINE_TIME) it will be signed out automatically

Regards
Was This Post Helpful? 0
  • +
  • -

#163 jamesrayner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-June 13

Posted 17 June 2013 - 06:20 AM

many thanks! where would i enter this, please:

<body onload="initiateChatBox()" onbeforeunload="signout()">



im afraid i cant find a config.php file, where is this please?
Was This Post Helpful? 0
  • +
  • -

#164 jamesrayner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 17-June 13

Posted 17 June 2013 - 07:03 AM

i have found this, but i just need to know where to put that line of code you showed me:

<script language="Javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
  {
    return "You have attempted to leave this page.  If you have made any changes to the fields without clicking the Save button, your changes will be lost.  Are you sure you want to exit this page?";
  }
</script>



i guess it will go like this - but not sure which file it would go in?

<script language="Javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
  window.onbeforeunload = signout;
  function signout()
  {
    return "You have attempted to leave this page.  If you have made any changes to the fields without clicking the Save button, your changes will be lost.  Are you sure you want to exit this page?";
  }
</script>


Was This Post Helpful? 0
  • +
  • -

#165 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Posted 17 June 2013 - 01:21 PM

Quote

im afraid i cant find a config.php file, where is this please?

directly in the chat folder (the same folder where index.htm is placed)

you can add the script you post at the head section of the index.htm, BUT, as I mentioned previously this is not going to work as expected

the signout() function I mentioned is the one included in the ./js/client.js file and you don't have to rewrite it,

maybe using a synchronous call is what you need here, but be aware that using a synchronous call will block the browser until response received from the server

put this code in the head section
<script type="text/javascript">
window.onbeforeunload=function(){
	var a=new Ajax();
	with(a){
		Async=false;
		Method="POST";
		URL="server.php";
		ErrorHandler=ajax_error;
		ResponseFormat="json";
		ResponseHandler=function(res){}
		Data={"o":"signout"};
		Send();
	}
}
</script>



anyway, in best scenarios it will break the auto sign-in feature and will sign-out the member if member refreshed the page
Was This Post Helpful? 0
  • +
  • -

  • (12 Pages)
  • +
  • « First
  • 9
  • 10
  • 11
  • 12