Jump to content

rockinaway

Members
  • Posts

    509
  • Joined

  • Last visited

    Never

Everything posted by rockinaway

  1. Well, I have basic hashchange functionality working where clicking different links will change the content of a page dynamically and will change the hash. HOWEVER, I want to be able to reload the content of the page when a link with the same hash is clicked. So, if I have a link producing the hash #idea. If this page is already loaded and I click the same link again (i.e. the hash doesn't change). Any ideas how i'd do this? I'm currently using this basic method: $("#link").click(function() { window.location.hash = "#i=link"; }); $(window).bind( 'hashchange', function(e) { // ajax request }) // Trigger the event $(window).trigger('hashchange');
  2. That doesn't work. It allows scrolling of the header when hovering over it.. but not even horizontal scrolling, kinda ruins it.
  3. I've created a header that I want to follow the user as they scroll down the page. For it I have used position:fixed. However, the issue is that, when the window is shrunk down, the header width is greater than the window but no horizontal scrollbar shows to allow scrolling. What do I need to do?
  4. Haha i have no idea how i missed that! Thanks
  5. How can I format my time value (initially created by using time()) to ISO 8601 so it can be used in the format described here: http://timeago.yarp.com/ Thanks
  6. Okay yeah, sounds good. I will use the user id instead. Thanks
  7. Okay, at the moment, when a user logs into my website a token is created. The token is made from a random code, their name and their email. This token is then stored next to their name in the DB. If the user chooses to be remembered, the token is stored as a cookie, otherwise it's stored as a session var. Every time a page is loaded, a comparison is made between the DB token and the session/cookie token to authenticate. HOWEVER, this does not work if the user decides to login from different locations/ip addresses. How would I go about allowing this? Could I created a table and then store the IP address and the token for that IP address?
  8. well it's difficult to post the code as there is code in a huge number of files. I have done some troubleshooting and have made some conclusions. I will talk about my problem as simply as possible. I have a main page, main.php. This file has a header.php included which has the javascript file, jquery_functions.js, included in the <head> tag. Then in main.php, I have a div called 'main_div'. This DIV is empty to begin with. When a link is clicked, it triggers a function in jquery_functions.js which causes main_div to be filled with content. This new content, produced from an AJAX response to another file, now contains some JS functions which are stored in jquery_functions.js. However, when clicking these new functions, NOTHING happens. I get that the function is undefined although it is clearly defined in my .js file. My jquery file is below, a lot of irrelevant information really, the last bit is where the major AJAX changes occur (the changing hash section). $(document).ready(function () { // Set a few vars var webroot = 'http://www.etcworld.co.uk/sn/'; var dir = '/sn/'; /////////////////////////////////////////////// /// Hover and change the images in the header $(".msg").hover( function(){this.src = this.src.replace(""+webroot+"theme/img/header_message_img.png",""+webroot+"theme/img/header_message_img_h.png");}, function(){this.src = this.src.replace(""+webroot+"theme/img/header_message_img_h.png",""+webroot+"theme/img/header_message_img.png"); }); $(".stream").hover( function(){this.src = this.src.replace(""+webroot+"theme/img/header_stream_img.png",""+webroot+"theme/img/header_stream_img_h.png");}, function(){this.src = this.src.replace(""+webroot+"theme/img/header_stream_img_h.png",""+webroot+"theme/img/header_stream_img.png"); }); /// /////////////////////////////////////////////// /////////////////////////////////////////////// /// Mini thought updates - clicking functions $('#cancel_mini_thought').click(function() { $('#thought_form_div').hide(); $('#mini_thought_div').show(); return false; }); $('#thought').click(function(e) { // e.stopPropagation(); $('#mini_thought_div').hide(); $('#thought_form_div').show(); // Focus onto the text field $('#mini_thought').focus(); }); // When we click anywhere else $(document).click(function(){ $('#thought_form_div').hide(); $('#mini_thought_div').show(); }); /// /////////////////////////////////////////////// /////////////////////////////////////////////// /// Mini thought is submitted $('#thought_form_div').keydown(function(event) { if(event.keyCode == 13) { // Stop the normal submit event.preventDefault(); // The thought submitted var mini_thought = encodeURIComponent($('#mini_thought').val()); // Send the request $.ajax({ url: 'post.php', data: 'mini_thought='+mini_thought, type: 'post', success: function (thought) { // Show the new thought $('#mini_thought_div').html(thought); // Show and hide $('#mini_thought_div').show(); $('#thought_form_div').hide(); } }); // Don't submit return false; } }); /// ////////////////////////////////////////////// ////////////////////////////////////////////// /// Mini buttons at the top $("#thought_update_button").click(function() { $("#header_mini_buttons #photo_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #photo_update_button").addClass("mini_button"); $("#header_mini_buttons #video_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #video_update_button").addClass("mini_button"); $("#header_mini_buttons #post_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #post_update_button").addClass("mini_button"); $("#thought_update_button").removeClass("mini_button"); $("#thought_update_button").addClass("mini_button_clicked"); $("#update_boxes .update_box").css("display","none"); $("#update_boxes #thought_update").css("display","block"); return false; }); $("#photo_update_button").click(function() { $("#header_mini_buttons #thought_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #thought_update_button").addClass("mini_button"); $("#header_mini_buttons #video_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #video_update_button").addClass("mini_button"); $("#header_mini_buttons #post_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #post_update_button").addClass("mini_button"); $("#photo_update_button").removeClass("mini_button"); $("#photo_update_button").addClass("mini_button_clicked"); $("#update_boxes .update_box").css("display","none"); $("#update_boxes #photo_update").css("display","block"); return false; }); $("#video_update_button").click(function() { $("#header_mini_buttons #photo_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #photo_update_button").addClass("mini_button"); $("#header_mini_buttons #thought_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #thought_update_button").addClass("mini_button"); $("#header_mini_buttons #post_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #post_update_button").addClass("mini_button"); $("#video_update_button").removeClass("mini_button"); $("#video_update_button").addClass("mini_button_clicked"); $("#update_boxes .update_box").css("display","none"); $("#update_boxes #video_update").css("display","block"); return false; }); $("#post_update_button").click(function() { $("#header_mini_buttons #photo_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #photo_update_button").addClass("mini_button"); $("#header_mini_buttons #video_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #video_update_button").addClass("mini_button"); $("#header_mini_buttons #thought_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #thought_update_button").addClass("mini_button"); $("#post_update_button").removeClass("mini_button"); $("#post_update_button").addClass("mini_button_clicked"); $("#update_boxes .update_box").css("display","none"); $("#update_boxes #post_update").css("display","block"); /*if ($("#post_update").is(":visible")) { $('#post_update').hide(); } else { $('#post_update').show(); $('#thought_update').hide(); $('#photo_update').hide(); $('#video_update').hide(); }*/ return false; }); $("#thought_update").click(function(event) { event.stopPropagation(); }); $("#photo_update").click(function(event) { event.stopPropagation(); }); $("#post_update").click(function(event) { event.stopPropagation(); }); $("#video_update").click(function(event) { event.stopPropagation(); }); $(document).click(function(){ $("#update_boxes .update_box").css("display","none"); $("#header_mini_buttons #photo_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #photo_update_button").addClass("mini_button"); $("#header_mini_buttons #video_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #video_update_button").addClass("mini_button"); $("#header_mini_buttons #thought_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #thought_update_button").addClass("mini_button"); $("#header_mini_buttons #post_update_button").removeClass("mini_button_clicked"); $("#header_mini_buttons #post_update_button").addClass("mini_button"); }); /// ////////////////////////////////////////////// $.extend({ getUrlVars: function(){ var vars = [], hash; var hashes = window.location.search.slice(window.location.search.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; }, geturlvar: function(name){ return $.getUrlVars()[name]; }, getUrlHashes: function(){ var vars = [], hash; var hashes = window.location.hash.slice(window.location.hash.indexOf('#') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; }, geturlhash: function(name){ return $.getUrlHashes()[name]; } }); var get = $.geturlvar; var hash = $.geturlhash; ////////////////////////////////////////////// /// Changing and hashing the profile tabs // Roll tab has been clicked $("#profile_link_stream").click(function() { window.location.hash = "#s=stream"; // Need to force the check as the hash doesn't change on reclick $(window).trigger('hashchange'); }); // Photos tab has been clicked $("#profile_link_photos").click(function() { window.location.hash = "#s=photos"; // Need to force the check as the hash doesn't change on reclick $(window).trigger('hashchange'); }); // Videos tab has been clicked $("#profile_link_videos").click(function() { window.location.hash = "#s=videos"; // Need to force the check as the hash doesn't change on reclick //$(window).trigger('hashchange'); //$.bbq.pushState('hello=test'); }); // Check we are on the profile page if (window.location.pathname == dir+"view_profile.php") { $(window).bind( 'hashchange', function(e) { // Get the url hash //var url = $.param.fragment(); // Get the user id var pid = get('pid'); var s = hash('s'); // Show pending image $('#profile_main').html('<img src="theme/img/loader.gif" height="16" width="16" />'); // Photos huh? if (s == "photos") { // Send the request $.ajax({ url: 'view_profile_photos.php', type: 'post', success: function (msg) { $("#profile_main").html(msg); } }); } // Oh videos else if (s == "videos") { // Send the request $.ajax({ url: 'view_profile_videos.php', type: 'post', success: function (msg) { $("#profile_main").html(msg); } }); } // Stream it is.. else if (s == "stream" || s == '') { // Send the request $.ajax({ url: 'view_profile_stream.php', type: 'post', data: 'pid='+pid, success: function (msg) { $("#profile_main").html(msg); } }); } }) // Trigger the event $(window).trigger('hashchange'); } /// //////////////////////////////////////////////////////// //////////////////////////////////////////////////////// /// Submit a new thought $("#thought_post_submit").click(function() { // Disable the button to stop more submissions $('#thought_post_submit').attr("disabled", true); // The thought submitted var thought = encodeURIComponent($('#thought_post').val()); // Send the request $.ajax({ url: 'post.php', data: 'thought='+thought, type: 'post', success: function (msg) { // Do this is we are on the profile page!!! // // // //$("#profile_main").prepend(msg); // // // /////////// // Enable the button $('#thought_post_submit').attr("disabled", false); // Clear the value of thought post $('#thought_post').val(''); // Show pending image $('#mini_thought_div').html('<img src="theme/img/loader.gif" height="16" width="16" />'); // Update mini thought $("#mini_thought_div").html(msg); // Show pending image $('#thought_success').html('<img src="theme/img/loader.gif" height="16" width="16" />'); // Show the success message $('#thought_success').fadeIn("slow").html('Success').fadeOut(1500); } }); // Prevent the normal action return false; }); /// ////////////////////////////////////////////////////// });
  9. I have a main page, home.php. This file then has content dynamically loaded using AJAX based on which link is clicked. So one link loads content from info.php. I have included my Javascript file (i'm using jQuery) in home.php. However, when I use some form of Javascript e.g. "<a onclick="contact()">Contact</a>", in info.php, it doesn't work. It says that the function in undefined even though it is clearly stated in the main Javascript file included in home.php What do I need to do? Include it individually again? :s
  10. Done it, thanks!. I used the following: var url = window.location.search.slice(window.location.search.indexOf('?') + 1).split('&');
  11. Yes I am using the current window URL. However, how do I exclude the stuff after # in the URL using window.location.search? (i'm reading up on it now but posting in case!)
  12. Well how is the URL dynamically changing as well with each 'ajax' call, I thought this wasn't possible..
  13. Well, for those of you who use facebook, if you move pages from messages, to feed, to events or anything like that, you will notice the entire page doesn't load. At first, I though there must be some Ajax involved but then I realised that the page url is changing with new GET variables. So what is going on? What are they doing?
  14. I am trying to slice a string but between two set points. I have a string with the value '&hello=now#". I basically want to snip out the information between & and # so i can manipulate it. I can't just use substr as I have a varying length of the string. Any help as to how to do this?
  15. Is it possible to use PHP variables in a jQuery file that is including in the header of the file? If so, how?
  16. Kind of, I'll try explaining it better. I have a main page, then in a sidebar, I have a section that is echo'ed out from another PHP page that I have included through a require statement. Now, when the user submits a form, I want to effectively reload that sidebar (and therefore the PHP file associated with it) through AJAX. But my variables don't work anymore, do I have to pass each one through like you've shown?
  17. I have a file, test.php. It has a require statement to include line.php. Now on normal load, I can access the variables set in test.php in line.php. However, I also have an automated reload of line.php using AJAX, where I send a request to access the file and it outputs the same information. HOWEVER, in this case, the variables set in test.php can no longer be access :s .. why is that? I haven't set any data to be passed in the request, but I assume this doesn't have to be done.
  18. Can Java easily be integrated with PHP or is something like a recorder made through Flash/Action Script the better option?
  19. Is there any way to link these together? For example if I create a video player in Flash, can I use it in PHP etc?
  20. I know this can't be accomplished with JUST PHP, however a few questions. I want to create code that will allow users to record an audio message and then this will be saved as a file and linked into my database (hence the PHP/MySQL requirement). How would I go about this? Is it possible? Which languages would I need?
  21. I have created tabs (not using the jQuery tab feature) and each tab loads different content. I am stuck as to how to use the location.hash feature in order to load different content based on which tab is linked. As I have multiple pages, I first need to check with page is accessed, then the GET parameters and then the hash. Any help with what to do?
  22. Oh it seems like adding type="text/javascript" to the script statement suddenly makes it work :s
  23. I am following the tutorial here: http://www.scriptbreaker.com/javascript/script/JQuery-vertical-tab-menu However, when I include the jQuery function into an external file and include that, it doesn't work, but when it's in the head of the file it works perfectly. What could be wrong?
  24. Right, I have a 2 part question. At the moment, each user has an image stored for them which is linked to via a field in the database. Now I'm showing the image by a simple <img /> tag and just including the result of the filename from a database query, which works perfectly fine but I want to take this a step or two further. 1) Firstly, is it possible to get variables of width, height etc for images that are stored on the server as a file? Much like this information can be accessed when a user uploads an image, is it possible to do it if I'm showing the image once it's uploaded and stored? 2) If I can get dimensions for the image, is it possible to SCALE it properly down to a suitable size? For example, the maximum image can be 50 x 50, but images that are smaller would be scaled up PROPORTIONALLY or if they were bigger they would be scaled down PROPORTIONALLY. For example, if an image is 100 x 200, I don't want it scaled down to 50 x 50, I want it so that it remains to scale and is scaled down to 25 x 50.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.