diff options
author | priyanka-m <priyanka.menghani@gmail.com> | 2012-12-16 21:35:10 +0400 |
---|---|---|
committer | priyanka-m <priyanka.menghani@gmail.com> | 2012-12-16 21:35:10 +0400 |
commit | a7c6187373cef4492e23d75607c3835532ce4e5d (patch) | |
tree | d33070593d3ec233935517d7616df4a49cdfba3d /reader | |
parent | 0df32bd3fd0312a08192b3ff02e9a287164e3366 (diff) |
Fixed Tagging, need to work on display
Diffstat (limited to 'reader')
-rwxr-xr-x | reader/ajax/tags.php | 4 | ||||
-rwxr-xr-x | reader/css/reader.css | 2 | ||||
-rwxr-xr-x | reader/js/integrate.js | 42 | ||||
-rwxr-xr-x | reader/lib/library_display.php | 44 | ||||
-rwxr-xr-x | reader/lib/tag_utils.php | 10 |
5 files changed, 34 insertions, 68 deletions
diff --git a/reader/ajax/tags.php b/reader/ajax/tags.php index 70e8c6d02..8892ba0b3 100755 --- a/reader/ajax/tags.php +++ b/reader/ajax/tags.php @@ -1,9 +1,7 @@ <?php include('apps/reader/lib/tag_utils.php'); - $new_tag = $_POST['s']; + $new_tag = $_POST['tag']; $path_of_ebook = $_POST['path']; - //$new_tag = $_POST['tag']; - //$path_of_ebook = urldecode($path_of_ebook); $tags = find_tags_for_ebook($path_of_ebook); if ($tags != NULL) { echo $new_tag; diff --git a/reader/css/reader.css b/reader/css/reader.css index d1dde5311..4d05c5484 100755 --- a/reader/css/reader.css +++ b/reader/css/reader.css @@ -16,7 +16,7 @@ td.filename a.name { position:relative;} a.name span.nametext { position:relative; top: 4px; left:-25px; } span.nametext { padding-left:1px; font-family:Arial; font-size:16px; font-weight:normal; white-space:nowrap;} -a.dirs span.nametext { margin-left:10px;} +a.dirs span.nametext {margin-left:10px;} div#thumbs { position:relative;} div#thumbs img { border:1px solid #EEE; -webkit-box-shadow: 4px 4px 4px 0px grey; box-shadow: 4px 4px 4px 0px grey; /*position:absolute; left:25px; top: 20px;*/} diff --git a/reader/js/integrate.js b/reader/js/integrate.js index 94cfa0d44..438439b0e 100755 --- a/reader/js/integrate.js +++ b/reader/js/integrate.js @@ -5,39 +5,19 @@ $(document).ready(function() { }); $('#file_action_panel').attr('activeAction', false); - - /*$('.start').click(function(){ - var contentbox = $(this).parent().children('div#contentbox'); - var path = $(this).parent().children('a.name').attr('dir'); - contentbox.show(100); - contentbox.keypress(function(e) { - if(e.which == 13) { - var tag = contentbox.text(); - contentbox.text(''); - contentbox.hide(); - var displaybox = $(this).parent().children('div#displaybox'); - displaybox.append('<a href = "apps/reader/fetch_tags.php?tag='+tag+'">'+tag+'</a>'); - //location.reload(); - tag = tag + ','; - $.post('apps/reader/ajax/tags.php', {tag:tag, path:path}); - - } - }); - });*/ - /*$("#searchForm").submit(function(event) { - event.preventDefault(); - var $form = $( this ), - term = $form.find( 'input[name="s"]' ).val(), - url = 'apps/reader/ajax/tags.php'; + $("#TagForm").submit(function(event) { + event.preventDefault(); + var $form = $( this ), + tag = $form.find( 'input[name="tag"]' ).val(), + url = 'apps/reader/ajax/tags.php'; var path = $(this).parent().children('a.name').attr('dir'); - $.post( url, { s: term,path:path }, - function( data ) { - $( "#result" ).empty().append(data); - } - ); - });*/ - + $.post( url, {tag:tag,path:path}, + function( data ) { + $("#result").append('<a href = "apps/reader/fetch_tags.php?tag='+data+'">'+data+'</a>'); + } + ); + }); }); $(function() { diff --git a/reader/lib/library_display.php b/reader/lib/library_display.php index 1dc74462b..f435a9391 100755 --- a/reader/lib/library_display.php +++ b/reader/lib/library_display.php @@ -10,39 +10,21 @@ function display_each_ebook($directory,$name) { htmlspecialchars(urldecode($name)). '</span> </a>'; - //<div id = "displaybox">'; - /* $each_row = find_tags_for_ebook(urldecode($directory).urldecode($name)); - $tags = explode(",",$each_row); - $tag_count = 1; - foreach ($tags as $tag) { - echo '<a href = "'.\OCP\Util::linkTo('reader', 'fetch_tags.php').'?tag='.$tag.'">' - .ucwords($tag). - '</a>'; - } - echo '</div>'; - if (count($tags) < 5 ) { - echo count($tags); - echo '<input type="button" class="start" value="Add Tag">'; - }echo '<div id="contentbox" contenteditable="true"></div>*/ - - /*echo '<form action="/" id="TagForm"> - <input type="text" name="s" placeholder="Add Tag..." /> - <input type="submit" value="add tag" /> - </form> - <!-- the result of the search will be rendered inside this div --> - <div id="result">'; $each_row = find_tags_for_ebook(urldecode($directory).urldecode($name)); - $tags = explode(",",$each_row); - foreach ($tags as $tag) { - echo '<a href = "'.\OCP\Util::linkTo('reader', 'fetch_tags.php').'?tag='.$tag.'">' - .ucwords($tag). - '</a>'; - } + $tags = explode(",",$each_row); + if (count($tags) < 5) { + echo '<form action="/" id="TagForm"> + <input type="text" name="tag" placeholder="Add Tag..." /> + <input type="submit" value="add tag" /> + </form>'; + } + echo '<div id="result">'; + foreach ($tags as $tag) { + echo '<a href = "'.\OCP\Util::linkTo('reader', 'fetch_tags.php').'?tag='.$tag.'">' + .ucwords($tag). + '</a>'; + } echo '</div>'; - - */ - - echo '</td>'; } diff --git a/reader/lib/tag_utils.php b/reader/lib/tag_utils.php index 23a172286..7d77a3feb 100755 --- a/reader/lib/tag_utils.php +++ b/reader/lib/tag_utils.php @@ -11,8 +11,14 @@ function find_tags_for_ebook($path_of_ebook) { } function update_tag_for_ebook($new_tag,$path_of_ebook) { - $stmt = OCP\DB::prepare("UPDATE *PREFIX*eBook_library SET tags = ? WHERE filepath = ?"); - $stmt->execute(array($new_tag,$path_of_ebook)); + $tags = find_tags_for_ebook($path_of_ebook); + $each_tag = explode(",",$tags); + if (count($each_tag) < 5) { + $stmt = OCP\DB::prepare("UPDATE *PREFIX*eBook_library SET tags = ? WHERE filepath = ?"); + $stmt->execute(array($new_tag,$path_of_ebook)); + } + else + return; } function insert_new_tag($new_tag,$path_of_ebook) { |