pixelfed/public/js/search.js

28 lines
32 KiB
JavaScript
Raw Normal View History

2024-07-10 06:11:42 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([["/js/search"],{"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=script&lang=js":
/*!**************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=script&lang=js ***!
\**************************************************************************************************************************************************************************************************************/(t,s,e)=>{"use strict";e.r(s),e.d(s,{default:()=>i});var a=e(/*! jquery */"./node_modules/jquery/dist/jquery.js");function r(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,s){if(!t)return;if("string"==typeof t)return l(t,s);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return l(t,s)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(t,s){(null==s||s>t.length)&&(s=t.length);for(var e=0,a=new Array(s);e<s;e++)a[e]=t[e];return a}const i={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(){a(".search-bar input").val(this.query)},updated:function(){a('[data-toggle="tooltip"]').tooltip()},methods:{bootSearch:function(){var t=this.searchLexer();this.analysis=t,this.fetchSearchResults(),axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()}))},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)},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>1?arguments[1]:void 0;switch(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"hashtag"){case"hashtag":default:return t.url+"?src=search";case"profile":return 1==t.entity.local?t.url:"/i/web/profile/_/"+t.entity.id}},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",{params:{q:this.query,src:"metro",v:this.searchVersion,scope:"remote"}}).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.profiles.length&&(s.analysis="profile"),s.results.statuses.length&&(s.analysis="remotePost"),s.loading=!1})).catch((function(t){s.loading=!1,s.networkError=!0}));break;case"hashtag":axios.get("/api/search",{params:{q:this.query.slice(1),src:"metro",v:this.searchVersion,scope:"hashtag"}}).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.loading=!1})).catch((function(t){s.loading=!1,s.networkError=!0}));break;case"profile":axios.get("/api/search",{params:{q:this.query,src:"metro",v:this.searchVersion,scope:"profile"}}).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.loading=!1})).catch((function(t){s.loading=!1,s.networkError=!0}));break;case"webfinger":axios
/*!*************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=template&id=37623187&scoped=true ***!
\*************************************************************************************************************************************************************************************************************************************************************************************************************/(t,s,e)=>{"use strict";e.r(s),e.d(s,{render:()=>a,staticRenderFns:()=>r});var a=function(){var t=this,s=t._self._c;return s("div",{staticClass:"container"},[t.loading?s("div",{staticClass:"pt-5 text-center"},[t._m(0)]):t._e(),t._v(" "),t.networkError?s("div",{staticClass:"pt-5 text-center"},[t._m(1)]):t._e(),t._v(" "),t.loading||t.networkError?t._e():s("div",{staticClass:"mt-5"},["all"==t.analysis?s("div",{staticClass:"row"},[s("div",{staticClass:"col-12 d-flex justify-content-between align-items-center"},[s("p",{staticClass:"h5 font-weight-bold text-dark"},[t._v("Showing results for "),s("i",[t._v(t._s(t.query))])]),t._v(" "),t.placesSearchEnabled?s("div",{attrs:{title:"Show Places","data-toggle":"tooltip"}},[t.results.placesPagination.total>0?s("span",{staticClass:"badge badge-light mr-2 p-1 border",staticStyle:{"margin-top":"-5px"}},[t._v(t._s(t.formatCount(t.results.placesPagination.total)))]):t._e(),t._v(" "),s("div",{staticClass:"d-inline custom-control custom-switch"},[s("input",{directives:[{name:"model",rawName:"v-model",value:t.showPlaces,expression:"showPlaces"}],staticClass:"custom-control-input",attrs:{type:"checkbox",id:"placesSwitch"},domProps:{checked:Array.isArray(t.showPlaces)?t._i(t.showPlaces,null)>-1:t.showPlaces},on:{change:function(s){var e=t.showPlaces,a=s.target,r=!!a.checked;if(Array.isArray(e)){var l=t._i(e,null);a.checked?l<0&&(t.showPlaces=e.concat([null])):l>-1&&(t.showPlaces=e.slice(0,l).concat(e.slice(l+1)))}else t.showPlaces=r}}}),t._v(" "),t._m(2)])]):t._e()]),t._v(" "),t._m(3),t._v(" "),t.placesSearchEnabled&&t.showPlaces?s("div",{staticClass:"col-12 mb-4"},[s("div",{staticClass:"mb-4"},[s("p",{staticClass:"text-secondary small font-weight-bold"},[t._v("PLACES "),s("span",{staticClass:"pl-1 text-lighter"},[t._v("("+t._s(t.results.placesPagination.total)+")")])])]),t._v(" "),t.results.places.length?s("div",{staticClass:"mb-5"},[t._l(t.results.places,(function(e,a){return s("a",{staticClass:"mr-3 pr-4 d-inline-block text-decoration-none",attrs:{href:t.buildUrl("places",e)}},[s("div",{staticClass:"pb-2"},[s("div",{staticClass:"media align-items-center py-2"},[s("div",{staticClass:"media-body text-truncate"},[s("p",{staticClass:"mb-0 text-break text-dark font-weight-bold",attrs:{"data-toggle":"tooltip",title:e.value}},[s("i",{staticClass:"fas fa-map-marker-alt text-lighter mr-2"}),t._v(" "+t._s(e.value)+"\n\t\t\t\t\t\t\t\t\t")])])])])])})),t._v(" "),20==t.results.places.length||t.placesCursor>0?s("p",{staticClass:"text-center mt-3"},[1==t.placesCursor?s("a",{staticClass:"btn btn-outline-secondary btn-sm font-weight-bold py-0 disabled",attrs:{href:"#",disabled:""}},[s("i",{staticClass:"fas fa-chevron-left mr-2"}),t._v(" Previous\n\t\t\t\t\t\t")]):s("a",{staticClass:"btn btn-outline-secondary btn-sm font-weight-bold py-0",attrs:{href:"#"},on:{click:function(s){return s.preventDefault(),t.placesPrevPage()}}},[s("i",{staticClass:"fas fa-chevron-left mr-2"}),t._v(" Previous\n\t\t\t\t\t\t")]),t._v(" "),s("span",{staticClass:"mx-4 small text-lighter"},[t._v(t._s(t.placesCursor)+"/"+t._s(t.results.placesPagination.last_page))]),t._v(" "),t.placesCursor!==t.results.placesPagination.last_page?s("a",{staticClass:"btn btn-primary btn-sm font-weight-bold py-0",attrs:{href:"#"},on:{click:function(s){return s.preventDefault(),t.placesNextPage()}}},[t._v("\n\t\t\t\t\t\t\tNext "),s("i",{staticClass:"fas fa-chevron-right ml-2"})]):s("a",{staticClass:"btn btn-primary btn-sm font-weight-bold py-0 disabled",attrs:{href:"#",disabled:""}},[t._v("\n\t\t\t\t\t\t\tNext "),s("i",{staticClass:"fas fa-chevron-right ml-2"})])]):t._e()],2):s("div",[s("div",{staticClass:"border py-3 text-center font-weight-bold"},[t._v("No results found")])])]):t._e(),t._v(" "),s("div",{staticClass:"col-md-3"},[s("div",{staticClass:"mb-4"
/*!***************************************!*\
!*** ./resources/assets/js/search.js ***!
\***************************************/(t,s,e)=>{Vue.component("search-results",e(/*! ./components/SearchResults.vue */"./resources/assets/js/components/SearchResults.vue").default)},"./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css":
/*!*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css ***!
\*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/(t,s,e)=>{"use strict";e.r(s),e.d(s,{default:()=>l});var a=e(/*! ../../../../node_modules/laravel-mix/node_modules/css-loader/dist/runtime/api.js */"./node_modules/laravel-mix/node_modules/css-loader/dist/runtime/api.js"),r=e.n(a)()((function(t){return t[1]}));r.push([t.id,"\n.result-card[data-v-37623187] {\n\ttext-decoration: none;\n}\n.result-card .media[data-v-37623187]:hover {\n\tbackground: #EDF2F7;\n}\n@media (min-width: 1200px) {\n.container[data-v-37623187] {\n\t\tmax-width: 995px;\n}\n}\n",""]);const l=r},"./node_modules/style-loader/dist/cjs.js!./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css":
/*!*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** ./node_modules/style-loader/dist/cjs.js!./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css ***!
\*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/(t,s,e)=>{"use strict";e.r(s),e.d(s,{default:()=>o});var a=e(/*! !../../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js */"./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"),r=e.n(a),l=e(/*! !!../../../../node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!../../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../../node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css */"./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css"),i={insert:"head",singleton:!1};r()(l.default,i);const o=l.default.locals||{}},"./resources/assets/js/components/SearchResults.vue":
/*!**********************************************************!*\
!*** ./resources/assets/js/components/SearchResults.vue ***!
\**********************************************************/(t,s,e)=>{"use strict";e.r(s),e.d(s,{default:()=>o});var a=e(/*! ./SearchResults.vue?vue&type=template&id=37623187&scoped=true */"./resources/assets/js/components/SearchResults.vue?vue&type=template&id=37623187&scoped=true"),r=e(/*! ./SearchResults.vue?vue&type=script&lang=js */"./resources/assets/js/components/SearchResults.vue?vue&type=script&lang=js"),l={};for(const t in r)"default"!==t&&(l[t]=()=>r[t]);e.d(s,l);e(/*! ./SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css */"./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css");var i=(0,e(/*! !../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */"./node_modules/vue-loader/lib/runtime/componentNormalizer.js").default)(r.default,a.render,a.staticRenderFns,!1,null,"37623187",null);i.options.__file="resources/assets/js/components/SearchResults.vue";const o=i.exports},"./resources/assets/js/components/SearchResults.vue?vue&type=script&lang=js":
/*!**********************************************************************************!*\
!*** ./resources/assets/js/components/SearchResults.vue?vue&type=script&lang=js ***!
\**********************************************************************************/(t,s,e)=>{"use strict";e.r(s),e.d(s,{default:()=>l});var a=e(/*! -!../../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./SearchResults.vue?vue&type=script&lang=js */"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=script&lang=js"),r={};for(const t in a)"default"!==t&&(r[t]=()=>a[t]);e.d(s,r);const l=a.default},"./resources/assets/js/components/SearchResults.vue?vue&type=template&id=37623187&scoped=true":
/*!****************************************************************************************************!*\
!*** ./resources/assets/js/components/SearchResults.vue?vue&type=template&id=37623187&scoped=true ***!
\****************************************************************************************************/(t,s,e)=>{"use strict";e.r(s);var a=e(/*! -!../../../../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!../../../../node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./SearchResults.vue?vue&type=template&id=37623187&scoped=true */"./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=template&id=37623187&scoped=true"),r={};for(const t in a)"default"!==t&&(r[t]=()=>a[t]);e.d(s,r)},"./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css":
/*!******************************************************************************************************************!*\
!*** ./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css ***!
\******************************************************************************************************************/(t,s,e)=>{"use strict";e.r(s);var a=e(/*! -!../../../../node_modules/style-loader/dist/cjs.js!../../../../node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!../../../../node_modules/vue-loader/lib/loaders/stylePostLoader.js!../../../../node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css */"./node_modules/style-loader/dist/cjs.js!./node_modules/laravel-mix/node_modules/css-loader/dist/cjs.js??clonedRuleSet-14.use[1]!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-14.use[2]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/assets/js/components/SearchResults.vue?vue&type=style&index=0&id=37623187&scoped=true&lang=css"),r={};for(const t in a)"default"!==t&&(r[t]=()=>a[t]);e.d(s,r)}},t=>{t.O(0,["/js/vendor"],(()=>{return s="./resources/assets/js/search.js",t(t.s=s);var s}));t.O()}]);