SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Jquery class

  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Jquery class

    Hi, I want to write a jquery function that I will use to share status on facebook and twitter. How can I write the function?

    Thanks

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Facebook status jQuery plugin

    For Twitter, there is Tweet! along with a wide range of other twitter status plugins
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    Facebook status jQuery plugin

    For Twitter, there is Tweet! along with a wide range of other twitter status plugins
    Hi thanks for the reply. I downloadded the file from github but honestly I want able to paste it on the jquery file I have. Im not sure how to incorporate the fbshare function on my actual jquery file.

    Below are some of the functions I have on my jquery:

    function stream_publish() {
    global $client, $config;
    if (!$client['id']) die('please login first');
    limit_posting(0,1);
    if (strlen($_POST['message'])<4) die('failed! message too short');
    $_POST['message'] = utf8_substr($_POST['message'],200);
    $_POST['message'] = parseurl($_POST['message']);
    $url_search = array(
    "/\[url]www.([^'\"]*)\[\/url]/iU",
    "/\[url]([^'\"]*)\[\/url]/iU",
    "/\[url=www.([^'\"\s]*)](.*)\[\/url]/iU",
    "/\[url=([^'\"\s]*)](.*)\[\/url]/iU",
    );
    $url_replace = array(
    "<a href=\"http://www.\\1\" target=\"_blank\" rel=\"nofollow\">www.\\1</a>",
    "<a href=\"\\1\" target=\"_blank\" rel=\"nofollow\">\\1</a>",
    "<a href=\"http://www.\\1\" target=\"_blank\" rel=\"nofollow\">\\2</a>",
    "<a href=\"\\1\" target=\"_blank\" rel=\"nofollow\">\\2</a>"
    );
    $stream_id = stream_publish(preg_replace($url_search,$url_replace, h($_POST['message']) ),$attachment,$app,$client['id'],$_POST['page_id']);
    $arr = array(
    'id'=>$stream_id,'fullname'=>$client['fullname'],'avatar'=>$client['avatar'],'message'=>decode_bb(h(stripslashes($_POST['message']))),'attachment'=>$attachment,'username'=>$client['uname'],'created'=>time()
    );
    echo stream_display($arr,'',1);
    ss_update();

    exit;
    }

    function stream_delete($storyid) {
    global $client, $config;
    if (!$client['id']) die('please login first');
    $res = sql_query("select * from ".tb()."streams where id='$storyid'");
    $stream = sql_fetch_array($res);
    if (!$stream['id']) die('wrong sid');
    if ($stream['uid'] == $client['id'] || in_array('3',$client['roles']) ) {
    sql_query("update ".tb()."streams set hide=1 where id='{$stream['id']}'");
    echo 'ok';
    }
    else {
    echo 'access denied';
    }
    exit;
    }

    function comment_publish() {
    global $client, $config;
    if (!$client['id']) die('<div class="ferror">please login first</div>');
    if ( !eregi("^[0-9a-z]+$",$_POST['target_id']) ) die('no target id');
    if (strlen($_POST['message'])<4) die('<div class="ferror">failed! message too short</div>');
    limit_posting(0,1);

    comment_publish($_POST['target_id'],$_POST['message']);
    record_this_posting($_POST['message']);
    $arr = array(
    'avatar'=>$client['avatar'],'message'=>stripslashes($_POST['message']),'username'=>$client['uname'],'fullname'=>$client['fullname'],'created'=>time()
    );
    echo comment_display($arr);
    ss_update();
    exit;
    }

    function dolike() {
    sleep(1);
    global $client, $config;
    if (!$client['id']) die('<div class="ferror">please login first</div>');
    if ( !eregi("^[0-9a-z]+$",$_POST['target_id']) ) die('no target id');
    limit_posting(0,1);
    if (!is_numeric($_POST['target_id'])) {
    die('wrong target id');
    }
    $res = sql_query("select * from ".tb()."liked where stream_id='{$_POST['target_id']}' and uid='{$client['id']}' limit 1");
    if (sql_counts($res)) {
    sql_query("delete from ".tb()."liked where stream_id='{$_POST['target_id']}' and uid='{$client['id']}'");
    sql_query("update ".tb()."streams set likes=likes-1 where id='{$_POST['target_id']}'");
    echo t('Unliked').'<br />';
    }
    else {
    $like = array('uid'=>$client['id'],'stream_id'=>$_POST['target_id']);
    sql_insert($like,tb().'liked');
    sql_query("update ".tb()."streams set likes=likes+1 where id='{$_POST['target_id']}'");
    echo t('Liked').'<br />';
    }

    exit;
    }

    function dodislike() {
    global $client, $config;
    if (!$client['id']) die('<div class="ferror">please login first</div>');
    if ( !eregi("^[0-9a-z]+$",$_POST['target_id']) ) die('no target id');
    limit_posting(0,1);
    if (!is_numeric($_POST['target_id'])) {
    die('wrong target id');
    }
    $res = sql_query("select * from ".tb()."disliked where stream_id='{$_POST['target_id']}' and uid='{$client['id']}' limit 1");
    if (sql_counts($res)) {
    sql_query("delete from ".tb()."disliked where stream_id='{$_POST['target_id']}' and uid='{$client['id']}'");
    sql_query("update ".tb()."streams set dislikes=dislikes-1 where id='{$_POST['target_id']}'");
    echo t('Un-disliked').'<br />';
    }
    else {
    $like = array('uid'=>$client['id'],'stream_id'=>$_POST['target_id']);
    sql_insert($like,tb().'disliked');
    sql_query("update ".tb()."streams set dislikes=dislikes+1 where id='{$_POST['target_id']}'");
    echo t('Disliked').'<br />';
    }

    exit;
    }

    function wholike($stream_id=0,$offset=0) {
    if (!is_numeric($stream_id)) die();
    if (!$offset) $offset = 0;
    $num = 8;
    $res = sql_query("select u.* from ".tb()."liked as l left join ".tb()."accounts as u on u.id=l.uid where stream_id='$stream_id' limit $offset,".($num+1));
    $i=1;
    while ($user = sql_fetch_array($res)) {
    if ($i>$num) {
    $got_more = 1;
    }
    else {
    $users[] = $user;
    }
    $i++;
    }
    echo $this->display_users($users);
    if ($got_more) {
    $offset = $offset + $num;
    echo '<hr />
    <a href="#" onclick="jQuery.facebox({ ajax: \''.url('jquery/wholike/'.$stream_id.'/'.$offset).'\' });return false;" >'.t('More..').'</a>';
    }
    exit;
    }

    function whodislike($stream_id=0,$offset=0) {
    if (!is_numeric($stream_id)) die();
    if (!$offset) $offset = 0;
    $num = 8;
    $res = sql_query("select u.* from ".tb()."disliked as l left join ".tb()."accounts as u on u.id=l.uid where stream_id='$stream_id' limit $offset,".($num+1));
    $i=1;
    while ($user = sql_fetch_array($res)) {
    if ($i>$num) {
    $got_more = 1;
    }
    else {
    $users[] = $user;
    }
    $i++;
    }
    echo $this->display_users($users);
    if ($got_more) {
    $offset = $offset + $num;
    echo '<hr />
    <a href="#" onclick="jQuery.facebox({ ajax: \''.url('jquery/whodislike/'.$stream_id.'/'.$offset).'\' });return false;" rel="facebox">'.t('More..').'</a>';
    }
    exit;
    }

    private function display_users($users) {
    if (is_array($users)) {
    foreach ($users as $user) {
    if (!strlen($user['fullname'])) $user['fullname'] = $user['username'];
    $output .= '<li>'.avatar($user).'<br />'.url('u/'.$user['username'],h($user['fullname'])).'</li>';
    }
    }
    return '
    <ul class="small_avatars">'.$output.'</ul>';
    }

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by thakim83 View Post
    Im not sure how to incorporate the fbshare function on my actual jquery file.
    I keep a long distance away from Facebook so I'm not sure how to deal with their stuff either.

    All the best.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    I keep a long distance away from Facebook so I'm not sure how to deal with their stuff either.

    All the best.
    The script im using is Jcow Community software and not facebook but thought I could use the share button on the site

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,705
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by thakim83 View Post
    The script im using is Jcow Community software and not facebook but thought I could use the share button on the site
    You might be able to, but as I said, I keep a long distance away from Facebook.
    Yes I heard, you're web site is not on Facebook, but bear in mind that I do not have any content on Facebook so I can not even start to implement or test anything relating to Facebook. Capiche?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    You might be able to, but as I said, I keep a long distance away from Facebook.
    Yes I heard, you're web site is not on Facebook, but bear in mind that I do not have any content on Facebook so I can not even start to implement or test anything relating to Facebook. Capiche?
    Thanks for your time mate


Tags for this Thread

Bookmarks

Posting Permissions

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