OSDN Git Service

8f128eee47228bd9b268b44900cb95534f97926c
[embrj/master.git] / js / nexus.js
1 $(function(){\r
2                 $("#analyze").click(function(){\r
3                                 var user_1 = $.trim($("#user_1").val());\r
4                                 var user_2 = $.trim($("#user_2").val());\r
5                                 if(user_1 === $.trim($("#sideid").text())){\r
6                                         $("#descr").animate({opacity: 0}, 200, function(){\r
7                                         $("#descr").html("Due to the the limitation of API, you cannot enter your name in the first blank!").css("color", "#83161F").animate({opacity: 1}, 100);\r
8                                         });\r
9                                         return;\r
10                                 };\r
11                                 if(user_1 !== '' & user_2 !== ''){\r
12                                         $("#analyze").val("").addClass("loading");\r
13                                         $.ajax({\r
14                                                         url: "ajax/getRelationship.php" + "?target=" + user_1 + "&source=" + user_2,\r
15                                                         type: "GET",\r
16                                                         dataType: "text",\r
17                                                         data: "target=" + user_1 + "&source=" + user_2,\r
18                                                         success: function(msg) {\r
19                                                                 msg = $.trim(msg);\r
20                                                                 if(msg.length > 0 && msg !== "error") {\r
21                                                                         $("#analyze").val("Analyze").removeClass("loading");\r
22                                                                         $("#descr").html("Rabr Nexus is a tool helps you analyze relationships between you or the others.").css("color", "#333333");\r
23                                                                         $("#result").animate({opacity: 0}, 500, function(){\r
24                                                                         $("#result").removeClass("intro").html(msg).animate({opacity: 1}, 500);\r
25                                                                         });\r
26                                                                 }else{\r
27                                                                         $("#descr").animate({opacity: 0}, 200, function(){\r
28                                                                         $("#descr").html("Something went wrong, please try again!").css("color", "#83161F").animate({opacity: 1}, 100);\r
29                                         });\r
30                                                                 }\r
31                                                         },\r
32                                                         error: function() {\r
33                                                                         $("#descr").animate({opacity: 0}, 200, function(){\r
34                                                                         $("#descr").html("Something went wrong, please try again!").css("color", "#83161F").animate({opacity: 1}, 100);\r
35                                         });\r
36                                                         }\r
37                                                 });\r
38                                 }\r
39                         });\r
40         });