aboutsummaryrefslogtreecommitdiffstats
path: root/97suifangqa/apps/indicator/static/javascripts
diff options
context:
space:
mode:
authorAlvin Li <liweitianux@gmail.com>2013-08-18 00:52:06 +0800
committerAlvin Li <liweitianux@gmail.com>2013-08-18 00:52:06 +0800
commit9d07e8a26657542c98535abb7812d83a98839918 (patch)
tree6d5b039e7c01082a280fcefb7cc4fe3ca806e521 /97suifangqa/apps/indicator/static/javascripts
parent0cdba05f09201b6db129ebaa787e960be9ecb851 (diff)
download97dev-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')
-rw-r--r--97suifangqa/apps/indicator/static/javascripts/delete_card_tip.js26
-rw-r--r--97suifangqa/apps/indicator/static/javascripts/load_card.js107
-rw-r--r--97suifangqa/apps/indicator/static/javascripts/new_delete_index.js26
3 files changed, 109 insertions, 50 deletions
diff --git a/97suifangqa/apps/indicator/static/javascripts/delete_card_tip.js b/97suifangqa/apps/indicator/static/javascripts/delete_card_tip.js
index 099a216..9365d46 100644
--- a/97suifangqa/apps/indicator/static/javascripts/delete_card_tip.js
+++ b/97suifangqa/apps/indicator/static/javascripts/delete_card_tip.js
@@ -1,4 +1,7 @@
+// global js var: card_2_delete_id (type: string)
+
$(document).ready(function(){
+// console.log(parent.card_2_delete_id); //要取消关注的 卡片id 的获取方法
//点大叉、继续关注按钮,关闭弹层页面
$(".delete_card_tip_close, .action_confirm_ignore").bind("click", function(){
parent.TB_remove();
@@ -7,12 +10,23 @@ $(document).ready(function(){
//取消关注,关闭弹层页面
$(".action_confirm_cancel").bind("click", function(){
- //TODO
- //底层数据层取消关注(ajax)
- //console.log(parent.card_2_delete_id); //要取消关注的 卡片id 的获取方法
+ // ajax process to unfollow the indicator
+ // indicator_id -> parseInt(parent.card_2_delete_id)
+ // 底层数据层取消关注(ajax)
+ var date = new Date();
+ var time = date.getTime();
+ $.ajax({
+ type: 'get',
+ url: parent.indicator_url + 'ajax/unfollow_indicator',
+ data: 'indicator_id='+parent.card_2_delete_id+'&time='+time,
+ success: function(data) {
+ if (data == 'success') {
+ parent.delete_card();
+ parent.TB_remove();
+ }
+ },
+ });
- parent.delete_card();
- parent.TB_remove();
return false;
});
-}); \ No newline at end of file
+});
diff --git a/97suifangqa/apps/indicator/static/javascripts/load_card.js b/97suifangqa/apps/indicator/static/javascripts/load_card.js
index 4db48a4..160273b 100644
--- a/97suifangqa/apps/indicator/static/javascripts/load_card.js
+++ b/97suifangqa/apps/indicator/static/javascripts/load_card.js
@@ -1,26 +1,61 @@
var detail_chart;
-$(document).ready(function(){
- var startDate = '2013-07-13';
- startDate = new Date(startDate.replace(/-/g,"/"));
- var start_date_UTC_time = startDate.getTime() - startDate.getTimezoneOffset() * 60 * 1000;
- var chart3 = new Highcharts.Chart({
+
+// set global options for hightcharts {{{
+$(function() {
+ Highcharts.setOptions ({
chart: {
- renderTo: 'chart_3',
type: 'area',
marginLeft: 15,
height: 223,
spacingTop: 10,
- spacingBottom: 0,
- overflow: false,
- zIndex: 5
+ spacingBottom: 0
+ //overflow: false,
+ //zIndex: 5
},
+ colors: ['#31B6AD'],
credits: {
enabled: false
},
+ legend: {
+ enabled: false
+ },
+ plotOptions: {
+ series: {
+ fillOpacity: 0.12,
+ lineWidth: 1,
+ marker: {
+ enabled: true, //false false的时候就不会突出显示点
+ lineColor: '#31B6AD',
+ lineWidth: 1,
+ radius: 3, // 点的大小
+ fillColor: '#FFFFFF' // 设置点中间填充的颜色
+ },
+ shadow: false
+ //threshold: null
+ }
+ },
+ //series: [{
+ // data: [6.0, 5.9, 5.5, 4.5, 6.2, 6.5, 5.2, 6.0,
+ // 5.9, 5.5, 4.5, 6.2, 6.5, 5.2, 6.0, 5.9,
+ // 5.5, 4.5, 6.2, 6.5],
+ // pointStart: start_date_UTC_time,
+ // pointInterval: 1 * 24 * 3600 * 1000 // one day
+ //}],
title: {
- text: ' '
+ text: null
+ },
+ tooltip: {
+ //formatter: function() {
+ // return '<span style="color:#969696;font-weight:bold;">' + Highcharts.dateFormat('%b %e', this.x) + '</span>' +'<br />' + '<span style="color:#464646;font-weight:bold;">' + this.y + 'mmol/L' + '</span>' + '<br />' + 'click for more info';
+ //},
+ // positioner: function (boxWidth, boxHeight, point) {
+ // return { x: point.plotX+80, y: point.plotY-20 };
+ // },
+ style: {
+ padding: '7px'
+ },
+ borderColor: '#EAEAEA'
},
- colors: ['#31B6AD'],
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
@@ -34,13 +69,13 @@ $(document).ready(function(){
step: 2,
maxStaggerLines: 1
},
- tickInterval: (4 * 24 * 3600 * 1000),
+ tickInterval: (4 * 24 * 3600 * 1000), // 4 days
tickColor: '#FFFFFF'
},
yAxis: {
- title: {
- text: ''
- },
+ //title: {
+ // text: ''
+ //},
allowDecimals: false,
endOnTick: false,
tickInterval: 1,
@@ -50,36 +85,31 @@ $(document).ready(function(){
gridLineWidth: 1,
minPadding: 0.3,
maxPadding: 1.2
+ }
+ });
+});
+// }}}
+
+$(document).ready(function(){
+ var startDate = '2013-07-13';
+ startDate = new Date(startDate.replace(/-/g,"/"));
+ var start_date_UTC_time = startDate.getTime() - startDate.getTimezoneOffset() * 60 * 1000;
+ var chart3 = new Highcharts.Chart({
+ chart: {
+ renderTo: 'chart_3'
},
- legend: {
- enabled: false
+ yAxis: {
+ title: {
+ text: ''
+ }
},
tooltip: {
formatter: function() {
return '<span style="color:#969696;font-weight:bold;">' + Highcharts.dateFormat('%b %e', this.x) + '</span>' +'<br />' + '<span style="color:#464646;font-weight:bold;">' + this.y + 'mmol/L' + '</span>' + '<br />' + 'click for more info';
- },
+ }
// positioner: function (boxWidth, boxHeight, point) {
// return { x: point.plotX+80, y: point.plotY-20 };
// },
- style: {
- padding: '7px'
- },
- borderColor: '#EAEAEA'
- },
- plotOptions: {
- series: {
- marker: {
- enabled: true, //false false的时候就不会突出显示点
- lineColor: '#31B6AD',
- lineWidth: 1,
- radius: 3, // 点的大小
- fillColor: '#FFFFFF' // 设置点中间填充的颜色
- },
- fillOpacity: 0.12,
- lineWidth: 1,
- threshold: null,
- shadow: false
- }
},
series: [{
data: [6.0, 5.9, 5.5, 4.5, 6.2, 6.5, 5.2, 6.0, 5.9, 5.5, 4.5, 6.2, 6.5, 5.2, 6.0, 5.9, 5.5, 4.5, 6.2, 6.5],
@@ -254,7 +284,8 @@ function redraw_chart(detail_chart, start, end){
url: indicator_url + 'ajax/get_card_data_chart',
data: 'card_detail_id='+card_detail_id+'&start='+start+'&end='+end+'&time='+time,
dataType: 'json',
- success: function(dataJson) { //每一天都要有数据,否则x轴刻度时间对不上
+ success: function(dataJson) {
+ //每一天都要有数据,否则x轴刻度时间对不上
var startDateLogFormat = new Date(start.replace(/-/g,"/"));
var start_date_log_UTC_time = startDateLogFormat.getTime() - startDateLogFormat.getTimezoneOffset() * 60 * 1000;
var pointStart = start_date_log_UTC_time;
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);
}
});