diff --git a/app/controllers/main.controller.js b/app/controllers/main.controller.js index bb55960..3cc5b0e 100644 --- a/app/controllers/main.controller.js +++ b/app/controllers/main.controller.js @@ -1,67 +1,80 @@ module.exports = function($scope, pageViews, searchService) { + + $scope.search = { + str: "", + list: [] + }; + $scope.groups = [ { 'name' : 'Dogs', 'breeds': [ 'Labrador', 'Retriever', 'Boxer', 'Cocker Spaniel' ]}, { 'name': 'Cats', 'breeds': [ 'Russian blue', 'Ragdoll', 'Norwegian Forest Cat' ]}, { 'name': 'Fish', 'breeds': [ 'Salmon', 'Pike', 'Trout', 'Bass' ]} ]; - $scope.searchstr = ""; - $scope.projects = [ // TODO: Proper externalization and language checking {name: "Wikipedia", url: "$lang$.wikipedia", multilang: true}, {name: "Wikiversity", url: "$lang$.wikiversity", multilang: true}, {name: "Wikisource", url: "$lang$.wikisource", multilang: true}, {name: "Wikinews", url: "$lang$.wikinews", multilang: true}, {name: "Wikibooks", url: "$lang$.wikibooks", multilang: true}, {name: "Wikiquote", url: "$lang$.wikiquote", multilang: true}, {name: "Wikispecies", url: "species.wikimedia", multilang: false}, {name: "Wikivoyage", url: "$lang$.wikivoyage", multilang: true}, {name: "Wikidata", url: "www.wikidata", multilang: false}, {name: "Wikicommons", url: "commons.wikimedia", multilang: false}, {name: "Metawiki", url: "meta.wikimedia", multilang: false} ]; $scope.chosen = { proj: $scope.projects[0].name, lang: "Svenska" }; $scope.changeChosen = function(name, dropdown){ $scope.chosen[dropdown] = name; }; + $scope.$watch('search.str.length', function () { + + if($scope.search.str.length <= 0) { + $scope.search.list = []; + return; + } + + searchService.query({ + namespace: 'sv.wikipedia', //TODO + str: $scope.search.str + }).then(function(data) { + console.log(data.data); + $scope.search.list = data.data; + }); + }); + pageViews.query({ project: "en.wikipedia", article: "Dog", from: "20160101", to: "20160110", }).$promise.then(function(result) { console.log(result.article); }); - searchService.query({ - namespace: 'sv.wikipedia', - str: "Turing priset" - }).then(function(data) { - console.log(data.data); - $scope.search = data.data; - }); }; diff --git a/app/index.html b/app/index.html index 0aad560..73c7c4d 100644 --- a/app/index.html +++ b/app/index.html @@ -1,70 +1,77 @@ Wikistats
+
+
+
- +
+
    +
  • {{ s }}
  • +
+

    {{animal.name}}

  • {{breed}}