app.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. app=angular.module('app', []);
  2. app.controller('main', function($scope,$http,$interval) {
  3. $scope.list=[];
  4. $scope.book="";
  5. $scope.extension="";
  6. $scope.activeTab = 'SEARCH';
  7. $scope.getList = function() {
  8. $http.get("http://192.168.1.7/test/").then(
  9. function(data) {
  10. /*
  11. data.data=data.data.map(function(el) {
  12. if (el.STATUS!="DISCONNECTED")
  13. el.STATUS=el.STATUS+" "+el.ELAPSED;
  14. return el;
  15. });
  16. */
  17. $scope.list=data.data;
  18. },
  19. function(data){
  20. console.log("error");
  21. });
  22. }
  23. $scope.getList();
  24. $scope.download = function(book) {
  25. $http.post("http://192.168.1.7/test/?adasasd",{"type":"BOOK","book":book}).then(
  26. function(data) {
  27. $scope.getList();
  28. },
  29. function(data){
  30. console.log("error");
  31. console.log(data);
  32. });
  33. };
  34. $scope.searchBook = function(book,extension){
  35. $http.post("http://192.168.1.7/test/?ewqewqewq", {"type":"search","book":book,"extension":extension}).then(
  36. function(data) {
  37. console.log("success");
  38. $scope.getList();
  39. },
  40. function(data){
  41. console.log("err");
  42. });
  43. };
  44. $scope.isActiveTab = function(tab){
  45. return $scope.activeTab === tab;
  46. }
  47. $scope.changeTab = function(tab){
  48. $scope.activeTab = tab;
  49. }
  50. $scope.limit = {};
  51. $scope.showMore = function(l){
  52. $scope.limit[l.ID] = $scope.limit[l.ID] ? undefined : l.OUT.length;
  53. }
  54. $interval($scope.getList, 1000);
  55. });