diff --git a/js/dist/forum.js b/js/dist/forum.js index 72ce001..2328e37 100644 --- a/js/dist/forum.js +++ b/js/dist/forum.js @@ -1,2 +1,2 @@ -(()=>{var t={n:o=>{var a=o&&o.__esModule?()=>o.default:()=>o;return t.d(a,{a}),a},d:(o,a)=>{for(var e in a)t.o(a,e)&&!t.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:a[e]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o);const a=flarum.core.compat["forum/app"];var e=t.n(a);const r=flarum.core.compat["forum/components/DiscussionList"];var s=t.n(r);const n=flarum.core.compat["common/extend"],d=flarum.core.compat["forum/components/DiscussionListItem"];var i=t.n(d);const c=flarum.core.compat["forum/components/IndexPage"];var u=t.n(c);e().initializers.add("justoverclock/random-post",(function(){(0,n.extend)(s().prototype,"oninit",(function(){var t=this;e().store.find("posts",{include:"discussion,user"}).then((function(o){t.randomPostOne=o[Math.floor(Math.random()*o.length)],t.randomPostTwo=o[Math.floor(Math.random()*o.length)],t.randomPostTree=o[Math.floor(Math.random()*o.length)]}))})),(0,n.extend)(s().prototype,"view",(function(t){var o=this;e().current.matches(u())&&m.redraw(),t.children.forEach((function(t){if(t&&t.attrs&&"DiscussionList-discussions"===t.attrs.className){var a=0;t.children.forEach((function(t){t&&t.children&&[].concat(t.children).forEach((function(e){"li"===e.tag&&e.children&&e.children.length&&e.children[0]&&e.children[0].tag===i()&&(e.attrs["data-index"]=a,1===a?t.children.splice(t.children.indexOf(e),0,m("div",{id:"random-post-one"},m("div",{className:"random-post-content"},m("p",{className:"random-post-text",id:"random-post-text"},o.randomPostOne&&o.randomPostOne.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g,"").substr(0,200)),m("div",{className:"random-post-info"},m("div",{className:"random-post-author",id:"random-post-author"},m("a",{href:o.randomPostOne&&"u/"+o.randomPostOne.user().data.attributes.slug},o.randomPostOne&&o.randomPostOne.user().displayName())," in the ",m("a",{href:o.randomPostOne&&"d/"+o.randomPostOne.discussion().data.attributes.slug},o.randomPostOne&&o.randomPostOne.discussion().data.attributes.title)))))):10===a?t.children.splice(t.children.indexOf(e),0,m("div",{id:"random-post-one"},m("div",{className:"random-post-content"},m("p",{className:"random-post-text",id:"random-post-text"},o.randomPostTwo&&o.randomPostTwo.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g,"").substr(0,200)),m("div",{className:"random-post-info"},m("div",{className:"random-post-author",id:"random-post-author"},m("a",{href:o.randomPostTwo&&"u/"+o.randomPostTwo.user().data.attributes.slug},o.randomPostTwo&&o.randomPostTwo.user().displayName())," in the ",m("a",{href:o.randomPostTwo&&"d/"+o.randomPostTwo.discussion().data.attributes.slug},o.randomPostTwo&&o.randomPostTwo.discussion().data.attributes.title)))))):19===a&&t.children.splice(t.children.indexOf(e),0,m("div",{id:"random-post-one"},m("div",{className:"random-post-content"},m("p",{className:"random-post-text",id:"random-post-text"},o.randomPostTree&&o.randomPostTree.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g,"").substr(0,200)),m("div",{className:"random-post-info"},m("div",{className:"random-post-author",id:"random-post-author"},m("a",{href:o.randomPostTree&&"u/"+o.randomPostTree.user().data.attributes.slug},o.randomPostTree&&o.randomPostTree.user().displayName())," in the ",m("a",{href:o.randomPostTree&&"d/"+o.randomPostTree.discussion().data.attributes.slug},o.randomPostTree&&o.randomPostTree.discussion().data.attributes.title)))))),a++)}))}))}}))}))}))})(),module.exports=o})(); +(()=>{var o={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return o.d(a,{a}),a},d:(t,a)=>{for(var r in a)o.o(a,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(o,t)=>Object.prototype.hasOwnProperty.call(o,t),r:o=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})}},t={};(()=>{"use strict";o.r(t);const a=flarum.core.compat["forum/app"];var r=o.n(a);const s=flarum.core.compat["forum/components/DiscussionList"];var e=o.n(s);const n=flarum.core.compat["common/extend"],d=flarum.core.compat["forum/components/DiscussionListItem"];var i=o.n(d);const c=flarum.core.compat["forum/components/IndexPage"];var u=o.n(c);r().initializers.add("justoverclock/random-post",(function(){(0,n.extend)(e().prototype,"oninit",(function(){var o=this;r().store.find("posts",{include:"discussion,user"}).then((function(t){o.randomPostOne=t[Math.floor(Math.random()*t.length)],o.randomPostTwo=t[Math.floor(Math.random()*t.length)],o.randomPostTree=t[Math.floor(Math.random()*t.length)]}))})),(0,n.extend)(e().prototype,"view",(function(o){var t=this,a=r().forum.attribute("justoverclock-random-post.charLimitRandomPost")||200;r().current.matches(u())&&m.redraw(),o.children.forEach((function(o){if(o&&o.attrs&&"DiscussionList-discussions"===o.attrs.className){var s=0;o.children.forEach((function(o){o&&o.children&&[].concat(o.children).forEach((function(e){"li"===e.tag&&e.children&&e.children.length&&e.children[0]&&e.children[0].tag===i()&&(e.attrs["data-index"]=s,1===s?o.children.splice(o.children.indexOf(e),0,m("div",{id:"random-post-one"},m("div",{className:"random-post-content"},m("p",{className:"random-post-text",id:"random-post-text"},t.randomPostOne&&t.randomPostOne.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g,"").substr(0,a)),m("div",{className:"random-post-info"},m("div",{className:"random-post-author",id:"random-post-author"},m("a",{href:t.randomPostOne&&"u/"+t.randomPostOne.user().data.attributes.slug},t.randomPostOne&&t.randomPostOne.user().displayName()),r().translator.trans("justoverclock-random-post.forum.inThe"),m("a",{href:t.randomPostOne&&"d/"+t.randomPostOne.discussion().data.attributes.slug},t.randomPostOne&&t.randomPostOne.discussion().data.attributes.title)))))):10===s?o.children.splice(o.children.indexOf(e),0,m("div",{id:"random-post-one"},m("div",{className:"random-post-content"},m("p",{className:"random-post-text",id:"random-post-text"},t.randomPostTwo&&t.randomPostTwo.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g,"").substr(0,a)),m("div",{className:"random-post-info"},m("div",{className:"random-post-author",id:"random-post-author"},m("a",{href:t.randomPostTwo&&"u/"+t.randomPostTwo.user().data.attributes.slug},t.randomPostTwo&&t.randomPostTwo.user().displayName()),r().translator.trans("justoverclock-random-post.forum.inThe"),m("a",{href:t.randomPostTwo&&"d/"+t.randomPostTwo.discussion().data.attributes.slug},t.randomPostTwo&&t.randomPostTwo.discussion().data.attributes.title)))))):19===s&&o.children.splice(o.children.indexOf(e),0,m("div",{id:"random-post-one"},m("div",{className:"random-post-content"},m("p",{className:"random-post-text",id:"random-post-text"},t.randomPostTree&&t.randomPostTree.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g,"").substr(0,a)),m("div",{className:"random-post-info"},m("div",{className:"random-post-author",id:"random-post-author"},m("a",{href:t.randomPostTree&&"u/"+t.randomPostTree.user().data.attributes.slug},t.randomPostTree&&t.randomPostTree.user().displayName()),r().translator.trans("justoverclock-random-post.forum.inThe"),m("a",{href:t.randomPostTree&&"d/"+t.randomPostTree.discussion().data.attributes.slug},t.randomPostTree&&t.randomPostTree.discussion().data.attributes.title)))))),s++)}))}))}}))}))}))})(),module.exports=t})(); //# sourceMappingURL=forum.js.map \ No newline at end of file diff --git a/js/dist/forum.js.map b/js/dist/forum.js.map index d4fcda1..41cd26d 100644 --- a/js/dist/forum.js.map +++ b/js/dist/forum.js.map @@ -1 +1 @@ -{"version":3,"file":"forum.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,IACzBH,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,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Ac2B,aAAaT,KAAKC,WAAWS,YAKpD,KAApBlB,GACTC,EAASL,SAASS,OAAOJ,EAASL,SAASU,QAAQJ,GAAK,EACtD,SAAKK,GAAG,mBACN,SAAKR,UAAU,uBACb,OAAGA,UAAU,mBAAmBQ,GAAG,oBAChC,EAAKhB,gBAAkB,EAAKA,eAAeiB,KAAKC,WAAWC,YAAYC,QAAQ,kBAAmB,IAAIC,OAAO,EAAG,MAEnH,SAAKb,UAAU,oBACb,SAAKA,UAAU,qBAAqBQ,GAAG,sBACrC,OACEM,KAAM,EAAKtB,gBAAkB,KAAO,EAAKA,eAAeuB,OAAON,KAAKC,WAAWM,MAAO,EAAKxB,gBAAkB,EAAKA,eAAeuB,OAAOE,eAF5I,WAGM,OAAGH,KAAM,EAAKtB,gBAAkB,KAAO,EAAKA,eAAe0B,aAAaT,KAAKC,WAAWM,MAC3F,EAAKxB,gBAAkB,EAAKA,eAAe0B,aAAaT,KAAKC,WAAWS,YAOrFlB,sB","sources":["webpack://@justoverclock/random-post/webpack/bootstrap","webpack://@justoverclock/random-post/webpack/runtime/compat get default export","webpack://@justoverclock/random-post/webpack/runtime/define property getters","webpack://@justoverclock/random-post/webpack/runtime/hasOwnProperty shorthand","webpack://@justoverclock/random-post/webpack/runtime/make namespace object","webpack://@justoverclock/random-post/external root \"flarum.core.compat['forum/app']\"","webpack://@justoverclock/random-post/external root \"flarum.core.compat['forum/components/DiscussionList']\"","webpack://@justoverclock/random-post/external root \"flarum.core.compat['common/extend']\"","webpack://@justoverclock/random-post/external root \"flarum.core.compat['forum/components/DiscussionListItem']\"","webpack://@justoverclock/random-post/external root \"flarum.core.compat['forum/components/IndexPage']\"","webpack://@justoverclock/random-post/./src/forum/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/app'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionList'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['common/extend'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/DiscussionListItem'];","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['forum/components/IndexPage'];","import app from 'flarum/forum/app';\nimport DiscussionList from 'flarum/forum/components/DiscussionList';\nimport {extend} from 'flarum/common/extend';\nimport DiscussionListItem from \"flarum/forum/components/DiscussionListItem\";\nimport IndexPage from \"flarum/forum/components/IndexPage\";\n\n\napp.initializers.add('justoverclock/random-post', () => {\n extend(DiscussionList.prototype, 'oninit', function () {\n app.store\n .find('posts', {\n include: 'discussion,user',\n })\n .then((results) => {\n this.randomPostOne = results[Math.floor(Math.random() * results.length)];\n this.randomPostTwo = results[Math.floor(Math.random() * results.length)];\n this.randomPostTree = results[Math.floor(Math.random() * results.length)];\n })\n })\n extend(DiscussionList.prototype, 'view', function (vdom) {\n\n\n if (app.current.matches(IndexPage)) {\n m.redraw()\n }\n\n\n vdom.children.forEach(vdom => {\n\n // Find the child with class .DiscussionList-discussions\n if (!vdom || !vdom.attrs || vdom.attrs.className !== 'DiscussionList-discussions') {\n return;\n }\n\n let discussionIndex = 0;\n\n vdom.children.forEach(mapGroup => {\n\n\n // All children should be Mithril virtual group nodes \"[\" but we'll make sure no `null` or `undefined` got in here\n if (!mapGroup || !mapGroup.children) {\n return;\n }\n\n // Clone array so inserting new items into the original array doesn't cause the loop to skip items\n [...mapGroup.children].forEach((li) => {\n // Verify each child is an li containing a DiscussionListItem, this way we are not counting items added by other extensions\n if (li.tag !== 'li' || !li.children || !li.children.length || !li.children[0] || li.children[0].tag !== DiscussionListItem) {\n return;\n }\n\n // Add index to the DOM so it can be used from CSS\n li.attrs['data-index'] = discussionIndex;\n\n // Add content above each group of 3 discussions\n if (discussionIndex === 1) {\n\n\n // Use indexOf() to get the up to date index of the current element, since adding items will shift the index of next items\n mapGroup.children.splice(mapGroup.children.indexOf(li), 0,\n
\n {this.randomPostOne && this.randomPostOne.data.attributes.contentHtml.replace(/<\\/?[^>]+(>|$)/g, '').substr(0, 200)}\n
\n\n {this.randomPostTwo && this.randomPostTwo.data.attributes.contentHtml.replace(/<\\/?[^>]+(>|$)/g, '').substr(0, 200)}\n
\n\n {this.randomPostTree && this.randomPostTree.data.attributes.contentHtml.replace(/<\\/?[^>]+(>|$)/g, '').substr(0, 200)}\n
\n\n {this.randomPostOne && this.randomPostOne.data.attributes.contentHtml.replace(/<\\/?[^>]+(>|$)/g, '').substr(0, charLim)}\n
\n\n {this.randomPostTwo && this.randomPostTwo.data.attributes.contentHtml.replace(/<\\/?[^>]+(>|$)/g, '').substr(0, charLim)}\n
\n\n {this.randomPostTree && this.randomPostTree.data.attributes.contentHtml.replace(/<\\/?[^>]+(>|$)/g, '').substr(0, charLim)}\n
\n- {this.randomPostOne && this.randomPostOne.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g, '').substr(0, 200)} + {this.randomPostOne && this.randomPostOne.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g, '').substr(0, charLim)}
- {this.randomPostTwo && this.randomPostTwo.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g, '').substr(0, 200)} + {this.randomPostTwo && this.randomPostTwo.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g, '').substr(0, charLim)}
- {this.randomPostTree && this.randomPostTree.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g, '').substr(0, 200)} + {this.randomPostTree && this.randomPostTree.data.attributes.contentHtml.replace(/<\/?[^>]+(>|$)/g, '').substr(0, charLim)}