|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- Vue.component('search',{
- template: `
- <form class="om-searchbar" @submit.prevent="search()">
- <b-field>
- <b-autocomplete
- v-model="searchtext"
- @keydown.native.enter="search"
- :data="filteredDataArray"
- placeholder="suche..."
- icon="magnify"
- @select="option => selected = option">
- </b-autocomplete>
- <button class="clearButton" @click="clear">x</button>
- </b-field>
- </form>`,
- data: function() {
- return{
- searchtext: "",
- selected: [],
- taglist: data,
- };
- },
- computed:{
- filteredDataArray() {
- return this.taglist.filter((option) => {
- return option
- .toString()
- .toLowerCase()
- .indexOf(this.searchtext.toLowerCase()) >= 0
- })
- }
- },
- methods: {
- getFilteredTags(text) {
- this.taglist = data.filter((option) => {
- return option
- .toString()
- .toLowerCase()
- .indexOf(text.toLowerCase()) >= 0
- })
- this.search();
- },
- search: function() {
- searching(this.searchtext);
- },
- saveTagsToArray: function() {
- tagArray = this.selected;
- // console.info(tagArray);
- },
- list_messages: function() {
- messages();
- },
- list_tags: function () {
- $.ajax({url: "api/tag/ids", method: "GET"})
- .done(jd => {
- // NICHT SO wg. Vue: _messagelist = jd;
- if(data == ""){
- _taglist.splice(0, _taglist.length);
- _taglist.push.apply(_taglist, jd);
- // console.log("tag: jd: " + jd);
- for (var e in jd) {
- if (!_tags[jd[e]]) {
- get_insert_tag(jd[e]);
- }
- }
- }
- }).fail(function (e, f, g) {
- console.log("err: " + e + f + g);
- });
- },
- clear: function() {
- //_isSearchActiv = false;
- this.searchtext = "";
- this.list_messages();
- //router.push('/files')
- //router.push('/home')
- $("#escape-search-link").css("visibility", "hidden");
- $("#subscribe-btn").css("visibility", "hidden");
- },
- },
- mounted: function() {
- //this.search();
- this.list_tags();
- },
- });
-
- // Global Functions !!!
- function get_insert_tag(id) {
- $.ajax({
- url: "api/tag/id/" + id,
- method: "GET"
- }).done(function(tag) {
- data.push("#" + tag.name);
- }).fail(function(e, f, g) {
- console.log("cannot load " + id + ".json: " + e + f + g);
- })
- }
-
- function searching(searchtext) {
- _isSearchActiv = true;
- $("#escape-search-link").css("visibility", "visible");
- if(_taglist.indexOf(searchtext.replace(/#/g, '')) > -1){
- var btnString = "#" + searchtext.replace(/#/g, '') + " abonnieren";
- $("#btn-text").text(btnString);
- $("#subscribe-btn").css("visibility", "visible");
- }else{
- $("#subscribe-btn").css("visibility", "hidden");
- }
-
-
- $.ajax({
- url: "api/msg/search/" + searchtext.replace(/#/g, ''),
- method: "GET"
- }).done(jd => {
- // NICHT SO wg. Vue: _messagelist = jd;
- _messagelist.splice(0, _messagelist.length);
- _messagelist.push.apply(_messagelist, jd);
- //console.log("jd: "+jd);
- for (var e in jd) {
- if (!_messages[jd[e]]) {
- get_insert_message(jd[e]);
- }
- }
- }).fail(function(e, f, g) {
- console.log("searching: err: " + e + f + g);
- })
-
- }
-
- function messages() {
- $.ajax({
- url: "api/msg/ids",
- method: "GET"
- })
- .done(jd => {
- // NICHT SO wg. Vue: _messagelist = jd;
- _messagelist.splice(0, _messagelist.length);
- _messagelist.push.apply(_messagelist, jd);
- //console.log("jd: "+jd);
- for (var e in jd) {
- if (!_messages[jd[e]]) {
- get_insert_message(jd[e]);
- }
- }
- }).fail(function(e, f, g) {
- console.log("list_msg: err: " + e + f + g);
- });
- }
|