123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- function Follow(obj,data){
- if(obj.hasClass('active'))
- {$.ajax ({
- type : "DELETE",
- url : "/user/follow",
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- obj.text('关注').removeClass('active');
- }
- else
- {alert('asd');}}});
- }else
- {$.ajax ({
- type : "POST",
- url : "/user/follow",
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge === true)
- {
- obj.text('取消关注').addClass('active');
- } else
- {alert('asd');}
- }});
- }
- }
- $(document).ready(function(){
- $('button.tagfollow').click(function(){
- var _$this = $(this);
- var data = JSON.stringify({
- id:_$this.attr("id"),
- type:'tag'
- });
- Follow(_$this,data);
- });
- $('button.topicfollow').click(function(){
- var _$this = $(this);
- var data = JSON.stringify({
- id:_$this.attr("id"),
- type:'topic'
- });
- Follow(_$this,data);
- });
- $('button.collectfollow').click(function(){
- var _$this = $(this);
- var data = JSON.stringify({
- id:_$this.attr("id"),
- type:'collect'
- });
- Follow(_$this,data);
- });
- });
- 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.edit_url,
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge == true)
- {
- window.location =collectData.edit_url ;
- }
- }
- });
- });
- $('button#delete-collect-form').click(function() {
- $.ajax ({
- type : "DELETE",
- url : collectData.delete_url,
- data:JSON.stringify(),
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge == true)
- {
- window.location = collectData.url;
- }
- }
- });
- });
- $('#delete-from-collect').click(function() {
- var _$this = $(this);
- var topicId = _$this.attr('data-id');
- var collectId = collectData.collectId;
- var data = JSON.stringify({
- collectId:collectId,
- topicId:topicId
- });
- $.ajax ({
- type : "DELETE",
- url : collectData.delete,
- data:data,
- contentType: 'application/json;charset=UTF-8',
- success: function(result) {
- if (result.judge == true)
- {
- _$this.parent().remove();
- }
- }
- });
- });
- });
- }
|