2 header('Content-Type: text/javascript');
3 require_once 'header.inc.php';
4 require_once 'functions.inc.php';
5 $player_root = $root .'includes/player/';
7 $userservice =& ServiceFactory::getServiceInstance('UserService');
8 if ($userservice->isLoggedOn()) {
9 $currentUser = $userservice->getCurrentUser();
10 $currentUsername = $currentUser[$userservice->getFieldName('username')];
15 function deleteBookmark(ele, input) {
17 $(ele).parent().append("<span><?php echo T_('Are you sure?') ?> <a href=\"#\" onclick=\"deleteConfirmed(this, " + input + "); return false;\"><?php echo T_('Yes'); ?></a> - <a href=\"#\" onclick=\"deleteCancelled(this); return false;\"><?php echo T_('No'); ?></a></span>");
20 function deleteCancelled(ele) {
21 $(ele).parent().prev().show();
22 $(ele).parent().remove();
25 function deleteConfirmed(ele, input) {
26 $.get("<?php echo $root; ?>ajaxDelete.php?id=" + input, function(data) {
27 if (1 === parseInt(data)) {
28 $(ele).parents(".xfolkentry").slideUp();
34 function useAddress(ele) {
35 var address = ele.value;
37 if (address.indexOf(':') < 0) {
38 address = 'http:\/\/' + address;
40 getTitle(address, null);
45 function getTitle(input) {
46 var title = $("#titleField").val();
47 if (title.length < 1) {
48 $("#titleField").css("background-image", "url(<?php echo $root; ?>loading.gif)");
49 if (input.indexOf("http") > -1) {
50 $.get("<?php echo $root; ?>ajaxGetTitle.php?url=" + input, function(data) {
51 $("#titleField").css("background-image", "none")
58 function autocomplete() {
60 url: '<?php echo $root?>alltags/<?php echo $currentUsername?>',
61 success: function(data) {
62 //console.log($(data));
63 var availableTags = new Array();
64 $(data).find('a').each(function() {
65 availableTags.push($(this).html());
66 //console.log($(this).html());
70 // don't navigate away from the field on tab when selecting an item
71 .bind( "keydown", function( event ) {
72 if ( event.keyCode === $.ui.keyCode.TAB &&
73 $( this ).data( "autocomplete" ).menu.active ) {
74 event.preventDefault();
79 source: function( request, response ) {
80 // delegate back to autocomplete, but extract the last term
81 response( $.ui.autocomplete.filter(
82 availableTags, extractLast( request.term ) ) );
85 // prevent value inserted on focus
88 select: function( event, ui ) {
89 var terms = split( this.value );
90 // remove the current input
92 // add the selected item
93 terms.push( ui.item.value );
94 // add placeholder to get the comma-and-space at the end
96 this.value = terms.join( ", " );
105 function split( val ) {
106 return val.split( /,\s*/ );
108 function extractLast( term ) {
109 return split( term ).pop();
117 // Insert Flash player for MP3 links
118 if ($("#bookmarks").length > 0) {
119 $("a[href$=.mp3].taggedlink").each(function() {
121 var code = '<object type="application/x-shockwave-flash" data="<?php echo $player_root ?>musicplayer_f6.swf?song_url=' + url +'&b_bgcolor=ffffff&b_fgcolor=000000&b_colors=0000ff,0000ff,ff0000,ff0000&buttons=<?php echo $player_root ?>load.swf,<?php echo $player_root ?>play.swf,<?php echo $player_root ?>stop.swf,<?php echo $player_root ?>error.swf" width="14" height="14">';
122 code = code + '<param name="movie" value="<?php echo $player_root ?>musicplayer.swf?song_url=' + url +'&b_bgcolor=ffffff&b_fgcolor=000000&b_colors=0000ff,0000ff,ff0000,ff0000&buttons=<?php echo $player_root ?>load.swf,<?php echo $player_root ?>play.swf,<?php echo $player_root ?>stop.swf,<?php echo $player_root ?>error.swf" />';
123 code = code + '</object> ';
124 $(this).prepend(code);