1
0
Fork 0
pixelfed/public/js/search.js

1 line
28 KiB
JavaScript
Raw Normal View History

2020-11-18 21:41:37 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[21],{9:function(t,s,e){t.exports=e("EnJJ")},"9tPo":function(t,s){t.exports=function(t){var s="undefined"!=typeof window&&window.location;if(!s)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var e=s.protocol+"//"+s.host,a=e+s.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,s){var r,i=s.trim().replace(/^"(.*)"$/,(function(t,s){return s})).replace(/^'(.*)'$/,(function(t,s){return s}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(i)?t:(r=0===i.indexOf("//")?i:0===i.indexOf("/")?e+i:a+i.replace(/^\.\//,""),"url("+JSON.stringify(r)+")")}))}},EnJJ:function(t,s,e){Vue.component("search-results",e("IpYn").default)},I1BE:function(t,s){t.exports=function(t){var s=[];return s.toString=function(){return this.map((function(s){var e=function(t,s){var e=t[1]||"",a=t[3];if(!a)return e;if(s&&"function"==typeof btoa){var r=(n=a,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(n))))+" */"),i=a.sources.map((function(t){return"/*# sourceURL="+a.sourceRoot+t+" */"}));return[e].concat(i).concat([r]).join("\n")}var n;return[e].join("\n")}(s,t);return s[2]?"@media "+s[2]+"{"+e+"}":e})).join("")},s.i=function(t,e){"string"==typeof t&&(t=[[null,t,""]]);for(var a={},r=0;r<this.length;r++){var i=this[r][0];"number"==typeof i&&(a[i]=!0)}for(r=0;r<t.length;r++){var n=t[r];"number"==typeof n[0]&&a[n[0]]||(e&&!n[2]?n[2]=e:e&&(n[2]="("+n[2]+") and ("+e+")"),s.push(n))}},s}},IpYn:function(t,s,e){"use strict";e.r(s);function a(t){return function(t){if(Array.isArray(t)){for(var s=0,e=new Array(t.length);s<t.length;s++)e[s]=t[s];return e}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var r={props:["query","profileId"],data:function(){return{loading:!0,networkError:!1,results:{hashtags:[],profiles:[],statuses:[],places:[]},filters:{hashtags:!0,profiles:!0,statuses:!0},analysis:"profile",showPlaces:!1,placesCursor:1,placesCache:[],placesSearchEnabled:!1,searchVersion:2}},beforeMount:function(){this.bootSearch()},mounted:function(){$(".search-bar input").val(this.query)},updated:function(){$('[data-toggle="tooltip"]').tooltip()},methods:{bootSearch:function(){var t=this.searchLexer();this.analysis=t,this.fetchSearchResults()},fetchSearchResults:function(){if("remote"==this.analysis){var t=this.query;if(new URL(t).host===window.location.host)return void(window.location.href=t)}this.searchContext(this.analysis)},followProfile:function(t,s){var e=this;this.loading=!0,axios.post("/i/follow",{item:t.entity.id}).then((function(a){return 1==t.entity.local?void e.fetchSearchResults():(e.loading=!1,void(e.results.profiles[s].entity.follow_request=!0))})).catch((function(t){t.response.data.message&&swal("Error",t.response.data.message,"error")}))},searchLexer:function(){var t=this.query;return t.startsWith("#")?"hashtag":2==(t.match(/@/g)||[]).length?"webfinger":t.startsWith("@")?"profile":t.startsWith("https://")?"remote":"all"},buildUrl:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"hashtag",s=arguments.length>1?arguments[1]:void 0;switch(t){case"hashtag":return s.url+"?src=search";case"profile":return 1==s.entity.local?s.url:"/i/web/profile/_/"+s.entity.id;default:return s.url+"?src=search"}},searchContext:function(t){var s=this;switch(t){case"all":axios.get("/api/search",{params:{q:this.query,src:"metro",v:this.searchVersion,scope:"all"}}).then((function(t){var e=t.data;s.results.hashtags=e.hashtags?e.hashtags:[],s.results.profiles=e.profiles?e.profiles:[],s.results.statuses=e.posts?e.posts:[],s.results.places=e.places?e.places:[],s.placesCache=e.places,s.results.placesPagination=e.placesPagination?e.placesPagination:[],s.loading=!1})).catch((function(t){s.loading=!1,s.networkError=!0}));break;case"remote":axios.get("/api/search",{