https://www.drapersonline.com/wp-content/plugins/mbm-miso/Extensions/DR/assets/miso-ask.js?ver=2.2.3
1/** Drapers **/ 2jQuery(document).ready(function ($) { 3 (window.misocmd || (window.misocmd = [])).push(async () => { 4 var brandCode = miso_script_vars.brandCode; 5 MisoClient.on('create', (client) => { 6 client.ui.asks.useLayouts({ 7 query: { 8 placeholder: 'Ask Drapers anything', 9 }, 10 }); 11 12 client.ui.explore.useLayouts({ 13 query: { 14 placeholder: 'Ask Drapers anything', 15 }, 16 }); 17 18 client.ui.asks.useLayouts({ 19 affiliation: { 20 templates: { 21 ctaText: 'Learn More', 22 itemHeaderLeftText: "Drapers Events and Awards", 23 }, 24 }, 25 }); 26 27 client.ui.asks.useApi({ 28 "_pipeline_config": { 29 "version": "v3" 30 } 31 }); 32 33 client.ui.asks.on('ready', (event) => { 34 const workflow = event.workflow; 35 const parentQuestionId = workflow.parentQuestionId; 36 const comboElement = document.querySelector('miso-ask-combo'); 37 const containerSelector = parentQuestionId ? `miso-ask[parent-question-id="${parentQuestionId}"]` : `miso-ask`; 38 if (comboElement.querySelector(`${containerSelector} .miso-notice`)) { 39 return; 40 } 41 const feedbackElement = comboElement.querySelector(`${containerSelector} miso-feedback`); 42 feedbackElement.insertAdjacentHTML('afterend', ` 43 <hr> 44 <div class="miso-notice"> 45 <div class="miso-notice-icon"><i>!</i></div> 46 <div class="miso-notice-content">While our AI system is constantly evolving and improving, there's a possibility that the generated answers may not always be without error. It's important to exercise your own judgement when evaluating the information provided and to review the source articles that the answer is based on. Please keep in mind that any actions you take based on the AI-generated content are at your own risk.</div> 47 </div> 48 `); 49 }); 50 }); 51 52 // --- START: MutationObserver to remove reasoning/thought boxes --- 53 const observer = new MutationObserver((mutations) => { 54 mutations.forEach(() => { 55 document.querySelectorAll('.miso-ask-combo__reasoning-container') 56 .forEach(el => el.remove()); 57 }); 58 }); 59 observer.observe(document.body, { childList: true, subtree: true }); 60 // --- END: MutationObserver --- 61 62 var brand_name = miso_script_vars.brandName; 63 var miso_user_id = miso_script_vars.miso_user_id; 64 var miso_user_hash = miso_script_vars.user_hash; 65 let b_code = brandCode.toLowerCase(); 66 var fq_text = 'brand:"' + brand_name + '"'; 67 68 if (miso_script_vars.hasOwnProperty('ex_categories') && miso_script_vars.ex_categories != "") { 69 var str_cats = miso_script_vars.ex_categories; 70 var c_arr = str_cats.split(','); 71 var str = ''; 72 for (var i = 0; i < c_arr.length; i++) { 73 str += '"' + c_arr[i] + '"'; 74 if (i < c_arr.length - 1) { 75 str += ' or '; 76 } 77 } 78 fq_text += ' AND (NOT(categories:(' + str + ')))'; 79 } 80 81 if (miso_script_vars.hasOwnProperty('custom_attributes') && miso_script_vars.custom_attributes != "") { 82 var custom_attributes = formatKeyValuePairs(miso_script_vars, 'custom_attributes'); 83 fq_text += ' AND (NOT(' + custom_attributes + '))'; 84 } 85 86 87 // Function to get key-value pairs from an object 88 function formatKeyValuePairs(data, groupKey) { 89 // Get the specific group object based on the provided key 90 const groupObj = data[groupKey]; 91 92 if (!groupObj || typeof groupObj !== 'object') { 93 return ''; 94 } 95 96 let formattedPairs = []; 97 98 for (const [key, value] of Object.entries(groupObj)) { 99 formattedPairs.push(`${groupKey}.${key}:(${value.map(v => `"${v}"`).join(' or ')})`); 100 } 101 102 return formattedPairs.join(' or '); 103 } 104 105 const combo = MisoClient.ui.combo.ask; 106 combo.config({ 107 api: { 108 fq: fq_text, 109 user_id: miso_user_id, 110 user_hash: miso_user_hash, 111 source_fl: ['cover_image', 'url', 'created_at', 'updated_at', 'published_at', 'custom_attributes.type'], 112 }, 113 }); 114 combo.start(); 115 }); 116});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.