diff options
author | Alvin Li <liweitianux@gmail.com> | 2013-08-18 00:52:06 +0800 |
---|---|---|
committer | Alvin Li <liweitianux@gmail.com> | 2013-08-18 00:52:06 +0800 |
commit | 9d07e8a26657542c98535abb7812d83a98839918 (patch) | |
tree | 6d5b039e7c01082a280fcefb7cc4fe3ca806e521 /97suifangqa/apps/indicator/static/javascripts/new_delete_index.js | |
parent | 0cdba05f09201b6db129ebaa787e960be9ecb851 (diff) | |
download | 97dev-9d07e8a26657542c98535abb7812d83a98839918.tar.bz2 |
* improved 'indicator.views.follow_indicator()',
renamed to 'indicator_fanduf()' due to name conflict
* finished 'search' function for page indicator NewDeleteIndex.html
* added 'apps/utils/search_tools.py': some tools to process search results
* renamed 'sciblog/templatetags/tools.py' to 'get_range.py'
* added 'format_data()' to indicator.tools': to format data of
record/confine, make it properly display in html page;
* 'indicator/javascripts/new_delete_index.js':
added global 'var added_indexes_id' to track the already added indexes
* added 'indicator/templatetags/divisible_by.py' filter to check
if a number can be extactly divide by another number;
* fixed the 'index_card_fir/index_card_sec' problem of
'act_card_container' of page 'SheetDefault.html'
* indicator/static/css/new_delete_index.css:
added 'index_search_error' and 'index_error'
* fixed 'unit.dump' problems in 'indicator.models'
* 'indicator.tools':
o added 'RI_TYPES', 'RI_WEIGHTS'
o added 'type' in the return value of 'calc_indicator_weight()'
and 'recommend_indicator()'
* added field 'followedHistories' in 'indicator.models.UserIndicator'
* moved 'follow_indicator()' and 'unfollow_indicator()' from
'indicator.views' to 'indicator.tools'
TODO:
* highcharts: draw chart for indicator records;
* add/edit data, and submit (page format design)
* followed indicator submit buttion
Diffstat (limited to '97suifangqa/apps/indicator/static/javascripts/new_delete_index.js')
-rw-r--r-- | 97suifangqa/apps/indicator/static/javascripts/new_delete_index.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/97suifangqa/apps/indicator/static/javascripts/new_delete_index.js b/97suifangqa/apps/indicator/static/javascripts/new_delete_index.js index 2c05d7f..8beed99 100644 --- a/97suifangqa/apps/indicator/static/javascripts/new_delete_index.js +++ b/97suifangqa/apps/indicator/static/javascripts/new_delete_index.js @@ -1,3 +1,6 @@ +// track the indexes already added(/followed) +var added_indexes_id = new Array(); + $(document).ready(function(){ $("#search_btn").bind("click", function(){ var kw = $("#search_kw").val(); @@ -10,6 +13,11 @@ $(document).ready(function(){ $(".right>.index_line").each(function(){ classHover($(this), "minus"); }); + // save the "index_id's of added (type: string) + $(".right>.index_line").each(function(){ + var index_id = $(this).attr("index_id"); + added_indexes_id.push(index_id); + }); $(".add>.icon").live("click", function(){ var add_icon = $(this); var index_id = add_icon.closest(".index_line").attr("index_id"); @@ -21,12 +29,16 @@ $(document).ready(function(){ data: 'index_id='+index_id+'&act=add'+'&time='+time, success: function(data){ if(data == 'success'){ - var obj = add_icon.parent(); - var objClone = obj.clone(); - objClone.removeClass("add") - objClone.children(".index_category").remove(); - $(".right").append(objClone); - classHover(objClone, "minus"); + // check if the index exists? + if (added_indexes_id.indexOf(index_id) == -1) { + var obj = add_icon.parent(); + var objClone = obj.clone(); + objClone.removeClass("add") + objClone.children(".index_category").remove(); + $(".right").append(objClone); + classHover(objClone, "minus"); + added_indexes_id.push(index_id); + } } } }); @@ -45,6 +57,8 @@ $(document).ready(function(){ success: function(data){ var obj = minus_icon.parent(); obj.remove(); + rm_index = added_indexes_id.indexOf(index_id); + added_indexes_id.splice(rm_index, 1); } }); |