Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

Basket to Post script

  • 19-06-2011 9:31pm
    #1
    Registered Users Posts: 1,414 ✭✭✭


    New version as of 28/3/12 - Sol

    Hey,

    I know there is a few of you more knowledgeable people here that regularly go to sites like HWVS and scan and build a computer for someone by putting the items into your basket and then at the end take a screen shot of it or spend your valuable time converting that basket into a nice bb-coded post for the user that made the request.

    So I thought maybe I could make it a little easier for you :) I don't know has someone done this before, or if you all, already have your own tools for this kind of thing, but I'm gonna post it in the off chance it might help someone.
    I wrote a JavaScript that takes all the items from your basket and puts them into bb-codes so you can just copy and paste the text into your post in these forums. It should hopefully save people time when building a machine for a user.

    Here is the script.
    [PHP]JavaScript:var debug = false;function loadScript( url ){if ( document.getElementById("basket_parser") == null ){var script = document.createElement( "script" );script.setAttribute( "id", "basket_parser" );script.setAttribute( "type", "text/javascript" );script.setAttribute( "src", url + "?" + Math.random() * 10000000 );document.getElementsByTagName( "head" )[0].appendChild( script );setTimeout( "loadScript('" + url + "')", 200 );log( "Started loading script: " + url );}else if ( typeof( init_script ) != 'undefined' ){log( "Loaded." );init_script();}else{setTimeout( "loadScript('" + url + "')", 200 );log( "loading ..." );}}function log (string){if ( debug ){document.body.appendChild( document.createTextNode( string ) );document.body.appendChild( document.createElement( "br" ) );}}loadScript( "http://fluffy88.com/scripts/basket_parser.js" );void( 0 );[/PHP]
    I hope this will come in helpful to all the users of this forum, masters and noobs alike.
    At the moment it only works with
    http://hardwareversand.de/
    http://www.scan.co.uk/
    http://www.dabs.ie/
    http://www.memoryc.com/
    http://www.newegg.com/
    http://www.amazon.co.uk
    http://www.overclockers.co.uk
    but if people find it useful I will extend it for use with any other website that is requested.
    Sites I plan to add to the above list (at some stage),
    http://www.komplett.ie/

    And any ideas on how to make the script better are appreciated.

    To use this script you will have to create a bookmark for the script,
    This varys from browser to browser, so I am just going to cover firefox 10.x now, if needed I can do others by request.
    1. Create a new bookmark
      1. I recommend using the bookmark bar
      2. Right click on the bookmark bar
      3. Select "New Bookmark..."
      4. In the popup window paste the script into the "Location:" section.
      5. Give the bookmark any relevant name perhaps, "Basket parser"
      6. Click "Add"
    2. When you have the script as a bookmark
    3. Visit the site you want to use the script on
    4. Then click the bookmark to run it.

    Sorry I am very poor at explaining things, but if people want to use this and need help just ask, I will do guides with screen shots if it would be simpler to follow.



    Now for the complicated bits
    From here on I am going to try and explain the more advanced/complicated features of this script. For most uses the script posted above will work perfectly and you will have no need to read the below section to use the script. If you however want to change the formatting of the script to suit your own personal style or to adhere to some other format for use on another forum/site then read on.

    Script with editable formatting options.
    [php]JavaScript:var before = 'Item|Price';var format = '{itm_quantity}{itm_name}|{itm_price}';var after = 'Shipping|{shipping}\nTotal|{total}';function loadScript(url) {if (document.getElementById("basket_parser") == null) {var script = document.createElement("script");script.setAttribute("id", "basket_parser");script.setAttribute("type", "text/javascript");script.setAttribute("src", url + "?" + Math.pow(new Date().getMonth(), 2) + Math.pow(new Date().getDate(), 3));document.getElementsByTagName("head")[0].appendChild(script);setTimeout("loadScript('" + url + "')", 200);} else if (typeof(init_script) != 'undefined') {init_script();} else {setTimeout("loadScript('" + url + "')", 200);}}loadScript("http://fluffy88.com/scripts/basket_parser.js");void(0);[/php]
    In this script you will see three variables at the beginning(just after "JavaScript:") called before, format and after this is what you use to edit the format of the output. It uses 'tags' that get swapped with the information(price, name ...) of the items in your basket.

    First I will explain the main format variable.
    Atm there is 4 tags,
    1. {itm_url} - This will get replaced by the full url of the item. Example: http://www.scan.co.uk/products/corsair-600t-graphite-series-black-mid-tower-gaming-case-w-o-psu
    2. {itm_name} - This will get replaced by the full name of the item that is displayed in the basket. Example: Intel Core i5-2500K Box, LGA1155
    3. {itm_price} - This will get replaced by the price of the item that is displayed in the basket. Example: €44.09, £172.94
    4. {itm_quantity} - This will get replaced by the quantity of the item that is displayed in the basket if it is greater than 1. Example: 2 x , 5 x. It might be helpful to note, {itm_quantity} gets replaced with a trailing space, "2 x "
    To change how the output is formatted all we have to do is change this variable and place the 'tags' in between what ever text is needed for your post.
    Some example formats are
    [PHP]var format = '{itm_quantity}{itm_name} {itm_price}';[/PHP]
    A HTML version of this would be
    [PHP]var format = '{itm_quantity}<a href="{itm_url}">{itm_name}</a> {itm_price}';[/PHP]
    A tabled version
    [PHP]var format = '{itm_quantity}|{itm_name}|{itm_price}';[/PHP]

    Tags can be placed anywhere in the string.
    You can have as much text around the tags as needed and it will remain untouched.
    Be careful not to remove the single quotes around the format variable as the script will not work without these
    If you want to use a single quote in the format you must backslash it. For example var format='Fluffy\'s basket {itm_price}';
    If you wish to put a line break in the format place a backslash n '\n' in the variable and it will be replaced by a line break.


    Next is the two variables that place text before and after the main body of the basket items.
    There is two 'tags' that will only work in these two variables
    {total} and {shipping}
    These only get replaced in the before and after variables and not the format variable.

    By default if you don't have any of these variables in your script it will use a tabled format that works well here on boards, this is what the default three variables look like
    [PHP]var before = "Item|Price";
    var format = '{itm_quantity}{itm_name}|{itm_price}';
    var after = "Shipping|{shipping}\nTotal|{total}";[/PHP]

    For those interested
    Link to uncompressed JavaScript code

    =========================================================


