home.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<?php $query = " SELECT home_usernote FROM app_users WHERE userid=".$_SESSION['authenticated_user_id']; $res_note = $mysqli->query($query); $row_note = $res_note->fetch_array() ?> <div class="page-header div-move"> <h3><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Note<small> note everything</small></h3> </div> <img src="dist/img/vtbusy.gif" id="loading_img" style="vertical-align:middle; margin-left:5px; display:none;" /> <div id="usernote"><?php if($row_note['home_usernote']){ echo nl2br(htmlspecialchars($row_note['home_usernote'])); }else{ echo '-DoubleClick for add Note.-'; } ?></div> <script type="text/javascript"> function divClicked() { var divHtml = $(this).html(); var regex = /<br\s*[\/]?>/gi; divHtml = divHtml.replace(regex, ""); var editableText = $("<textarea class='form-control' rows='7' />"); editableText.val(divHtml); $(this).replaceWith(editableText); editableText.focus(); // setup the blur event for this new textarea editableText.blur(editableTextBlurred); } function editableTextBlurred() { $("#loading_img").show(); var html = $(this).val(); var viewableText = $("<div id='usernote'>"); //viewableText.html(html); $(this).replaceWith(viewableText); // setup the click event for this new div $.post("blank.php?module=index&action=setUserNote", { note:html }, function(data,status){ //alert("Data: " + data + "\nStatus: " + status); $("#loading_img").hide(); $("#usernote").html(data); }); viewableText.dblclick(divClicked); } $(document).ready(function() { $("#usernote").dblclick(divClicked); }); // </script> |
setUserNote.php
1 2 3 4 5 6 7 8 |
<?php if(isset($_POST['note'])){ $query = " UPDATE app_users SET home_usernote='".$mysqli->real_escape_string(input_post('note'))."' WHERE userid=".$_SESSION['authenticated_user_id']; $res_update = $mysqli->query($query); if($_POST['note']){ echo nl2br(htmlspecialchars($_POST['note'])); }else{ echo '-DoubleClick for add Note.-'; } } ?> |