Results 1 to 6 of 6

Thread: need help with a project

  1. #1
    Join Date
    Mar 2012

    Cool need help with a project

    hey guys hows it going... new to the forums here... i'm currently working on a lil code for "Random Quotes" ok well i have it working very nice but still not what's desired, i'll explain...

    its here as a demo: http://abkclan.com/test/rotate.html

    currently its getting the random quote list from rotate.js in a list like this...

    rotateQuotes.quotes = [
    "quote 1 here",
    "quote 2 here",
    "quote 3 here",
    "quote 4 here",
    "quote 5 here",
    "quote 6 here",
    well i could and have entered the data in like that... however i want to get the quote strings from a file 'http://anybodykillas.com/Quotes.txt'

    the data would look like this in the file:
    quote 1 here
    quote 2 here
    quote 3 here
    quote 4 here
    quote 5 here
    quote 6 here
    what i need is to gather this data from Quotes.txt and put it in the format used in rotate.js

  2. #2
    Join Date
    Mar 2012
    my guess is i'll have to get all the strings by doing a split at each new line (\n) then they will be array'd so they are separated, then some how do a string replace. i suppose the first string: quotes[0] to be like this:
    "rotateQuotes.quotes = [ " quotes[0] ","

    the middle would be like this:
    "" quotes[1] ","

    and the last like this:
    "" quotes[1] "]&#59;"

    idk why im here :P RAGE! can't figure it out...

    want it from the Quotes.txt because our bot saves quotes from our mIRC chat rooms to that file.

    couple of people say i just have to do my random quotes differently where it splits the string and randoms the array id number.

    others say i need jquery for what i wanna do but i wouldnt see y considering its just javascript anyways

  3. #3
    Join Date
    Feb 2012
    use PHP to get quotes from file.
    PHP Code:
    $quotes file('Quotes.txt'FILE_IGNORE_NEW_LINES FILE_SKIP_EMPTY_LINES); 
    and here is the javascript
    rotateQuotes.quotes = ["<?php echo implode('","', $quotes)?>"];

  4. #4
    Join Date
    May 2005
    Dirty Jersey
    PHP isn't necessary to do what you're asking. you can keep everything native an just use AJAX to request the contents of the text file. here's an example of doing just that:


    in your case, you wouldn't just be placing the entire contexts of the text file into your page using "innerHTML". you'd have to be a bit (a lot) more precise. so, what you'd do is take the responseText and place each quote within the responseText into an instance in some array. that could be done using the "split" function against the responseText string, splitting at any instance of
    so if your text file said:

    quote 1 here
    quote 2 here
    quote 3 here
    quote 4 here
    quote 5 here
    quote 6 here
    and you split it based on "\n", you'd get an array that looked like:

    [0] = "quote 1 here"
    [1] = "quote 2 here"
    [2] = "quote 3 here"
    then, using more javascript, you randomize the quote and insert it into the DOM. EASY!!!
    Last edited by Angry Black Man; 03-03-2012 at 12:37 PM.

    1. If you reply to my post, and your reply would then appear directly beneath my post, DON'T QUOTE MY ENTIRE POST!!! IT'S REDUNTANT!!! IT'S ASININE!!!! IT'S REDUNDANTLY ASININE!!!!! DON'T DO IT!!!!
    2. jQuery extends the functionality of JavaScript. If you don't know JavaScript, give up on that jQuery script and learn JavaScript. You'll save yourself a lot of frustration, I promise.
    3. Use the [code][/code] tags. Otherwise, you may be left wondering why no one responded to your eyesore of a thread.

  5. #5
    Join Date
    Mar 2012
    thx the PHP method will work great i do believe...
    at first was tring to avoid PHP scripts because there not allowed on the site being used... however i just made this on my own host and added it to the theme in the location desired with an iframe, my host allows php so i dont have to avoid using it anymore... lol didnt think about it, was stuck on making it work with js, and everything i tried failed :P

  6. #6
    Join Date
    Mar 2012
    ok yea the PHP method failed for some reason not sure why.... maybe i did it wrong idk...

    well think he desided just to update the file with the list, with the bot instead of making a Quotes.txt file... think ima try the AJAX method later. idk nothing in AJAX lol only what it is and what its made to do... do believe i need to learn

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11641 seconds
  • Memory Usage 2,898KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (6)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (6)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates