1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-26 09:46:49 +00:00
pixelfed/public/js/search.js

1 line
19 KiB
JavaScript
Raw Normal View History

2020-04-12 05:14:43 +00:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[20],{"51wX":function(t,e,s){var r=s("zZx1");"string"==typeof r&&(r=[[t.i,r,""]]);var a={hmr:!0,transform:void 0,insertInto:void 0};s("aET+")(r,a);r.locals&&(t.exports=r.locals)},9:function(t,e,s){t.exports=s("EnJJ")},"9tPo":function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var s=e.protocol+"//"+e.host,r=s+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var a,n=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(n)?t:(a=0===n.indexOf("//")?n:0===n.indexOf("/")?s+n:r+n.replace(/^\.\//,""),"url("+JSON.stringify(a)+")")}))}},EnJJ:function(t,e,s){Vue.component("search-results",s("IpYn").default)},I1BE:function(t,e){t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var s=function(t,e){var s=t[1]||"",r=t[3];if(!r)return s;if(e&&"function"==typeof btoa){var a=(i=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),n=r.sources.map((function(t){return"/*# sourceURL="+r.sourceRoot+t+" */"}));return[s].concat(n).concat([a]).join("\n")}var i;return[s].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+s+"}":s})).join("")},e.i=function(t,s){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},a=0;a<this.length;a++){var n=this[a][0];"number"==typeof n&&(r[n]=!0)}for(a=0;a<t.length;a++){var i=t[a];"number"==typeof i[0]&&r[i[0]]||(s&&!i[2]?i[2]=s:s&&(i[2]="("+i[2]+") and ("+s+")"),e.push(i))}},e}},IpYn:function(t,e,s){"use strict";s.r(e);var r={props:["query","profileId"],data:function(){return{loading:!0,networkError:!1,results:{hashtags:[],profiles:[],statuses:[]},filters:{hashtags:!0,profiles:!0,statuses:!0},analysis:"profile"}},beforeMount:function(){this.bootSearch()},mounted:function(){$(".search-bar input").val(this.query)},methods:{bootSearch:function(){var t=this.searchLexer();this.analysis=t,this.fetchSearchResults()},fetchSearchResults:function(){this.searchContext(this.analysis)},followProfile:function(t,e){var s=this;this.loading=!0,axios.post("/i/follow",{item:t.entity.id}).then((function(r){return 1==t.entity.local?void s.fetchSearchResults():(s.loading=!1,void(s.results.profiles[e].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("@")||-1!=t.search("@")?"profile":t.startsWith("https://")?"remote":"all"},buildUrl:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"hashtag",e=arguments.length>1?arguments[1]:void 0;switch(t){case"hashtag":return e.url+"?src=search";case"profile":return 1==e.entity.local?e.url:"/i/web/profile/_/"+e.entity.id;default:return e.url+"?src=search"}},searchContext:function(t){var e=this;switch(t){case"all":axios.get("/api/search",{params:{q:this.query,src:"metro",v:1,scope:"all"}}).then((function(t){var s=t.data;e.results.hashtags=s.hashtags?s.hashtags:[],e.results.profiles=s.profiles?s.profiles:[],e.results.statuses=s.posts?s.posts:[],e.loading=!1})).catch((function(t){e.loading=!1,console.log(t),e.networkError=!0}));break;case"hashtag":axios.get("/api/search",{params:{q:this.query.slice(1),src:"metro",v:1,scope:"hashtag"}}).then((function(t){var s=t.data;e.results.hashtags=s.hashtags?s.hashtags:[],e.results.profiles=s.profiles?s.profiles:[],e.results.statuses=s.posts?s.posts:[],e.loading=!1})).catch((function(t){e.loading=!1,console.log(t),e.networkError=!0}));break;case"profile":axios.get("/api/search",{params:{q:this.query,src:"metro",v:1,scope:"profile"}}).then((function(t){var s=t.data;e.results.hashtags=s.hashtags?s.hashtags:[],e.results.profiles=s.profiles?s.profiles:[],e.results.statuses=s.posts?s