Jump to content

narutofan

Members
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

0 Neutral

About narutofan

  • Rank
    Member
  1. hi, i'm trying to create a @tagging script for one of my project where i'm using at.js with tinymce editor. The problem is i get the desired username in alert output ,but can't seem to bind it to a variable that will be accepted by at.js. The response i get when i alert is but i want only the part in the variable don't know how to get it in jquery or javascript a little help in solving this problem might help me a lot. The code i have tried so far tinymce.init({ selector: 'textarea#wall_id_1', height: 300, theme: 'modern', resize: false, force_p_newlines: false, plugins: 'print preview powerpaste searchreplace autolink directionality advcode visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount tinymcespellchecker a11ychecker imagetools mediaembed linkchecker contextmenu colorpicker textpattern help', toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat', image_advtab: true, templates: [ { title: 'Test template 1', content: 'Test 1' }, { title: 'Test template 2', content: 'Test 2' } ], content_css: [ '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i', '//www.tinymce.com/css/codepen.min.css' ], setup: function(editor) { editor.on('keyup', function(e) { /* var eli= $(editor.contentDocument.activeElement).prop('innerHTML'); var txt=$(eli+'p').html(); var txt1=$(eli+'span').html(); var regex=new RegExp(/@+([a-zA-z!._-]+)/g); var match= regex.exec(txt); // console.log(match); // alert(match); var names=load_Ajax(match[1]); return names; */ if (e.keyCode == 13 && $(editor.contentDocument.activeElement).atwho('isSelecting')) return false; }); return names; }, init_instance_callback: function(editor) { var name = editor.on("keyup", function(e) { var eli = $(editor.contentDocument.activeElement).prop('innerHTML'); console.log('eli=', eli); var txt = $(eli + 'p').html(); console.log('txt=', txt); var txt1 = $(eli + 'span').html(); console.log('txt1=', txt1); var regex = new RegExp(/@+([a-zA-z!._-]+)/g); var match = regex.exec(txt); console.log('match=', match); if( typeof match != 'undefined' && match != null ) { var results = []; $.ajax({ url: "jsdropdown.php", data: { "uname": match[1] }, async: false, complete: function(res) { results.push(res); // results=res; // alert(JSON.stringify(res)); return res; }, dataType: "json" }); var results1=JSON.stringify(results); alert(results1); $(editor.contentDocument.activeElement).atwho({ at: "@", data: results1 }); } }).responseJSON; } }); here is a js fiddle: http://jsfiddle.net/e8szo2yw/8/
  2. i upgraded to version 4 and the script is working now but now i face a new problem. in order to fetch names via jquery .post function i need the input value from tinymceafter the @ selector do you know how to fetch it. @kicken the code i tried so far : var uname=tinymce.init({ init_instance_callback: function(editor) { $(editor.contentDocument.activeElement).val().then(function(val){alert(val);}); } }); // var names = ["Jacob","Isabella","Ethan","Emma","Michael","Olivia","Alexander","Sophia","William","Ava","Joshua","Emily","Daniel","Madison","Jayden","Abigail","Noah","Chloe","你好","你你你", "jeremy"]; var names= [$.post( "jsdropdown.php", {"uname": uname} , function(res){ return res; })]; tinymce.init({ selector: 'textarea#wall_id_1', height: 300, theme: 'modern', resize: false, plugins: 'print preview powerpaste searchreplace autolink directionality advcode visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists textcolor wordcount tinymcespellchecker a11ychecker imagetools mediaembed linkchecker contextmenu colorpicker textpattern help', toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat', image_advtab: true, templates: [ { title: 'Test template 1', content: 'Test 1' }, { title: 'Test template 2', content: 'Test 2' } ], content_css: [ '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i', '//www.tinymce.com/css/codepen.min.css' ], init_instance_callback: function(editor) { $(editor.contentDocument.activeElement).atwho({at: "@", data: names}); }, setup: function(editor) { editor.on('keydown', function(e) { if(e.keyCode == 13 && $(editor.contentDocument.activeElement).atwho('isSelecting')) return false }) } });
  3. i tried as you said it's not working @kicken here is my code where the textarea is: echo "<div class='jumbotron'><input type='text' class='form-control title_s' name='status_title' placeholder='Title ' ><br>" . "<textarea id='editor' name='content' class='update_session atjs' placeholder='whats up ".$session_uname."'>" . "</textarea><br><span class='status_spinner'></span><br>" . "<span id='status_spinner' class='pull_left'></span><button style='float:right;' type='a' class='btn btn-warning btn btn-large btn-lg post-s'>Post</button></div>";
  4. @kicken the example provided doesn't talk about giving class to tinymce
  5. i don't know how to give the class. But i initialised tinymce on the editor @kicken
  6. Hi, currently i'm trying to create a facebook style tagging system with tinymce3 editor(i don't have a choice to upgrade to 4th version) and i'm following this example here https://github.com/ichord/At.js/wiki/usage-with-TinyMCE. The problem is i'm not able to initiate the facebook style dropdown tagging system as i type in the editor. can anyone help me with this. the code i tried so far: tinyMCE.onAddEditor.add(function(mgr, ed) { var editor = $('#' + ed.editor + '.atjs'); var names = ["Jacob","Isabella","Ethan","Emma","Michael","Olivia","Alexander","Sophia","William","Ava","Joshua","Emily","Daniel","Madison","Jayden","Abigail","Noah","Chloe","你好","你你你", "jeremy"]; if (editor.length == 1) { ed.onInit.add(function(ed, l) { $(ed.contentDocument.activeElement).atwho({at: "@",data: "names"}); }); } });
  7. Hi, i need to create a phpfreaks style tagging system in one of my projects and i'm stumped at how to get user input value at keypress after they type the "@" symbol in tinymce editor and i need help on how to create a phpfreaks style dropdown list and how to capture the clicked usernames. i think they are using tinymce3 editor to post updates. can anyone help me regardiing this problem.
  8. @Barand come on man i'm asking because i don't know how to do it and you are making fun of me.
  9. hi @requinix, i want to create a dropdown style tagging sys as in this forum can i know how to do it in jquery and php. And i would also like to know how to create a facebook style read more dropdown link after some 250 words??
  10. narutofan

    password_verify not working

    finally found the solution after googling a bit. Seems like password_hash function requires 60 characters in DB but i gave only 55 after changing it everything works fine now thankis for your patience @requinix
  11. narutofan

    password_verify not working

    Hi, i'm currently facing this problem where i need to verify passwords using password_verify function. After creating the password with password_hash function when i try to login its not logging in and when i try to ouput it the var_dump function for password_verify function is saying bool false. I coudn't figure out where i'm going wrong.it would be of great help if you guys could solve it. here is the code for login script: error_reporting(E_ALL); include_once 'dbconfig.inc.php'; if (isset($_POST['submit-login'])) { $uname= htmlentities($_POST['unamel']); $unamel= stripslashes($uname); $query="select * from user where uname=:uname and activated='1'"; $stmt=$conn->prepare($query); $stmt->bindValue(":uname",$unamel); $stmt->execute(); $user1=$stmt->fetchAll(); $hash='$2y$10$wCt5GTBB1oCFzhc0fh5GeeATPjP8mvxQsFH0taabQdXfqu0prOVCG'; $pass1="123456"; print_r($hash); $passl= password_verify($pass1, $hash); var_dump($passl); exit(); } password hash script: include '../includes/dbconfig.inc.php'; $sess_id=(int)$_SESSION['id']; $ph= htmlentities($_POST['phone']); $em= htmlentities($_POST['email']); $un= htmlentities($_POST['uname']); $fn= htmlentities($_POST['fname']); $ln= htmlentities($_POST['lname']); $pssd= $_POST['current_pass']; $n_pssd= password_hash($_POST['new_password'],PASSWORD_BCRYPT); $privacy=(int)$_POST['privacy']; $phone= stripslashes($ph); $email= stripslashes($em); $uname= stripslashes($un); $fname= stripslashes($fn); $lname= stripslashes($ln); $current_pass= $pssd; $new_pass= $n_pssd; print_r($new_pass); exit();
  12. narutofan

    php script not running to finish point

    finally found the solution i deleted the check_regex function i intended it for array_filter function and now it works fine thanks for your patience all.
  13. narutofan

    php script not running to finish point

    and it is not catching any error at the end
  14. Hi, i'm currently facing a problem of php script not running to the finish point of the script. the code actually tries to find tags preceded either with "!" or "@" and if it doesn't match it outputs user input data in to a update query at the end and this is where the script isn't behaving properly it tries to match the tags but it is not updating in to DB i don't know where i'm going wrong.The code might be long but that is all there is to it. include_once '../includes/dbconfig.inc.php'; if(strlen(htmlentities($_POST['data']))<1){ echo "Data empty!"; exit(); } #clean all the post vars that will interact with the DB. #ideal for search results page $u_id=(int)$_POST['id']; $type=htmlentities($_POST['type']); $account_name= htmlentities($_SESSION['uname']); $data= htmlentities($_POST['data']); $tit= htmlentities($_POST['title']); $sess_id=(int)$_SESSION['id']; $title= stripslashes($tit); $sql="select count(user_id) from user where uname=:account_name and activated='1' limit 1"; $stmth=$conn->prepare($sql); $stmth->bindparam(":account_name",$account_name); $stmth->execute(); $row=$stmth->rowCount(); if ($row<1) { echo "Account doesn't exist"; exit(); } $dat= explode(" ", $data);//names are exploded in to array $data1=""; foreach($dat as $d){ if(strpos($d ,'!') !== FALSE ){ $d_p=""; $i=0; $tag=""; $d2=count($dat); while ($i<$d2) { $d_w=$dat[$i]; $regex="/!+([a-zA-z0-9._-]+)/"; $regex1="/(?:\s|^)![A-Za-z0-9\-\.\_]+(?:\s|$)/"; $d1=preg_match_all($regex, $dat[$i],$output_preg,PREG_PATTERN_ORDER); function check_regex($data){ if ($data=="/(?:\s|^)![A-Za-z0-9\-\.\_]+(?:\s|$)/") { return $data; } } $i++; $d_p= array_column($dat,$output_preg[0][0],$regex1); $d_f= preg_grep($regex1, $d_p); $d_c= array_count_values($d_f); //print_r($d_c); foreach ($d_c as $d2) { if ($d2>=2) { $tag=1; } } } if($tag==1){ echo 1; exit(); } else { echo 0; } } elseif (strpos($d ,'@') !== FALSE) { $d1=str_replace("@", "", $d); //check if the user exists $stmt= $conn->prepare("select count(uname) from user where uname=:d1 and activated='1'"); $stmt->bindValue(":d1",$d1); $stmt->execute(); $count=$stmt->rowCount(); if($count>0){ $data1=str_replace("@$d1", "<a href='home.php?u={$d1}'>@$d1</a>", $data); $app = "Status post"; $note = $_SESSION['uname'].' Mentioned you in a Post: <br /><a href="home.php?u='.$_SESSION['uname'].'">'.$_SESSION['uname'].'&#39;s Profile</a><br><hr>'; $stmth= $conn->prepare("insert into notifications (username, initiator, app, note, date_time,user_id_n) values(:friend,:session,:app,:note,now(),:sess_id)"); $stmth->bindparam(":friend",$d1); $stmth->bindparam(":session",$_SESSION['uname']); $stmth->bindparam(":sess_id",$sess_id); $stmth->bindparam(":app",$app); $stmth->bindparam(":note",$note); $stmth->execute(); } } else { $data1=$data; } } #insert in to DB try { $stmt=$conn->prepare("update updates set account_name=:account_name,author=:session, title=:title ,update_body=:data1,time=now() where update_id=:u_id"); $stmt->bindparam(":account_name",$account_name); $stmt->bindparam(":session",$account_name); $stmt->bindparam(":title",$title); $stmt->bindparam(":data1",$data1); $stmt->bindparam(":u_id",$u_id); $stmt->execute(); }catch (PDOException $ex) { echo $ex->getMessage(); } echo 2;
  15. narutofan

    If statement not working after loop

    finally i found a solution all i had to do was add spaces to the anchor tag in hashtag function and the explode function started to separate the tag from the anchor tag and now the if st is working after the loop. function hashtags($dat) { $regex="/!+([a-zA-z0-9._-]+)/"; $dat1= preg_replace($regex, '<a href="hash_sys.php?tag=$1"> $0 </a>', $dat);<=see the space return $dat1;  }.... foreach ($tag_fetch as $row_s) { $data= stripslashes($row_s['update_body']); $data1= explode(" ",$data); <= this took care of the rest
×

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.