diff --git a/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt b/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt index 35087f9c40..ff155d179b 100644 --- a/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt +++ b/pkgs/plt-services/meta/pkg-index/official/dynamic.rkt @@ -234,7 +234,7 @@ [("jsonp" "package" "version" "del") jsonp/package/version/del] [("jsonp" "package" "tag" "add") jsonp/package/tag/add] [("jsonp" "package" "tag" "del") jsonp/package/tag/del] - [("jsonp" "package" "curate") jsonp/package/currate] + [("jsonp" "package" "curate") jsonp/package/curate] [("api" "upload") #:method "post" api/upload] [else redirect-to-static])) diff --git a/pkgs/plt-services/meta/pkg-index/official/static/index.js b/pkgs/plt-services/meta/pkg-index/official/static/index.js index 566e519ea0..3bd0d9de8b 100644 --- a/pkgs/plt-services/meta/pkg-index/official/static/index.js +++ b/pkgs/plt-services/meta/pkg-index/official/static/index.js @@ -9,6 +9,20 @@ function me () { return localStorage['email']; } $( document ).ready(function() { + function jslink ( texts, clickf) { + return $('', { text: texts, + href: "javascript:void(0)", + click: clickf } ); } + + function dynamic_send ( u, o ) { + o['email'] = localStorage['email']; + o['passwd'] = localStorage['passwd']; + $.getJSON( dynamic_url(u), o ); } + + function dynamic_pkgsend ( u, o ) { + o['pkg'] = active_info['name']; + dynamic_send ( u, o ); } + $("#package_info").dialog({ autoOpen: false, minWidth: 600, @@ -50,10 +64,7 @@ $( document ).ready(function() { return [tag, " "]; } ) )); } else { ($( "#pi_tags" ).html("").append( $.map( pkgi['tags'], function ( tag, i ) { - return [ tag, $('', { text: "[x]", - href: "javascript:void(0)", - click: function () { - submit_remove_tag(tag); } } ), + return [ tag, jslink( "[x]", function () { submit_remove_tag(tag); }), " "]; } ) )); } // xxx show add and delete buttons @@ -67,15 +78,15 @@ $( document ).ready(function() { function submit_remove_tag ( tag ) { var tag_index = $.inArray(tag, active_info['tags']); - // XXX really remove tag + dynamic_pkgsend( "/jsonp/package/tag/del", { tag: tag } ); active_info['tags'].splice( tag_index, 1 ); - // xxx also on sterms + delete active_info['search-terms'][ tag ]; update_info( active_info ); } function submit_add_tag () { var it = $( "#pi_add_tag_text" ); - // XXX really add tag + dynamic_pkgsend( "/jsonp/package/tag/add", { tag: tag } ); active_info['tags'].push( it.val() ); - // xxx also on sterms + active_info['search-terms'][ tag ] = true; update_info( active_info ); it.val("");} @@ -128,11 +139,7 @@ $( document ).ready(function() { console.log("hash changed beneath me!"); } }); function filterlink ( text, tclass, f ) { - return [$('', { text: text, - class: tclass, - href: "javascript:void(0)", - click: f } ), - " " ]; }; + return [ jslink(text, f), " " ]; }; function addfilterlink ( text, term, tclass ) { return filterlink( text, tclass, function () { @@ -234,10 +241,7 @@ $( document ).ready(function() { .append( $('', { class: "curate_link" } ).hide() // xxx make these links .append("▾", "1", "▴", " "), - $('', { text: value['name'], - href: "javascript:void(0)", - click: function () { - open_info ( value ); } } ) ), + jslink( value['name'], function () { open_info ( value ); }) ), $('