www.webdeveloper.com
Results 1 to 13 of 13

Thread: Help! Follow Friday Tweet Generator

  1. #1
    Join Date
    Jan 2010
    Posts
    7

    Help! Follow Friday Tweet Generator

    Okay, im having a little difficulty trying to code a #FollowFriday tweet generator for my website. My code works perfectly creating the tweet, but I want to make it so that when I hit the Submit button, it uses the text from the textarea to encode a URL and append it to the end of http://twitter.com/home?status=. For example if the text in the textbox says "#FollowFriday #FF @FATBOISLIMM" then it generates and opens this URL (http://twitter.com/home?status=%23Fo...%40FATBOISLIMM) in their browser window. Here is the code I have:

    Code:
    <script type = "text/javascript">
    //www.SlapTV.net
    //www.LILPOTSPRODUCTIONS.com
    
    function text(t){
     
      a = document.getElementById('statusPreview');
     
      a.value += t;
     
     }
     
    function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit)
    field.value = field.value.substring(0, maxlimit);
    else
    cntfield.value = maxlimit - field.value.length;
    }
    
    
    function showtext() {
    var output = "";
    if (document.getElementById("chk1").checked) {
    output = output + "#FollowFriday ";
    }
    if (document.getElementById("chk2").checked) {
    output = output + "#FF ";
    }
    if (document.getElementById("chk3").checked) {
    output = output + "@_SlapTV ";
    }
    if (document.getElementById("chk4").checked) {
    output = output + "@FATBOISLIMM ";
    }
    
    document.getElementById("statusPreview").value = output;
    }
    
    </script>
    
    <center>
    
    <form name="status" action="http://twitter.com/statuses/update.xml" method="POST" enctype="application/x-www-form-urlencoded">
    
    <textarea name="statusPreview" id="statusPreview" wrap="physical" cols="55" rows="3"
    onKeyDown="textCounter(document.status.statusPreview,document.status.remLen2,140)"
    onKeyUp="textCounter(document.status.statusPreview,document.status.remLen2,140)"></textarea>
    <br>
    <input readonly type="text" name="remLen2" size="3" maxlength="3" value="140">
    characters left
    <input type="Submit" class="Submit" value="TGIFF">
    <br /><br>
    
    <input type = "checkbox" id = "chk1" onclick = "showtext()">#FollowFriday 
    <input type = "checkbox" id = "chk2" onclick = "showtext()">#FF <br /><br />
    <input type = "checkbox" id = "chk3" onclick = "showtext()">SlapTV 
    <input type = "checkbox" id = "chk4" onclick = "showtext()">T
    as you can see it generates the text just fine, but I dont know how to make it encode and open the URL. Please help!!

  2. #2
    Join Date
    Oct 2006
    Posts
    939
    I get prompted for a password. Need the password to continue?

  3. #3
    Join Date
    Jan 2010
    Posts
    7
    exactly but when you encode the URL you shouldn't need to insert a password as long as your already signed into twitter because this method of updating your status is HTTP based. when you click Submit from my program i want it to encode whats in the textbox into a URL, attach that to the end of 'http://twitter.com/home?status=' and open that link. because when you open that link it will bring you to your twitter homepage and whatever have after home?status=...... will be in your status box waiting for you to click Update

  4. #4
    Join Date
    Jan 2010
    Posts
    7
    can ANYbody help?

  5. #5
    Join Date
    Oct 2006
    Posts
    939
    I have the idea that I'd have to set up a Twitter account in order to pursue this?

  6. #6
    Join Date
    Jan 2010
    Posts
    7
    no, you only need a Twitter account to test it. all i need help with is encoding the text thats in the text box into URL format when the submit button is hit, and append that to the end of this URL: http://twitter.com/home?status=

  7. #7
    Join Date
    Oct 2006
    Posts
    939
    I'm not quite following here, being unfamiliar.
    The var appendTo is there for you to do something with-

    HTML Code:
    <script type = "text/javascript">
    //www.SlapTV.net
    //www.LILPOTSPRODUCTIONS.com
    
    function text(t){
     
      a = document.getElementById('statusPreview');
     
      a.value += t;
     
     }
     
    function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit)
    field.value = field.value.substring(0, maxlimit);
    else
    cntfield.value = maxlimit - field.value.length;
    }
    
    
    function showtext(v) { 
    var appendTo='http://twitter.com/home?status='+v
    alert('_'+appendTo+'_'); return
    
    var output = "";
    if (document.getElementById("chk1").checked) {
    output = output + "#FollowFriday ";
    }
    if (document.getElementById("chk2").checked) {
    output = output + "#FF ";
    }
    if (document.getElementById("chk3").checked) {
    output = output + "@_SlapTV ";
    }
    if (document.getElementById("chk4").checked) {
    output = output + "@FATBOISLIMM ";
    }
    
    document.getElementById("statusPreview").value = output;
    }
    
    </script>
    
    <center>
    
    <form name="status" action="http://twitter.com/statuses/update.xml" method="POST" enctype="application/x-www-form-urlencoded">
    
    <textarea name="statusPreview" id="statusPreview" wrap="physical" cols="55" rows="3"
    onKeyDown="textCounter(document.status.statusPreview,document.status.remLen2,140)"
    onKeyUp="textCounter(document.status.statusPreview,document.status.remLen2,140)"></textarea>
    <br>
    <input readonly type="text" name="remLen2" size="3" maxlength="3" value="140">
    characters left
    <input type="Submit" class="Submit" value="TGIFF">
    <br /><br>
    
    <input type = "checkbox" id = "chk1" onclick = "showtext(this.value)" value="#FollowFriday">#FollowFriday 
    <input type = "checkbox" id = "chk2" onclick = "showtext(this.value)" value="Firefox">#FF <br /><br />
    <input type = "checkbox" id = "chk3" onclick = "showtext(this.value)" value="SlapanyTv">SlapTV 
    <input type = "checkbox" id = "chk4" onclick = "showtext(this.value)" value="TboneSteak">T

  8. #8
    Join Date
    Jan 2010
    Posts
    7
    no, appreciate that try tho. here, i made a test twitter account Username: testest123123 PW: test123. sign into there first and then click this link:

    http://twitter.com/home?status=&#37;23Fo...0testest123123

    as you see, the link created a status message for you (everything after home?status= is inserted into your status update box)

    this is what i want my code to do:

    -user checks any combination of boxes [done]
    -corresponding text appears in textarea [done]
    -when user clicks Submit button (TGIFF), it encodes the text in the textarea into a format like this:

    %23FollowFriday+%23FF+%40testest123123

    -then appends that to the end of this:

    http://twitter.com/home?status=

    -therefore generating and opening this link in their browser window:

    http://twitter.com/home?status=%23Fo...0testest123123

    as you see, opening this generated link sends you to your twitter homepage with "#FollowFriday #FF @testest123123" as your new status message

    get it?


    URLEncoding website: http://www.albionresearch.com/misc/urlencode.php

  9. #9
    Join Date
    Oct 2006
    Posts
    939
    Ok still guessing but maybe you can work with this-

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    	"http://www.w3.org/TR/html4/strict.dtd">
    <HTML>
    <HEAD><TITLE>Fr7-15pm36</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <STYLE type=text/CSS>
    //* {margin:0; padding:0;}
    
    </STYLE>
    <script type = "text/javascript">
    //www.SlapTV.net
    //www.LILPOTSPRODUCTIONS.com
    
    function text(t){
     
      a = document.getElementById('statusPreview');
     
      a.value += t;
     
     }
     
    function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit)
    field.value = field.value.substring(0, maxlimit);
    else
    cntfield.value = maxlimit - field.value.length;
    }
    
    var appendTo='http://twitter.com/home?status='
    var output = "";
    function showtext() {
    output = "";
    if (document.getElementById("chk1").checked) {
    output = output + escape("#FollowFriday ");
    }
    if (document.getElementById("chk2").checked) {
    output = output + escape("#FF ");
    }
    if (document.getElementById("chk3").checked) {
    output = output + escape("@_SlapTV ");
    }
    if (document.getElementById("chk4").checked) {
    output = output + escape("@FATBOISLIMM ");
    }
    
    document.getElementById("statusPreview").value = output;
    subm()
    }
    function subm(){appendTo+=output; //alert(appendTo);
     var aWin =window.open(appendTo,'aWin','top=150px, left=200px, width=400, height=375, location, menubar, scrollbars, toolbar, resizable, status');}
    </script>
    
    <META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
    <BODY scroll="auto">
    <center>
    
    <form name="status" action="http://twitter.com/statuses/update.xml" method="POST" enctype="application/x-www-form-urlencoded">
    
    <textarea name="statusPreview" id="statusPreview" wrap="physical" cols="55" rows="3"
    onKeyDown="textCounter(document.status.statusPreview,document.status.remLen2,140)"
    onKeyUp="textCounter(document.status.statusPreview,document.status.remLen2,140)"></textarea>
    <br>
    <input readonly type="text" name="remLen2" size="3" maxlength="3" value="140">
    characters left
    <input type="Submit" class="Submit" value="TGIFF">
    <br /><br>
    
    <input type = "checkbox" id = "chk1" onclick = "showtext()">#FollowFriday 
    <input type = "checkbox" id = "chk2" onclick = "showtext()">#FF <br /><br />
    <input type = "checkbox" id = "chk3" onclick = "showtext()">SlapTV 
    <input type = "checkbox" id = "chk4" onclick = "showtext()">T
    
    </BODY></HTML>

  10. #10
    Join Date
    Jan 2010
    Posts
    7
    okay okay we're making progress. that escape function is going to come in handy, but is there a way we can make the escape not encode anything until AFTER the Submit button is clicked? because i dont want the user to have to see what the encoded version of the text looks like ya know? here is what its going to look like in case you need to see it in action: www.slaptv.net/followfriday.html

  11. #11
    Join Date
    Oct 2006
    Posts
    939
    Its only a matter of moving the code around. From what you gave, you should be able to figure it out... Or, did you not write that code yourself?

  12. #12
    Join Date
    Oct 2006
    Posts
    939
    Ok, I may have it for you but you should ask someone else about the form,
    I'm not keen on forms
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    	"http://www.w3.org/TR/html4/strict.dtd">
    <HTML>
    <HEAD><TITLE>Fr7-15pm36</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=UTF-8">
    <STYLE type=text/CSS>
    
    
    </STYLE>
    <script type = "text/javascript">
    //www.SlapTV.net
    //www.LILPOTSPRODUCTIONS.com
    
    function text(t){
     
      a = document.getElementById('statusPreview');
     
      a.value += t;
     
     }
     
    function textCounter(field,cntfield,maxlimit) {
    if (field.value.length > maxlimit)
    field.value = field.value.substring(0, maxlimit);
    else
    cntfield.value = maxlimit - field.value.length;
    }
    
    var appendTo='http://twitter.com/home?status='
    var output = "";
    function showtext() {
    output = "";
    if (document.getElementById("chk1").checked) {
    output = output + "#FollowFriday ";
    }
    if (document.getElementById("chk2").checked) {
    output = output + "#FF ";
    }
    if (document.getElementById("chk3").checked) {
    output = output + "@_SlapTV ";
    }
    if (document.getElementById("chk4").checked) {
    output = output + "@FATBOISLIMM ";
    }
    
    document.getElementById("statusPreview").value = output;
    
    }
    function subm(){appendTo+=escape(output); //alert(appendTo);
     var aWin =window.open(appendTo,'aWin','top=150px, left=200px, width=400, height=375, location, menubar, scrollbars, toolbar, resizable, status');
    }
    </script>
    
    <META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
    <BODY scroll="auto">
    <center>
    
    <form name="status" method="POST" enctype="application/x-www-form-urlencoded" onSubmit="subm(); return false">
    
    <textarea name="statusPreview" id="statusPreview" wrap="physical" cols="55" rows="3"
    onKeyDown="textCounter(document.status.statusPreview,document.status.remLen2,140)"
    onKeyUp="textCounter(document.status.statusPreview,document.status.remLen2,140)"></textarea>
    <br>
    <input readonly type="text" name="remLen2" size="3" maxlength="3" value="140">
    characters left
    <input type="Submit" class="Submit" value="TGIFF">
    <br /><br>
    
    <input type = "checkbox" id = "chk1" onclick = "showtext()">#FollowFriday 
    <input type = "checkbox" id = "chk2" onclick = "showtext()">#FF <br /><br />
    <input type = "checkbox" id = "chk3" onclick = "showtext()">SlapTV 
    <input type = "checkbox" id = "chk4" onclick = "showtext()">T
    
    </BODY></HTML>

  13. #13
    Join Date
    Jan 2010
    Posts
    7
    oh man thats it! thanks a lot. yea this was my first program, and i went to google as much as i could until i got stuck..thats when i came to you. but i appreciate all the help man!

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



Recent Articles