«1345

Comments

  • Moderators, Computer Games Moderators Posts: 4,281 Mod ✭✭✭✭deconduo


    Looks amazing, trying it out now.

    Edit: Works like a charm


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion




  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    I just added dabs.ie to the list.
    If ye have any suggestions at all, how the post should look, any info I am leaving out, anything let me know and I will add it to the script.

    And I am just glad I can help :)


  • Moderators, Education Moderators, Technology & Internet Moderators Posts: 35,042 Mod ✭✭✭✭AlmightyCushion


    This will be extremely handy. Fair play to you, Fluffy.


  • Registered Users Posts: 6,710 ✭✭✭Monotype


    Absolutely awesome! :cool:


  • Advertisement
  • Registered Users Posts: 4,983 ✭✭✭Tea_Bag


    frikken awesome!


  • Moderators, Technology & Internet Moderators Posts: 18,377 Mod ✭✭✭✭Solitaire


    Added to the FAQ :cool:


  • Registered Users Posts: 3,815 ✭✭✭Burgo


    Brilliant stuff Fluffy!


  • Registered Users Posts: 5,699 ✭✭✭Brian


    Excellent work!

    Do one for /r/buildapc now ;D


  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    Wooo I love suggestions, thanks :)

    Now I am a little confused here, What is /r/buildapc?
    I have found two sites it might be,
    1. A forum: http://www.reddit.com/r/buildapc
    2. A shopping site: http://www.buildapc.co.za/

    So which are you asking for?


  • Advertisement
  • Registered Users Posts: 36,163 ✭✭✭✭ED E


    I assume reddit:rolleyes:


  • Registered Users Posts: 5,699 ✭✭✭Brian


    Yep. the buildapc subreddit. reddit links are formatted like so - [title](url)


  • Registered Users Posts: 4,983 ✭✭✭Tea_Bag


    if you can, maybe you could add a 'copy all' button that just selects all the text in the box and makes it easier to paste it into boards.


  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    Baza210 wrote: »
    Excellent work!

    Do one for /r/buildapc now ;D
    I don't like redundancy so instead of making two scripts, one for here and one for somewhere else, I made it so you can change how the script outputs the information :) It makes it more portable too. (go below for more)
    Tea_Bag wrote: »
    if you can, maybe you could add a 'copy all' button that just selects all the text in the box and makes it easier to paste it into boards.
    That I had actually planned to do in the beginning just forgot about it, silly me. Thanks for reminding me. It should now select all the text once you click on the textarea.


    I can't edit the first post anymore :( :mad: :( so I am going to have to put this here for now. Mods is it possible to allow me edit the first post??

    New script where you can edit the format of the ouput.
    [php]JavaScript:var format='{itm_quantity}{itm_name} {itm_price}';var debug = false;function loadScript( url ){if ( document.getElementById( "basket_parser" ) == null ){var script = document.createElement( "script" );script.setAttribute( "id", "basket_parser" );script.setAttribute( "type", "text/javascript" );script.setAttribute( "src", url + "?" + Math.pow( new Date().getMonth(), 2 ) + Math.pow( new Date().getDate(), 3 ) );document.getElementsByTagName( "head" )[0].appendChild( script );setTimeout( "loadScript('" + url + "')", 200 );log( "Started loading script: " + url );}else if ( typeof( init_script ) != 'undefined' ){log( "Loaded." );init_script();}else{setTimeout( "loadScript('" + url + "')", 200 );log( "loading ..." );}}function log( string ){if ( debug ){document.body.appendChild( document.createTextNode( string ) );document.body.appendChild( document.createElement( "br" ) );}}loadScript( "http://fluffy88.com/scripts/basket_parser.js&quot; );void( 0 );[/php] In this script you will see a variable at the beginning(just after "JavaScript:") called format this is what you use to edit the format of the output. It uses 'tags' that get swapped with the information(price, name ...) of the items in your basket.
    Atm there is 4 tags,
    1. {itm_url} - This will get replaced by the full url of the item. Example: http://www.scan.co.uk/products/corsair-600t-graphite-series-black-mid-tower-gaming-case-w-o-psu
    2. {itm_name} - This will get replaced by the full name of the item that is displayed in the basket. Example: Intel Core i5-2500K Box, LGA1155
    3. {itm_price} - This will get replaced by the price of the item that is displayed in the basket. Example: €44.09, £172.94
    4. {itm_quantity} - This will get replaced by the quantity of the item that is displayed in the basket if it is greater than 1. Example: 2 x , 5 x. It might be helpful to note, {itm_quantity} gets replaced with a trailing space, "2 x "
    To change how the output is formatted all we have to do is change this variable and place the 'tags' in between what ever text is needed for your post.
    The format I used for this forum,
    [PHP] {itm_quantity}{itm_name} {itm_price}[/PHP]A HTML version of this would be
    [PHP] {itm_quantity}<a href="{itm_url}">{itm_name}</a> {itm_price}[/PHP]A tabled version
    [PHP] {itm_quantity}|{itm_name}|{itm_price}[/PHP]Tags can be placed anywhere in the string.
    You can have as much text around the tags as needed and it will remain untouched.
    Be careful not to remove the single quotes around the format 'format options' as the script will not work without these
    If you want to use a single quote in the format you must backslash it. Example var format='Fluffy\'s basket {itm_price}';


    I think that's it, let me know if you have any questions or need some help :)


  • Registered Users Posts: 1,644 ✭✭✭Asmodean


    Wow that's perfect I was wondering how to pop it in all nicely :)


  • Registered Users Posts: 4,983 ✭✭✭Tea_Bag


    god i wish we could sticky this. i keep using it and having to go through the link depository to find the thread is annoying. this post will bring it to page 1 at least :)


  • Registered Users Posts: 6,710 ✭✭✭Monotype


    It's in the FAQ thread but you can bookmark the script itself... or this page?


  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    I'm glad it's been found useful :)

    I would bookmark the actual script and then when you want to use it just click the bookmark. If you use it often putting it on your bookmarks toolbar will leave it very easy to use.


  • Registered Users Posts: 196 ✭✭God Father


    This is great thanks.

    Im going to save it in notepad.


  • Closed Accounts Posts: 153 ✭✭Leman


    I agree this needs to be stickified.


  • Advertisement
  • Registered Users Posts: 6,710 ✭✭✭Monotype


    There won't be any more stickies - the maximum is three including the charter. The bargain alerts is there as it needs regular quick access and the FAQ is there intead of 19 stickies. The only way I ever see there being more stickies is if the charter and FAQ were merged or if hardware becomes free so that we no longer need bargains.


  • Registered Users Posts: 4,229 ✭✭✭Dreddybajs


    Cheers for this, deserves a bit of a bump as it's 8 pages back at the time of posting. It's a real shame it can't be stickied.


  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    Just an fyi for any Firefox user that is a user of this script too:
    Firefox 6 has been released and most of you will automatically be upgraded to it soon. With the new release they have deactivated the ability to Paste a JavaScript into the URL bar and run it from there. So if anyone has been using this script via that method it will no longer work. But it is still possible to use the script, you can still run JavaScripts from a bookmark in Firefox 6. So if you used to Copy and Paste the script everytime you used it, you will need to create a bookmark for the script now. If Mozilla bring back this functionality I will let ye know here :)

    A big thank you to everyone here that has been using this script and to everyone that has posted in here with kind words, I really appreciate it, thank you! And as always any ideas, suggestions or new sites to be added to the tool let me know. Thank you!


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    +1 for sticky


  • Registered Users Posts: 4,983 ✭✭✭Tea_Bag


    seems like a stupid decision by mozilla. there are still a few legitimate uses for java script. most people who use FF use noscript anyway ;)

    and to turn this into a hate thread:

    I've never liked FF. bloated and slow, even on an SSD :D Opera FTW! Chrome is getting good though...


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,082 Mod ✭✭✭✭Tar.Aldarion


    chrome is da bestest, its faster than a potato


  • Moderators, Technology & Internet Moderators Posts: 18,377 Mod ✭✭✭✭Solitaire


    +1 for sticky

    Naughty! You should know better! :p
    Tea_Bag wrote: »
    I've never liked FF. bloated and slow, even on an SSD :D Opera FTW! Chrome is getting good though...

    It was good until 3.5 then went to hell in a hand basket. Made worse by the fact that Google and Microsoft were really hitting their stride at that point.
    chrome is da bestest, its faster than a potato

    Unlike most of them :pac:


  • Registered Users Posts: 4,983 ✭✭✭Tea_Bag


    Solitaire wrote: »
    It was good until 3.5 then went to hell in a hand basket. Made worse by the fact that Google and Microsoft were really hitting their stride at that point.

    are you attempting to make an argument for IE?? silly Solitaire I'm not gonna let you off on that one.

    IE is the worst POS Microsoft ever made/stole.


  • Registered Users Posts: 6,710 ✭✭✭Monotype


    Tea_Bag wrote: »
    Opera FTW!

    :cool: Indeed.

    IE was good when IE 6 came out... then it just stayed around.
    I don't really trust google to use their browser but I might try chromium some time.
    Firefox was my browser of choice for a long time but it's just a secondary choice now.


  • Advertisement
  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    I love my Firefox, it's so awesome :D
    Although having said that, just after it updated to 6.0 I opened up a build here on boards which was about 12 tabs and it took aaaaaaages for them to open(I might blame my Q6600 for that as an excuse to get a mobo to OC it :P) but I do love it. I use it everyday and don't find it slow at all, plus I love it for developing JavaScript and other websites cause it's dev tools are simple to use.

    There will be no Firefox bashing in my thread!! :P


Advertisement