123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- function Follow(obj,data,url){
- if(obj.hasClass('active'))
- {$.ajax ({
- type : "DELETE",
- url : url,
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- obj.text('关注').removeClass('active');
- } else
- {alert('fail');}}});
- }else
- {$.ajax ({
- type : "POST",
- url : url,
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- obj.text('取消关注').addClass('active');
- } else
- {alert('fail');}
- }});
- }
- }
- $(document).ready(function(){
- $('button.tagfollow').click(function(){
- var _$this = $(this);
- var url = "/user/follow/tag";
- var data = JSON.stringify({
- id:_$this.attr("id"),
- });
- Follow(_$this,data,url);
- });
- $('button.topicfollow').click(function(){
- var _$this = $(this);
- var url = "/user/follow/topic";
- var data = JSON.stringify({
- id:_$this.attr("id"),
- });
- Follow(_$this,data,url);
- });
- $('button.collectfollow').click(function(){
- var _$this = $(this);
- var url = "/user/follow/collect";
- var data = JSON.stringify({
- id:_$this.attr("id"),
- });
- Follow(_$this,data,url);
- });
- $('button.userfollow').click(function(){
- var _$this = $(this);
- var url = "/user/follow/user";
- var data = JSON.stringify({
- id:_$this.attr("id"),
- });
- Follow(_$this,data,url);
- });
- });
- function DoCollect(collectData) {
- $(document).ready(function(){
- $('button#edit-collect-form').click(function() {
- var data = JSON.stringify({
- name:$('#name').val(),
- description:$('#description').val(),
- is_privacy:$("input[name='is_privacy']:checked").val()
- });
- $.ajax ({
- type : "PUT",
- url : collectData.collect_action_url,
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- window.location =collectData.collect_action_url ;
- }
- }
- });
- });
- $('button#delete-collect-form').click(function() {
- $.ajax ({
- type : "DELETE",
- url : collectData.collect_action_url,
- data:JSON.stringify(),
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- window.location = collectData.collect_url;
- }
- }
- });
- });
- $('#delete-from-collect').click(function() {
- var _$this = $(this);
- var topicId = _$this.attr('data-id');
- var data = JSON.stringify({
- topicId:topicId
- });
- $.ajax ({
- type : "DELETE",
- url : collectData.delete_detail_action_url,
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- _$this.parent().remove();
- }
- }
- });
- });
- });
- }
|