jenkins-bot has submitted this change and it was merged.

Change subject: Guaranteeing the order in which search suggestions appear.
......................................................................


Guaranteeing the order in which search suggestions appear.

Bug: T129613
Change-Id: I16574aedb9321c7e002c501ed93fd29f0b81df39
---
M dev/wikipedia.org/assets/js/wm-typeahead.js
M dev/wikipedia.org/assets/rev-manifest.json
D prod/wikipedia.org/assets/js/index-5b9d82d3b8.js
A prod/wikipedia.org/assets/js/index-c7d5a13f71.js
M prod/wikipedia.org/index.html
5 files changed, 91 insertions(+), 48 deletions(-)

Approvals:
  JGirault: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/dev/wikipedia.org/assets/js/wm-typeahead.js 
b/dev/wikipedia.org/assets/js/wm-typeahead.js
index 4e92e74..1c21652 100644
--- a/dev/wikipedia.org/assets/js/wm-typeahead.js
+++ b/dev/wikipedia.org/assets/js/wm-typeahead.js
@@ -57,6 +57,38 @@
        }
 
        /**
+        * Keeps track of the search query callbacks. Consists of an array of
+        * callback functions and an index that keeps track of the order of 
requests.
+        * Callbacks are deleted by replacing the callback function with a 
no-op.
+        */
+       window.callbackStack = {
+               queue: {},
+               index: -1,
+               incrementIndex: function () {
+                       this.index += 1;
+                       return this.index;
+               },
+               addCallback: function ( func ) {
+                       var index = this.incrementIndex();
+                       this.queue[ index ] = func( index );
+                       return index;
+               },
+               deleteSelfFromQueue: function ( i ) {
+                       delete this.queue[ i ];
+               },
+               deletePrevCallbacks: function ( j ) {
+
+                       this.deleteSelfFromQueue( j );
+
+                       for ( var callback in this.queue ) {
+                               if ( callback < j ) {
+                                       this.queue[ callback ]  = 
this.deleteSelfFromQueue.bind( window.callbackStack, callback );
+                               }
+                       }
+               }
+       };
+
+       /**
         * Removes the type-ahead suggestions from the DOM.
         * Reason for timeout: The typeahead is set to clear on input blur.
         * When a user clicks on a search suggestion, they triggers the input 
blur
@@ -81,6 +113,7 @@
         * @param {string} string - query string to search.
         * @param {string} lang - ISO code of language to search in.
         */
+
        function loadQueryScript( string, lang ) {
                // variables declared in parent function.
                searchLang = encodeURIComponent( lang ) || 'en';
@@ -102,6 +135,8 @@
                script = document.createElement( 'script' );
                script.id = 'api_opensearch';
 
+               var callbackIndex = window.callbackStack.addCallback( 
window.portalOpensearchCallback ) ;
+
                var searchQuery = {
                        action: 'query',
                        format: 'json',
@@ -116,7 +151,7 @@
                        gpssearch: string,
                        gpsnamespace: 0,
                        gpslimit: 6,
-                       callback: 'portalOpensearchCallback'
+                       callback: 'callbackStack.queue[' + callbackIndex + ']'
                };
 
                script.src = hostname + serialize( searchQuery );
@@ -169,12 +204,11 @@
                        /**
                         * Indentation is used to express the DOM order of 
template.
                         */
-                       var suggestionItem,
-                                       suggestionLink,
-                                               suggestionThumbnail,
-                                               suggestionText,
-                                                       suggestionTitle,
-                                                       suggestionDescription,
+                       var suggestionLink,
+                                       suggestionThumbnail,
+                                       suggestionText,
+                                               suggestionTitle,
+                                               suggestionDescription,
                                page = suggestions[ i ],
                                sanitizedThumbURL = false;
 
@@ -209,44 +243,6 @@
        } // END generateTemplateString
 
        /**
-        * Search API callback.
-        *  - parses the search results
-        *  - generates the template String
-        *  - inserts the template string into the DOM
-        *  - attaches event listeners on each suggestion item.
-        *
-        * @param {Object} xhrResults
-        */
-       window.portalOpensearchCallback = function ( xhrResults ) {
-
-               if ( document.activeElement !== searchEl ) { return; }
-
-               var orderedResults = [],
-                       suggestions = ( xhrResults.query && 
xhrResults.query.pages ) ? xhrResults.query.pages : [] ;
-
-               for ( var item in suggestions ) {
-                       var result = suggestions[ item ];
-                       orderedResults[ result.index - 1 ] = result;
-               }
-
-               var templateDOMString = generateTemplateString( orderedResults 
);
-
-               typeAheadEl.innerHTML = templateDOMString;
-
-               typeAheadItems = typeAheadEl.childNodes[ 0 ].childNodes;
-
-               // attaching hover events
-               for ( var i = 0; i < typeAheadItems.length; i++ ) {
-                       var listEl = typeAheadItems[ i ];
-                       // Requires the addEvent global polyfill
-                       addEvent( listEl, 'mouseenter', toggleActiveClass.bind( 
this, listEl, typeAheadItems ) );
-                       addEvent( listEl, 'mouseleave', toggleActiveClass.bind( 
this, listEl, typeAheadItems ) );
-               }
-       };
-
-       /* Mouse and keyboard Events */
-
-       /**
         * - Removes 'active' class from a collection of elements.
         * - Adds 'active' class to an item if missing.
         * - Removes 'active' class from item if present.
@@ -278,6 +274,53 @@
        }
 
        /**
+        * Search API callback. Returns a closure that holds the index of the 
request.
+        * Deletes previous callbacks based on this index. This prevents 
callbacks for old
+        * requests from executing. Then:
+        *  - parses the search results
+        *  - generates the template String
+        *  - inserts the template string into the DOM
+        *  - attaches event listeners on each suggestion item.
+        *
+        * @param {Object} xhrResults
+        */
+       window.portalOpensearchCallback = function ( i ) {
+
+               var callbackIndex = i;
+
+               return function ( xhrResults ) {
+
+                       window.callbackStack.deletePrevCallbacks( callbackIndex 
);
+
+                       if ( document.activeElement !== searchEl ) {
+                               return;
+                       }
+
+                       var orderedResults = [],
+                               suggestions = ( xhrResults.query && 
xhrResults.query.pages ) ? xhrResults.query.pages : [];
+
+                       for ( var item in suggestions ) {
+                               var result = suggestions[ item ];
+                               orderedResults[ result.index - 1 ] = result;
+                       }
+
+                       var templateDOMString = generateTemplateString( 
orderedResults );
+
+                       typeAheadEl.innerHTML = templateDOMString;
+
+                       typeAheadItems = typeAheadEl.childNodes[ 0 ].childNodes;
+
+                       // attaching hover events
+                       for ( var i = 0; i < typeAheadItems.length; i++ ) {
+                               var listEl = typeAheadItems[ i ];
+                               // Requires the addEvent global polyfill
+                               addEvent( listEl, 'mouseenter', 
toggleActiveClass.bind( this, listEl, typeAheadItems ) );
+                               addEvent( listEl, 'mouseleave', 
toggleActiveClass.bind( this, listEl, typeAheadItems ) );
+                       }
+               };
+       };
+
+       /**
         * Increments a global 'keyboardIndex' variable
         *
         * @param {int} i - current index
diff --git a/dev/wikipedia.org/assets/rev-manifest.json 
b/dev/wikipedia.org/assets/rev-manifest.json
index 9ca8883..8117488 100644
--- a/dev/wikipedia.org/assets/rev-manifest.json
+++ b/dev/wikipedia.org/assets/rev-manifest.json
@@ -1,5 +1,5 @@
 {
   "portal/wikipedia.org/assets/js/abtesting.js": 
"portal/wikipedia.org/assets/js/abtesting-83e3db0299.js",
   "portal/wikipedia.org/assets/js/gt-ie9.js": 
"portal/wikipedia.org/assets/js/gt-ie9-c84bf66d33.js",
-  "portal/wikipedia.org/assets/js/index.js": 
"portal/wikipedia.org/assets/js/index-5b9d82d3b8.js"
+  "portal/wikipedia.org/assets/js/index.js": 
"portal/wikipedia.org/assets/js/index-c7d5a13f71.js"
 }
\ No newline at end of file
diff --git a/prod/wikipedia.org/assets/js/index-5b9d82d3b8.js 
b/prod/wikipedia.org/assets/js/index-5b9d82d3b8.js
deleted file mode 100644
index 47e13c9..0000000
--- a/prod/wikipedia.org/assets/js/index-5b9d82d3b8.js
+++ /dev/null
@@ -1 +0,0 @@
-var _=_||{};_.now=Date.now||function(){return(new 
Date).getTime()},_.throttle=function(e,t,n){var a,i,r,o=null,s=0;n||(n={});var 
c=function(){s=n.leading===!1?0:_.now(),o=null,r=e.apply(a,i),o||(a=i=null)};return
 function(){var l=_.now();s||n.leading!==!1||(s=l);var u=t-(l-s);return 
a=this,i=arguments,0>=u||u>t?(o&&(clearTimeout(o),o=null),s=l,r=e.apply(a,i),o||(a=i=null)):o||n.trailing===!1||(o=setTimeout(c,u)),r}},_.debounce=function(e,t,n){var
 a,i,r,o,s,c=function(){var 
l=_.now()-o;t>l&&l>=0?a=setTimeout(c,t-l):(a=null,n||(s=e.apply(r,i),a||(r=i=null)))};return
 function(){r=this,i=arguments,o=_.now();var l=n&&!a;return 
a||(a=setTimeout(c,t)),l&&(s=e.apply(r,i),r=i=null),s}};var 
WMTypeAhead=function(e,t){function n(e){var t=[];for(var n in 
e)e.hasOwnProperty(n)&&t.push(n+"="+encodeURIComponent(e[n]));return 
t.join("&")}function a(){setTimeout(function(){p.innerHTML="";var 
e=document.getElementById("api_opensearch");e&&(e.src=!1)},300)}function 
i(e,t){if(u=encodeURIComponent(t)||"en",d=encodeURIComponent(e),0===d.length)return
 void a();var 
i=document.getElementById("api_opensearch"),r=document.getElementsByTagName("head")[0],o="//"+u+".wikipedia.org/w/api.php?";i&&r.removeChild(i),i=document.createElement("script"),i.id="api_opensearch";var
 
s={action:"query",format:"json",generator:"prefixsearch",prop:"pageprops|pageimages|pageterms",redirects:"",ppprop:"displaytitle",piprop:"thumbnail",pithumbsize:y,pilimit:6,wbptterms:"description",gpssearch:e,gpsnamespace:0,gpslimit:6,callback:"portalOpensearchCallback"};i.src=o+n(s),r.appendChild(i)}function
 r(e,t){var n=mw.html.escape(mw.RegExp.escape(t)),a=new 
RegExp(n,"i"),i=e.search(a),r=mw.html.escape(e);if(i>=0){var 
o=i+n.length,s=e.substring(i,o),c=e.substring(0,i),l=e.substring(o,e.length);r=c+mw.html.element("em",{"class":"suggestion-highlight"},s)+l}return
 r}function o(e){for(var t='<div 
class="suggestions-dropdown">',n=0;n<e.length;n++)if(e[n]){var 
a,i,o,s,c,l=e[n],g=!1;l.thumbnail&&l.thumbnail.source&&(g=l.thumbnail.source.replace(/\"/g,"%22"),g=g.replace(/'/g,"%27")),c=mw.html.element("p",{"class":"suggestion-description"},l.terms&&l.terms.description?l.terms.description.toString():""),s=mw.html.element("h3",{"class":"suggestion-title"},new
 
mw.html.Raw(r(l.title,d))),o=mw.html.element("div",{"class":"suggestion-text"},new
 
mw.html.Raw(s+c)),i=mw.html.element("div",{"class":"suggestion-thumbnail",style:g?"background-image:url("+g+")":!1},""),a=mw.html.element("a",{"class":"suggestion-link",href:"https://"+u+".wikipedia.org/wiki/"+encodeURIComponent(l.title.replace(/
 /gi,"_"))},new mw.html.Raw(o+i)),t+=a}return t+="</div>"}function 
s(e,t){for(var n=" active",a=0;a<t.length;a++){var 
i=t[a];i!==e?i.className=i.className.replace(n,""):/ 
active/.test(e.className)?e.className=e.className.replace(n,""):e.className+=n}}function
 c(e,t){w+=e,0>w&&(w=t-1),w>t-1&&(w=0)}function l(e){var 
t=e||window.event,n=t.which||t.keyCode;if(p.firstChild){if(40===n||38===n){var 
a=p.firstChild.childNodes,i=a.length;40===n?c(1,i):c(-1,i),h=p.firstChild?p.firstChild.childNodes[w]:!1,s(h,a)}13===n&&h&&(t.preventDefault?t.preventDefault():t.returnValue=!1,h.children[0].click())}}var
 
u,d,g,h,m="typeahead-suggestions",p=document.getElementById(m),v=document.getElementById(e),f=document.getElementById(t),w=-1,y=80*getDevicePixelRatio();return
 
p||(p=document.createElement("div"),p.id=m,v.appendChild(p)),window.portalOpensearchCallback=function(e){if(document.activeElement===f){var
 t=[],n=e.query&&e.query.pages?e.query.pages:[];for(var a in n){var 
i=n[a];t[i.index-1]=i}var 
r=o(t);p.innerHTML=r,g=p.childNodes[0].childNodes;for(var 
c=0;c<g.length;c++){var 
l=g[c];addEvent(l,"mouseenter",s.bind(this,l,g)),addEvent(l,"mouseleave",s.bind(this,l,g))}}},addEvent(f,"keydown",l),addEvent(f,"blur",a),{typeAheadEl:p,query:i}};!function(e,t){"use
 strict";function n(e,t){var n,a,i={};for(n=0;n<t.length;n++){var 
r=t[n].nodes;for(a=0;a<r.length;a++)r[a].contains(e)&&(i=t[n])}return 
i.name}function 
a(e){return"A"!==e.tagName&&e.parentElement?a(e.parentElement):e}function 
i(){u={event_type:"landing"},e.logEvent(s,u),u=null}function r(t){var 
i,r=t||window.event,o=r.target||r.srcElement;o.matches("a, a 
*")&&(i=a(o),u={event_type:"clickthrough",destination:i.href,section_used:n(i,c)},u.section_used&&e.logEvent(s,u))}function
 o(t){var 
a=t||window.event,i=a.target||a.srcElement;null===u&&(u={event_type:"clickthrough",section_used:n(i,c),destination:i.action}),u.section_used&&e.logEvent(s,u)}var
 
s,c,l,u,d=document.cookie.match(/GeoIP=.[^:]/);if("rejected"!==t.group&&!t.loggingDisabled){s={name:"WikipediaPortal",revision:14377354,defaults:{session_id:t.sessionId,event_type:"landing",referer:document.referrer||null,accept_language:t.userLangs.toString(),cohort:t.group},properties:{session_id:{type:"string",required:!0},event_type:{type:"string",required:!0,"enum":["landing","clickthrough"]},section_used:{type:"string",required:!1,"enum":["primary
 links","search","language search","secondary links","other languages","other 
projects"]},destination:{type:"string",required:!1},referer:{type:"string",required:!1},country:{type:"string",required:!1},accept_language:{type:"string",required:!0},cohort:{type:"string",required:!1}}},c=[{name:"primary
 links",nodes:document.querySelectorAll('[data-el-section="primary 
links"]')},{name:"search",nodes:document.querySelectorAll('[data-el-section="search"]')},{name:"language
 search",nodes:document.querySelectorAll('[data-el-section="language 
search"]')},{name:"secondary 
links",nodes:document.querySelectorAll('[data-el-section="secondary 
links"]')},{name:"other 
languages",nodes:document.querySelectorAll('[data-el-section="other 
languages"]')},{name:"other 
projects",nodes:document.querySelectorAll('[data-el-section="other 
projects"]')}],addEvent(document,"click",r),l=document.getElementsByTagName("form");for(var
 
g=0;g<l.length;g++)addEvent(l[g],"submit",o);d&&(s.defaults.country=d.toString().split("=")[1],addEvent(window,"load",i)),addEvent(window,"load",i)}}(eventLoggingLite,wmTest),function(){"use
 strict";function e(e){return document.getElementById(e)}function t(e){var 
t,n;document.querySelector&&"www-wiktionary-org"===document.body.id&&!e.match(/\W/)&&(t=document.querySelector('option[lang|="'+e+'"]'),n=t&&t.getAttribute("data-logo"),n&&document.body.setAttribute("data-logo",n))}function
 n(){var 
e=navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage||"";return
 e.toLowerCase().split("-")[0]}function a(){var 
e=document.cookie.match(/(?:^|\W)searchLang=([^;]+)/);return(e?e[1]:n()).toLowerCase()}function
 
i(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}function
 r(t){var 
n,a,r="data-convert-hans",o="data-converttitle-hans";if(-1!=="zh-hans,zh-cn,zh-sg,zh-my,".indexOf(t+",")){var
 
s=["zh_art","zh_others","zh_search","zh_tag","zh_top10","zh-yue_wiki","gan_wiki","hak_wiki","wuu_wiki"];for(n=0;n<s.length;n+=1)a=e(s[n]),a&&(a.hasAttribute(r)&&i(a,a.getAttribute(r)),a.hasAttribute(o)&&(a.title=a.getAttribute(o)))}}function
 o(t){var 
n;0===t.indexOf("zh")&&(n=t.substring(3),"mo"===n?n="hk":"my"===n&&(n="sg"),n&&"cn,tw,hk,sg,".indexOf(n+",")>=0&&(e("zh_wiki").href+="zh-"+n+"/",e("zh_others").href=e("zh_others").href.replace("wiki/","zh-"+n+"/")),r(t))}function
 s(){if(void 0!==window.HTMLDataListElement){var 
t=document.createElement("datalist"),n=e("searchInput");t.id="suggestions",document.body.appendChild(t),n.autocomplete="off",n.setAttribute("list","suggestions"),addEvent(n,"input",_.debounce(function(){var
 
t,a=document.getElementsByTagName("head")[0],i=e("searchLanguage").value,r=e("api_opensearch"),o=encodeURIComponent(n.value);t=i+".wikipedia.org",r&&a.removeChild(r),r=document.createElement("script"),r.id="api_opensearch",r.src="//"+encodeURIComponent(t)+"/w/api.php?action=opensearch&limit=10&format=json&callback=portalOpensearchCallback&search="+o,a.appendChild(r)},200))}}function
 c(e){if(e){var a=n(),i=a.match(/^\w+/),r=new 
Date;t(e),i&&i[0]===e?r.setTime(r.getTime()-1):r.setFullYear(r.getFullYear()+1),document.cookie="searchLang="+e+";expires="+r.toUTCString()+";domain="+location.host+";"}}function
 l(e,t){var n,a,i,r,o={ratio:1};for(n=t.split(/ *, 
*/),i=0;i<n.length;i++)a=n[i].match(/\s*(\S+)(?:\s*([\d.]+)w)?(?:\s*([\d.]+)h)?(?:\s*([\d.]+)x)?\s*/),r=a[4]&&parseFloat(a[4]),e>=r&&r>o.ratio&&(o.ratio=r,o.src=a[1],o.width=a[2]&&parseFloat(a[2]),o.height=a[3]&&parseFloat(a[3]));return
 o}function u(){var e,t,n=getDevicePixelRatio(),a=new Image;if(n>1&&void 
0===a.srcset)for(e=document.getElementsByTagName("img"),t=0;t<e.length;t++){var 
i,r=e[t],o=r.getAttribute("srcset");"string"==typeof o&&""!==o&&(i=l(n,o),void 
0!==i.src&&(r.setAttribute("src",i.src),void 
0!==i.width&&r.setAttribute("width",i.width),void 
0!==i.height&&r.setAttribute("height",i.height)))}}doWhenReady(function(){var 
n,r,s,c,l,u,d,g,h,m=a();if(m&&(o(m),n=getIso639(m),r=e("searchLanguage"))){for(s=r.getElementsByTagName("option"),c=0,l=s.length;!u&&l>c;c+=1)s[c].value===n&&(u=n);!u&&document.querySelector&&(d=document.querySelector('.langlist
 
a[lang|="'+n+'"]'),d&&(u=n,g=document.createElement("option"),g.setAttribute("lang",n),g.setAttribute("value",n),h=d.textContent||d.innerText||n,i(g,h),r.appendChild(g))),u&&(r.value=u,t(u))}}),window.wmSuggestionsEL=null,window.portalOpensearchCallback=_.debounce(function(t){var
 
n,a=window.wmSuggestionsEL||e("suggestions"),i=a.children,r=document.createDocumentFragment();for(n=0;n<t[1].length;n+=1){var
 
o=i[n]||document.createElement("option");o.value=t[1][n],i[n]||r.appendChild(o)}a.appendChild(r.cloneNode(!0))},100),doWhenReady(function(){var
 
t,n,a,i=e("searchInput"),r=e("searchLanguage");if(i)for(i.setAttribute("results","10"),s(),void
 
0===i.autofocus?i.focus():window.scroll(0,0),t=location.search&&location.search.substr(1).split("&"),n=0;n<t.length;n+=1)if(a=t[n].split("="),"search"===a[0]&&a[1]){i.value=decodeURIComponent(a[1].replace(/\+/g,"
 
"));break}addEvent(r,"change",function(){r.blur(),c(r.value)})}),doWhenReady(function(){var
 
e=document.searchwiki&&document.searchwiki.elements.uselang;e&&(e.value=n())}),doWhenReady(u)}(),window.mw||(window.mw=window.mediaWiki={loader:{state:function(){}}}),function(e,t){doWhenReady(function(){var
 
e,n=document.getElementById("searchInput"),a=n.cloneNode(!0);n.parentNode.replaceChild(a,n),a.focus();var
 i=new t("search-input","searchInput");e="oninput"in 
document?"input":"propertychange",addEvent(a,e,_.debounce(function(){i.query(a.value,document.getElementById("searchLanguage").value)},100))})}(wmTest,WMTypeAhead);
\ No newline at end of file
diff --git a/prod/wikipedia.org/assets/js/index-c7d5a13f71.js 
b/prod/wikipedia.org/assets/js/index-c7d5a13f71.js
new file mode 100644
index 0000000..f4f7e24
--- /dev/null
+++ b/prod/wikipedia.org/assets/js/index-c7d5a13f71.js
@@ -0,0 +1 @@
+var _=_||{};_.now=Date.now||function(){return(new 
Date).getTime()},_.throttle=function(e,t,n){var a,i,r,o=null,s=0;n||(n={});var 
c=function(){s=n.leading===!1?0:_.now(),o=null,r=e.apply(a,i),o||(a=i=null)};return
 function(){var l=_.now();s||n.leading!==!1||(s=l);var u=t-(l-s);return 
a=this,i=arguments,0>=u||u>t?(o&&(clearTimeout(o),o=null),s=l,r=e.apply(a,i),o||(a=i=null)):o||n.trailing===!1||(o=setTimeout(c,u)),r}},_.debounce=function(e,t,n){var
 a,i,r,o,s,c=function(){var 
l=_.now()-o;t>l&&l>=0?a=setTimeout(c,t-l):(a=null,n||(s=e.apply(r,i),a||(r=i=null)))};return
 function(){r=this,i=arguments,o=_.now();var l=n&&!a;return 
a||(a=setTimeout(c,t)),l&&(s=e.apply(r,i),r=i=null),s}};var 
WMTypeAhead=function(e,t){function n(e){var t=[];for(var n in 
e)e.hasOwnProperty(n)&&t.push(n+"="+encodeURIComponent(e[n]));return 
t.join("&")}function a(){setTimeout(function(){p.innerHTML="";var 
e=document.getElementById("api_opensearch");e&&(e.src=!1)},300)}function 
i(e,t){if(u=encodeURIComponent(t)||"en",d=encodeURIComponent(e),0===d.length)return
 void a();var 
i=document.getElementById("api_opensearch"),r=document.getElementsByTagName("head")[0],o="//"+u+".wikipedia.org/w/api.php?";i&&r.removeChild(i),i=document.createElement("script"),i.id="api_opensearch";var
 
s=window.callbackStack.addCallback(window.portalOpensearchCallback),c={action:"query",format:"json",generator:"prefixsearch",prop:"pageprops|pageimages|pageterms",redirects:"",ppprop:"displaytitle",piprop:"thumbnail",pithumbsize:y,pilimit:6,wbptterms:"description",gpssearch:e,gpsnamespace:0,gpslimit:6,callback:"callbackStack.queue["+s+"]"};i.src=o+n(c),r.appendChild(i)}function
 r(e,t){var n=mw.html.escape(mw.RegExp.escape(t)),a=new 
RegExp(n,"i"),i=e.search(a),r=mw.html.escape(e);if(i>=0){var 
o=i+n.length,s=e.substring(i,o),c=e.substring(0,i),l=e.substring(o,e.length);r=c+mw.html.element("em",{"class":"suggestion-highlight"},s)+l}return
 r}function o(e){for(var t='<div 
class="suggestions-dropdown">',n=0;n<e.length;n++)if(e[n]){var 
a,i,o,s,c,l=e[n],h=!1;l.thumbnail&&l.thumbnail.source&&(h=l.thumbnail.source.replace(/\"/g,"%22"),h=h.replace(/'/g,"%27")),c=mw.html.element("p",{"class":"suggestion-description"},l.terms&&l.terms.description?l.terms.description.toString():""),s=mw.html.element("h3",{"class":"suggestion-title"},new
 
mw.html.Raw(r(l.title,d))),o=mw.html.element("div",{"class":"suggestion-text"},new
 
mw.html.Raw(s+c)),i=mw.html.element("div",{"class":"suggestion-thumbnail",style:h?"background-image:url("+h+")":!1},""),a=mw.html.element("a",{"class":"suggestion-link",href:"https://"+u+".wikipedia.org/wiki/"+encodeURIComponent(l.title.replace(/
 /gi,"_"))},new mw.html.Raw(o+i)),t+=a}return t+="</div>"}function 
s(e,t){for(var n=" active",a=0;a<t.length;a++){var 
i=t[a];i!==e?i.className=i.className.replace(n,""):/ 
active/.test(e.className)?e.className=e.className.replace(n,""):e.className+=n}}function
 c(e,t){w+=e,0>w&&(w=t-1),w>t-1&&(w=0)}function l(e){var 
t=e||window.event,n=t.which||t.keyCode;if(p.firstChild){if(40===n||38===n){var 
a=p.firstChild.childNodes,i=a.length;40===n?c(1,i):c(-1,i),g=p.firstChild?p.firstChild.childNodes[w]:!1,s(g,a)}13===n&&g&&(t.preventDefault?t.preventDefault():t.returnValue=!1,g.children[0].click())}}var
 
u,d,h,g,m="typeahead-suggestions",p=document.getElementById(m),v=document.getElementById(e),f=document.getElementById(t),w=-1,y=80*getDevicePixelRatio();return
 
p||(p=document.createElement("div"),p.id=m,v.appendChild(p)),window.callbackStack={queue:{},index:-1,incrementIndex:function(){return
 this.index+=1,this.index},addCallback:function(e){var 
t=this.incrementIndex();return 
this.queue[t]=e(t),t},deleteSelfFromQueue:function(e){delete 
this.queue[e]},deletePrevCallbacks:function(e){this.deleteSelfFromQueue(e);for(var
 t in 
this.queue)e>t&&(this.queue[t]=this.deleteSelfFromQueue.bind(window.callbackStack,t))}},window.portalOpensearchCallback=function(e){var
 t=e;return 
function(e){if(window.callbackStack.deletePrevCallbacks(t),document.activeElement===f){var
 n=[],a=e.query&&e.query.pages?e.query.pages:[];for(var i in a){var 
r=a[i];n[r.index-1]=r}var 
c=o(n);p.innerHTML=c,h=p.childNodes[0].childNodes;for(var 
l=0;l<h.length;l++){var 
u=h[l];addEvent(u,"mouseenter",s.bind(this,u,h)),addEvent(u,"mouseleave",s.bind(this,u,h))}}}},addEvent(f,"keydown",l),addEvent(f,"blur",a),{typeAheadEl:p,query:i}};!function(e,t){"use
 strict";function n(e,t){var n,a,i={};for(n=0;n<t.length;n++){var 
r=t[n].nodes;for(a=0;a<r.length;a++)r[a].contains(e)&&(i=t[n])}return 
i.name}function 
a(e){return"A"!==e.tagName&&e.parentElement?a(e.parentElement):e}function 
i(){u={event_type:"landing"},e.logEvent(s,u),u=null}function r(t){var 
i,r=t||window.event,o=r.target||r.srcElement;o.matches("a, a 
*")&&(i=a(o),u={event_type:"clickthrough",destination:i.href,section_used:n(i,c)},u.section_used&&e.logEvent(s,u))}function
 o(t){var 
a=t||window.event,i=a.target||a.srcElement;null===u&&(u={event_type:"clickthrough",section_used:n(i,c),destination:i.action}),u.section_used&&e.logEvent(s,u)}var
 
s,c,l,u,d=document.cookie.match(/GeoIP=.[^:]/);if("rejected"!==t.group&&!t.loggingDisabled){s={name:"WikipediaPortal",revision:14377354,defaults:{session_id:t.sessionId,event_type:"landing",referer:document.referrer||null,accept_language:t.userLangs.toString(),cohort:t.group},properties:{session_id:{type:"string",required:!0},event_type:{type:"string",required:!0,"enum":["landing","clickthrough"]},section_used:{type:"string",required:!1,"enum":["primary
 links","search","language search","secondary links","other languages","other 
projects"]},destination:{type:"string",required:!1},referer:{type:"string",required:!1},country:{type:"string",required:!1},accept_language:{type:"string",required:!0},cohort:{type:"string",required:!1}}},c=[{name:"primary
 links",nodes:document.querySelectorAll('[data-el-section="primary 
links"]')},{name:"search",nodes:document.querySelectorAll('[data-el-section="search"]')},{name:"language
 search",nodes:document.querySelectorAll('[data-el-section="language 
search"]')},{name:"secondary 
links",nodes:document.querySelectorAll('[data-el-section="secondary 
links"]')},{name:"other 
languages",nodes:document.querySelectorAll('[data-el-section="other 
languages"]')},{name:"other 
projects",nodes:document.querySelectorAll('[data-el-section="other 
projects"]')}],addEvent(document,"click",r),l=document.getElementsByTagName("form");for(var
 
h=0;h<l.length;h++)addEvent(l[h],"submit",o);d&&(s.defaults.country=d.toString().split("=")[1],addEvent(window,"load",i)),addEvent(window,"load",i)}}(eventLoggingLite,wmTest),function(){"use
 strict";function e(e){return document.getElementById(e)}function t(e){var 
t,n;document.querySelector&&"www-wiktionary-org"===document.body.id&&!e.match(/\W/)&&(t=document.querySelector('option[lang|="'+e+'"]'),n=t&&t.getAttribute("data-logo"),n&&document.body.setAttribute("data-logo",n))}function
 n(){var 
e=navigator.languages&&navigator.languages[0]||navigator.language||navigator.userLanguage||"";return
 e.toLowerCase().split("-")[0]}function a(){var 
e=document.cookie.match(/(?:^|\W)searchLang=([^;]+)/);return(e?e[1]:n()).toLowerCase()}function
 
i(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}function
 r(t){var 
n,a,r="data-convert-hans",o="data-converttitle-hans";if(-1!=="zh-hans,zh-cn,zh-sg,zh-my,".indexOf(t+",")){var
 
s=["zh_art","zh_others","zh_search","zh_tag","zh_top10","zh-yue_wiki","gan_wiki","hak_wiki","wuu_wiki"];for(n=0;n<s.length;n+=1)a=e(s[n]),a&&(a.hasAttribute(r)&&i(a,a.getAttribute(r)),a.hasAttribute(o)&&(a.title=a.getAttribute(o)))}}function
 o(t){var 
n;0===t.indexOf("zh")&&(n=t.substring(3),"mo"===n?n="hk":"my"===n&&(n="sg"),n&&"cn,tw,hk,sg,".indexOf(n+",")>=0&&(e("zh_wiki").href+="zh-"+n+"/",e("zh_others").href=e("zh_others").href.replace("wiki/","zh-"+n+"/")),r(t))}function
 s(){if(void 0!==window.HTMLDataListElement){var 
t=document.createElement("datalist"),n=e("searchInput");t.id="suggestions",document.body.appendChild(t),n.autocomplete="off",n.setAttribute("list","suggestions"),addEvent(n,"input",_.debounce(function(){var
 
t,a=document.getElementsByTagName("head")[0],i=e("searchLanguage").value,r=e("api_opensearch"),o=encodeURIComponent(n.value);t=i+".wikipedia.org",r&&a.removeChild(r),r=document.createElement("script"),r.id="api_opensearch",r.src="//"+encodeURIComponent(t)+"/w/api.php?action=opensearch&limit=10&format=json&callback=portalOpensearchCallback&search="+o,a.appendChild(r)},200))}}function
 c(e){if(e){var a=n(),i=a.match(/^\w+/),r=new 
Date;t(e),i&&i[0]===e?r.setTime(r.getTime()-1):r.setFullYear(r.getFullYear()+1),document.cookie="searchLang="+e+";expires="+r.toUTCString()+";domain="+location.host+";"}}function
 l(e,t){var n,a,i,r,o={ratio:1};for(n=t.split(/ *, 
*/),i=0;i<n.length;i++)a=n[i].match(/\s*(\S+)(?:\s*([\d.]+)w)?(?:\s*([\d.]+)h)?(?:\s*([\d.]+)x)?\s*/),r=a[4]&&parseFloat(a[4]),e>=r&&r>o.ratio&&(o.ratio=r,o.src=a[1],o.width=a[2]&&parseFloat(a[2]),o.height=a[3]&&parseFloat(a[3]));return
 o}function u(){var e,t,n=getDevicePixelRatio(),a=new Image;if(n>1&&void 
0===a.srcset)for(e=document.getElementsByTagName("img"),t=0;t<e.length;t++){var 
i,r=e[t],o=r.getAttribute("srcset");"string"==typeof o&&""!==o&&(i=l(n,o),void 
0!==i.src&&(r.setAttribute("src",i.src),void 
0!==i.width&&r.setAttribute("width",i.width),void 
0!==i.height&&r.setAttribute("height",i.height)))}}doWhenReady(function(){var 
n,r,s,c,l,u,d,h,g,m=a();if(m&&(o(m),n=getIso639(m),r=e("searchLanguage"))){for(s=r.getElementsByTagName("option"),c=0,l=s.length;!u&&l>c;c+=1)s[c].value===n&&(u=n);!u&&document.querySelector&&(d=document.querySelector('.langlist
 
a[lang|="'+n+'"]'),d&&(u=n,h=document.createElement("option"),h.setAttribute("lang",n),h.setAttribute("value",n),g=d.textContent||d.innerText||n,i(h,g),r.appendChild(h))),u&&(r.value=u,t(u))}}),window.wmSuggestionsEL=null,window.portalOpensearchCallback=_.debounce(function(t){var
 
n,a=window.wmSuggestionsEL||e("suggestions"),i=a.children,r=document.createDocumentFragment();for(n=0;n<t[1].length;n+=1){var
 
o=i[n]||document.createElement("option");o.value=t[1][n],i[n]||r.appendChild(o)}a.appendChild(r.cloneNode(!0))},100),doWhenReady(function(){var
 
t,n,a,i=e("searchInput"),r=e("searchLanguage");if(i)for(i.setAttribute("results","10"),s(),void
 
0===i.autofocus?i.focus():window.scroll(0,0),t=location.search&&location.search.substr(1).split("&"),n=0;n<t.length;n+=1)if(a=t[n].split("="),"search"===a[0]&&a[1]){i.value=decodeURIComponent(a[1].replace(/\+/g,"
 
"));break}addEvent(r,"change",function(){r.blur(),c(r.value)})}),doWhenReady(function(){var
 
e=document.searchwiki&&document.searchwiki.elements.uselang;e&&(e.value=n())}),doWhenReady(u)}(),window.mw||(window.mw=window.mediaWiki={loader:{state:function(){}}}),function(e,t){doWhenReady(function(){var
 
e,n=document.getElementById("searchInput"),a=n.cloneNode(!0);n.parentNode.replaceChild(a,n),a.focus();var
 i=new t("search-input","searchInput");e="oninput"in 
document?"input":"propertychange",addEvent(a,e,_.debounce(function(){i.query(a.value,document.getElementById("searchLanguage").value)},100))})}(wmTest,WMTypeAhead);
\ No newline at end of file
diff --git a/prod/wikipedia.org/index.html b/prod/wikipedia.org/index.html
index 9e50259..185adf4 100644
--- a/prod/wikipedia.org/index.html
+++ b/prod/wikipedia.org/index.html
@@ -644,7 +644,7 @@
 </div>
 <div style="text-align:center"><a 
href="//wikimediafoundation.org/wiki/Terms_of_Use">Terms of Use</a> | <a 
href="//wikimediafoundation.org/wiki/Privacy_policy">Privacy Policy</a></div>
 <![if gt IE 7]>
-<script src="portal/wikipedia.org/assets/js/index-5b9d82d3b8.js"></script>
+<script src="portal/wikipedia.org/assets/js/index-c7d5a13f71.js"></script>
 <![endif]>
 <![if gt IE 9]>
 <script src="portal/wikipedia.org/assets/js/gt-ie9-c84bf66d33.js"></script>

-- 
To view, visit https://gerrit.wikimedia.org/r/281983
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I16574aedb9321c7e002c501ed93fd29f0b81df39
Gerrit-PatchSet: 4
Gerrit-Project: wikimedia/portals
Gerrit-Branch: master
Gerrit-Owner: Jdrewniak <[email protected]>
Gerrit-Reviewer: JGirault <[email protected]>
Gerrit-Reviewer: Jdrewniak <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to