Jdrewniak has uploaded a new change for review. https://gerrit.wikimedia.org/r/276488
Change subject: Checks if localstorage is enabled and can be written to. Prevents browsers from throwing error in private browsing mode. ...................................................................... Checks if localstorage is enabled and can be written to. Prevents browsers from throwing error in private browsing mode. Bug: T129408 Change-Id: I949450a9a9aa94481e79e8ac0296618fc97142ad --- M dev/wikipedia.org/assets/js/wm-test.js M dev/wikipedia.org/assets/rev-manifest.json R prod/wikipedia.org/assets/js/index-ed68a8db0a.js M prod/wikipedia.org/index.html 4 files changed, 15 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/wikimedia/portals refs/changes/88/276488/1 diff --git a/dev/wikipedia.org/assets/js/wm-test.js b/dev/wikipedia.org/assets/js/wm-test.js index 5257225..6c37d60 100644 --- a/dev/wikipedia.org/assets/js/wm-test.js +++ b/dev/wikipedia.org/assets/js/wm-test.js @@ -53,9 +53,20 @@ } } + function isLocalStorageEnabled() { + var isEnabled = true; + try { + localStorage.setItem( 'lsTest', 'lsTest' ); + localStorage.removeItem( 'slTest' ); + } catch ( err ) { + isEnabled = false; + } + return isEnabled; + } + if ( testOnly ) { group = location.hash.slice( 1 ); - } else if ( window.localStorage ) { + } else if ( window.localStorage && isLocalStorageEnabled() ) { var portalGroup = localStorage.getItem( KEYS.GROUP ), portalSessionId = localStorage.getItem( KEYS.SESSION_ID ), expires = localStorage.getItem( KEYS.EXPIRES ), diff --git a/dev/wikipedia.org/assets/rev-manifest.json b/dev/wikipedia.org/assets/rev-manifest.json index 8607b09..e9bec13 100644 --- a/dev/wikipedia.org/assets/rev-manifest.json +++ b/dev/wikipedia.org/assets/rev-manifest.json @@ -1,4 +1,4 @@ { "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-b335ba9eb0.js" + "portal/wikipedia.org/assets/js/index.js": "portal/wikipedia.org/assets/js/index-ed68a8db0a.js" } \ No newline at end of file diff --git a/prod/wikipedia.org/assets/js/index-b335ba9eb0.js b/prod/wikipedia.org/assets/js/index-ed68a8db0a.js similarity index 91% rename from prod/wikipedia.org/assets/js/index-b335ba9eb0.js rename to prod/wikipedia.org/assets/js/index-ed68a8db0a.js index 1238109..78f3ce0 100644 --- a/prod/wikipedia.org/assets/js/index-b335ba9eb0.js +++ b/prod/wikipedia.org/assets/js/index-ed68a8db0a.js @@ -1 +1 @@ -function addEvent(e,t,n){e&&(e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&(attachedEvents.push([e,t,n]),e.attachEvent("on"+t,n)))}function removeEvent(e,t,n){e&&(e.removeEventListener?e.removeEventListener(t,n):e.detachEvent&&e.detachEvent("on"+t,n))}function doWhenReady(e){var t=function(){removeEvent(document,"DOMContentLoaded",t),removeEvent(window,"load",t),e()};"complete"===document.readyState?e():(addEvent(document,"DOMContentLoaded",t),addEvent(window,"load",t))}window.JSON||(window.JSON={parse:function(sJSON){return eval("("+sJSON+")")},stringify:function(){var e=Object.prototype.toString,t=Array.isArray||function(t){return"[object Array]"===e.call(t)},n={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},r=function(e){return n[e]||"\\u"+(e.charCodeAt(0)+65536).toString(16).substr(1)},o=/[\\"\u0000-\u001F\u2028\u2029]/g;return function a(n){if(null==n)return"null";if("number"==typeof n)return isFinite(n)?n.toString():"null";if("boolean"==typeof n)return n.toString();if("object"==typeof n){if("function"==typeof n.toJSON)return a(n.toJSON());if(t(n)){for(var i="[",s=0;s<n.length;s++)i+=(s?", ":"")+a(n[s]);return i+"]"}if("[object Object]"===e.call(n)){var c=[];for(var l in n)n.hasOwnProperty(l)&&c.push(a(l)+": "+a(n[l]));return"{"+c.join(", ")+"}"}}return'"'+n.toString().replace(o,r)+'"'}}()}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var n;if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),o=r.length>>>0;if(0===o)return-1;var a=+t||0;if(Math.abs(a)===1/0&&(a=0),a>=o)return-1;for(n=Math.max(a>=0?a:o-Math.abs(a),0);o>n;){if(n in r&&r[n]===e)return n;n++}return-1}),function(){window.document.querySelectorAll||(document.querySelectorAll=document.body.querySelectorAll=Object.querySelectorAll=function(e,t,n,r,o){var a=document,i=a.createStyleSheet();for(o=a.all,t=[],e=e.replace(/\[for\b/gi,"[htmlFor").split(","),n=e.length;n--;){for(i.addRule(e[n],"k:v"),r=o.length;r--;)o[r].currentStyle.k&&t.push(o[r]);i.removeRule(0)}return t})}(),document.querySelector||(document.querySelector=function(e){var t=document.querySelectorAll(e);return t.length?t[0]:null}),Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,r=function(){},o=function(){return n.apply(this instanceof r?this:e,t.concat(Array.prototype.slice.call(arguments)))};return this.prototype&&(r.prototype=this.prototype),o.prototype=new r,o}),window.Element&&!Element.prototype.matches&&(Element.prototype.matches=function e(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),n=e.length;--n>=0&&e.item(n)!==this;);return n>-1});var attachedEvents=[];window.onunload=function(){var e,t;for(e=0;e<attachedEvents.length;e++)t=attachedEvents[e],t[0]&&t[0].detachEvent("on"+t[1],t[2]);attachedEvents=[]},function(){"use strict";var e,t,n="http://bits.beta.wmflabs.org/event.gif",r=[];/www.wikipedia.org/.test(location.hostname)&&(n="//www.wikipedia.org/beacon/event"),t={extend:function(e,t){var n,r={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&e[n]&&(r[n]=e[n]);for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]&&(r[n]=t[n]);return r},noop:function(){}};for(var o=0;256>o;o++)r[o]=(o+256).toString(16).slice(1);e=window.eventLoggingLite={schema:{},maxUrlSize:2e3,byteToHex:r,checkUrlSize:function(t,n){var r;return n.length>e.maxUrlSize?r="Url exceeds maximum length":void 0},generateRandomSessionId:function(){var t,n,r,o=new Array(8),a=window.crypto||window.msCrypto;if(a&&a.getRandomValues)t=new Uint8Array(8),a.getRandomValues(t);else for(t=new Array(8),n=0;8>n;n++)0===(3&n)&&(r=4294967296*Math.random()),t[n]=r>>>((3&n)<<3)&255;for(n=0;8>n;n++)o[n]=e.byteToHex[t[n]];return o.join("")},validate:function(e,t){var n,r,o,a=[];if(!t||!t.properties)return a.push("Missing or empty schema"),a;for(n in e)t.properties.hasOwnProperty(n)||a.push("Undeclared property: "+n);for(n in t.properties)o=t.properties[n],e.hasOwnProperty(n)?(r=e[n],o["enum"]&&o.required&&-1===o["enum"].indexOf(r)&&a.push('Value "'+JSON.stringify(r)+'" for property "'+n+'" is not one of '+JSON.stringify(o["enum"]))):o.required&&a.push("Missing property:",n);return a},prepare:function(n,r){for(var o=t.extend(n.defaults,r),a=e.validate(o,n);a.length;)console.log(a[a.length-1]),a.pop();return{event:o,revision:n.revision||-1,schema:n.name,webHost:location.hostname,wiki:"metawiki"}},makeBeaconUrl:function(e){var t=encodeURIComponent(JSON.stringify(e));return n+"?"+t+";"},sendBeacon:/1|yes/.test(navigator.doNotTrack)||!n?t.noop:navigator.sendBeacon?function(e){try{navigator.sendBeacon(e)}catch(t){}}:function(e){document.createElement("img").src=e},logEvent:function(t,n){var r=e.prepare(t,n),o=e.makeBeaconUrl(r),a=e.checkUrlSize(t,o);a||e.sendBeacon(o)}}}(),window.wmTest=function(e){"use strict";function t(e,t){var n=parseInt(e.slice(0,13),16);return n%t===0}function n(e){return t(e,a)?"baseline":"rejected"}var r,o=e.generateRandomSessionId(),a=2,i=9e5,s={GROUP:"portal_test_group",SESSION_ID:"portal_session_id",EXPIRES:"portal_test_group_expires"},c=!1;if(/www.wikipedia.org/.test(location.hostname)&&(a=200),c)r=location.hash.slice(1);else if(window.localStorage){var l=localStorage.getItem(s.GROUP),u=localStorage.getItem(s.SESSION_ID),d=localStorage.getItem(s.EXPIRES),m=(new Date).getTime();d&&u&&l&&m<parseInt(d,10)?(o=u,r="null"===l?null:l):(r=n(o),localStorage.setItem(s.SESSION_ID,o),localStorage.setItem(s.GROUP,r)),localStorage.setItem(s.EXPIRES,m+i)}else r="rejected";return{loggingDisabled:c,sessionId:o,group:r}}(eventLoggingLite);var mw=mw||{};mw.html=function(){function e(e){switch(e){case"'":return"'";case'"':return""";case"<":return"<";case">":return">";case"&":return"&"}}return{escape:function(t){return t.replace(/['"<>&]/g,e)},element:function(e,t,n){var r,o,a="<"+e;for(o in t){if(r=t[o],r===!0)r=o;else if(r===!1)continue;a+=" "+o+'="'+this.escape(String(r))+'"'}if(void 0===n||null===n)return a+="/>";switch(a+=">",typeof n){case"string":a+=this.escape(n);break;case"number":case"boolean":a+=String(n);break;default:if(n instanceof this.Raw)a+=n.value;else{if(!(n instanceof this.Cdata))throw new Error("mw.html.element: Invalid type of contents");if(/<\/[a-zA-z]/.test(n.value))throw new Error("mw.html.element: Illegal end tag found in CDATA");a+=n.value}}return a+="</"+e+">"},Raw:function(e){this.value=e},Cdata:function(e){this.value=e}}}();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 r(e,t){if(u=encodeURIComponent(t)||"en",d=encodeURIComponent(e),0===d.length)return void a();var r=document.getElementById("api_opensearch"),o=document.getElementsByTagName("head")[0],i="//"+u+".wikipedia.org/w/api.php?";r&&o.removeChild(r),r=document.createElement("script"),r.id="api_opensearch";var s={action:"query",format:"json",generator:"prefixsearch",prop:"pageprops|pageimages|pageterms",redirects:"",list:"prefixsearch",ppprop:"displaytitle",piprop:"thumbnail",pithumbsize:80,pilimit:6,wbptterms:"description",gpssearch:e,gpsnamespace:0,gpslimit:6,pssearch:e,pslimit:6,callback:"portalOpensearchCallback"};r.src=i+n(s),o.appendChild(r)}function o(e){for(var t='<ul class="suggestions-dropdown">',n=0;n<e.length;n++){var r,o,a,s,c,l,m=e[n],h=!1;m.thumbnail&&m.thumbnail.source&&(h=m.thumbnail.source.replace(/\"/g,"%22"),h=h.replace(/'/g,"%27")),l=mw.html.element("p",{"class":"suggestion-description"},m.terms&&m.terms.description?m.terms.description.toString():""),c=mw.html.element("h3",{"class":"suggestion-title"},new mw.html.Raw(i(m.title,d))),s=mw.html.element("div",{"class":"suggestion-text"},new mw.html.Raw(c+l)),a=mw.html.element("div",{"class":"suggestion-thumbnail",style:h?"background-image:url("+h+")":!1},""),o=mw.html.element("a",{"class":"suggestion-link",href:"https://"+u+".wikipedia.org/wiki/"+encodeURIComponent(m.title.replace(/ /gi,"_"))},new mw.html.Raw(s+a)),r=mw.html.element("li",{"class":"suggestion-item"},new mw.html.Raw(o)),t+=r}return t+="</ul>"}function a(){setTimeout(function(){g.innerHTML="";var e=document.getElementById("api_opensearch");e&&(e.src=!1)},300)}function i(e,t){var n=mw.html.escape(t),r=new RegExp(n,"i"),o=e.search(r),a=mw.html.escape(e);if(o>=0){var i=o+n.length,s=e.substring(o,i),c=e.substring(0,o),l=e.substring(i,e.length);a=c+mw.html.element("em",{"class":"suggestion-highlight"},s)+l}return a}function s(e,t){for(var n=" active",r=0;r<t.length;r++){var o=t[r];o!==e?o.className=o.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(g.firstChild){if(40===n||38===n){var r=g.firstChild.childNodes,o=r.length;40===n?c(1,o):c(-1,o),h=g.firstChild?g.firstChild.childNodes[w]:!1,s(h,r)}13===n&&h&&(t.preventDefault?t.preventDefault():t.returnValue=!1,h.children[0].click())}}var u,d,m,h,p="typeahead-suggestions",g=document.getElementById(p),f=document.getElementById(e),v=document.getElementById(t),w=-1;return g||(g=document.createElement("div"),g.id=p,f.appendChild(g)),window.portalOpensearchCallback=function(e){if(document.activeElement===v){var t=[],n=e.query&&e.query.pages?e.query.pages:[];for(var r in n){var a=n[r];t[a.index-1]=a}var i=o(t);g.innerHTML=i,m=g.childNodes[0].childNodes;for(var c=0;c<m.length;c++){var l=m[c];addEvent(l,"mouseenter",s.bind(this,l,m)),addEvent(l,"mouseleave",s.bind(this,l,m))}}},addEvent(v,"keydown",l),addEvent(v,"blur",a),{typeAheadEl:g,query:r}},_=_||{};_.now=Date.now||function(){return(new Date).getTime()},_.throttle=function(e,t,n){var r,o,a,i=null,s=0;n||(n={});var c=function(){s=n.leading===!1?0:_.now(),i=null,a=e.apply(r,o),i||(r=o=null)};return function(){var l=_.now();s||n.leading!==!1||(s=l);var u=t-(l-s);return r=this,o=arguments,0>=u||u>t?(i&&(clearTimeout(i),i=null),s=l,a=e.apply(r,o),i||(r=o=null)):i||n.trailing===!1||(i=setTimeout(c,u)),a}},_.debounce=function(e,t,n){var r,o,a,i,s,c=function(){var l=_.now()-i;t>l&&l>=0?r=setTimeout(c,t-l):(r=null,n||(s=e.apply(a,o),r||(a=o=null)))};return function(){a=this,o=arguments,i=_.now();var l=n&&!r;return r||(r=setTimeout(c,t)),l&&(s=e.apply(a,o),a=o=null),s}},function(e,t){"use strict";function n(e,t){var n,r,o={};for(n=0;n<t.length;n++){var a=t[n].nodes;for(r=0;r<a.length;r++)a[r].contains(e)&&(o=t[n])}return o.name}function r(e){return"A"!==e.tagName&&e.parentElement?r(e.parentElement):e}function o(){u={event_type:"landing"},e.logEvent(s,u),u=null}function a(t){var o,a=t||window.event,i=a.target||a.srcElement;i.matches("a, a *")&&(o=r(i),u={event_type:"clickthrough",destination:o.href,section_used:n(o,c)},u.section_used&&e.logEvent(s,u))}function i(t){var r=t||window.event,o=r.target||r.srcElement;null===u&&(u={event_type:"clickthrough",section_used:n(o,c),destination:o.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:navigator&&navigator.language?navigator.language:navigator.browserLanguage,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",a),l=document.getElementsByTagName("form");for(var m=0;m<l.length;m++)addEvent(l[m],"submit",i);d&&(s.defaults.country=d.toString().split("=")[1],addEvent(window,"load",o)),addEvent(window,"load",o)}}(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 r(){var e=document.cookie.match(/(?:^|\W)searchLang=([^;]+)/);return(e?e[1]:n()).toLowerCase()}function o(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}function a(t){var n,r,a="data-convert-hans",i="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)r=e(s[n]),r&&(r.hasAttribute(a)&&o(r,r.getAttribute(a)),r.hasAttribute(i)&&(r.title=r.getAttribute(i)))}}function i(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+"/")),a(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,r=document.getElementsByTagName("head")[0],o=e("searchLanguage").value,a=e("api_opensearch"),i=encodeURIComponent(n.value);t=o+".wikipedia.org",a&&r.removeChild(a),a=document.createElement("script"),a.id="api_opensearch",a.src="//"+encodeURIComponent(t)+"/w/api.php?action=opensearch&limit=10&format=json&callback=portalOpensearchCallback&search="+i,r.appendChild(a)},200))}}function c(e){if(e){var r=n(),o=r.match(/^\w+/),a=new Date;t(e),o&&o[0]===e?a.setTime(a.getTime()-1):a.setFullYear(a.getFullYear()+1),document.cookie="searchLang="+e+";expires="+a.toUTCString()+";domain="+location.host+";"}}function l(){return void 0!==window.devicePixelRatio?window.devicePixelRatio:void 0!==window.msMatchMedia?window.msMatchMedia("(min-resolution: 192dpi)").matches?2:window.msMatchMedia("(min-resolution: 144dpi)").matches?1.5:1:1}function u(e,t){var n,r,o,a,i={ratio:1};for(n=t.split(/ *, */),o=0;o<n.length;o++)r=n[o].match(/\s*(\S+)(?:\s*([\d.]+)w)?(?:\s*([\d.]+)h)?(?:\s*([\d.]+)x)?\s*/),a=r[4]&&parseFloat(r[4]),e>=a&&a>i.ratio&&(i.ratio=a,i.src=r[1],i.width=r[2]&&parseFloat(r[2]),i.height=r[3]&&parseFloat(r[3]));return i}function d(){var e,t,n=l(),r=new Image;if(n>1&&void 0===r.srcset)for(e=document.getElementsByTagName("img"),t=0;t<e.length;t++){var o,a=e[t],i=a.getAttribute("srcset");"string"==typeof i&&""!==i&&(o=u(n,i),void 0!==o.src&&(a.setAttribute("src",o.src),void 0!==o.width&&a.setAttribute("width",o.width),void 0!==o.height&&a.setAttribute("height",o.height)))}}doWhenReady(function(){var n,a,s,c,l,u,d,m,h,p=r();if(p&&(i(p),n=p.match(/^\w+/),n&&(n="nb"===n[0]?"no":n[0],a=e("searchLanguage")))){for(s=a.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,m=document.createElement("option"),m.setAttribute("lang",n),m.setAttribute("value",n),h=d.textContent||d.innerText||n,o(m,h),a.appendChild(m))),u&&(a.value=u,t(u))}}),window.wmSuggestionsEL=null,window.portalOpensearchCallback=_.debounce(function(t){var n,r=window.wmSuggestionsEL||e("suggestions"),o=r.children,a=document.createDocumentFragment();for(n=0;n<t[1].length;n+=1){var i=o[n]||document.createElement("option");i.value=t[1][n],o[n]||a.appendChild(i)}r.appendChild(a.cloneNode(!0))},100),doWhenReady(function(){var t,n,r,o=e("searchInput"),a=e("searchLanguage");if(o)for(o.setAttribute("results","10"),s(),void 0===o.autofocus?o.focus():window.scroll(0,0),t=location.search&&location.search.substr(1).split("&"),n=0;n<t.length;n+=1)if(r=t[n].split("="),"search"===r[0]&&r[1]){o.value=decodeURIComponent(r[1].replace(/\+/g," "));break}addEvent(a,"change",function(){a.blur(),c(a.value)})}),doWhenReady(function(){var e=document.searchwiki&&document.searchwiki.elements.uselang;e&&(e.value=n())}),doWhenReady(d)}(),window.mw||(window.mw=window.mediaWiki={loader:{state:function(){}}}),function(e,t){doWhenReady(function(){var e,n=document.getElementById("searchInput"),r=n.cloneNode(!0);n.parentNode.replaceChild(r,n),r.focus();var o=new t("search-input","searchInput");e="oninput"in document?"input":"propertychange",addEvent(r,e,_.debounce(function(){o.query(r.value,document.getElementById("searchLanguage").value)},100))})}(wmTest,WMTypeAhead); \ No newline at end of file +function addEvent(e,t,n){e&&(e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&(attachedEvents.push([e,t,n]),e.attachEvent("on"+t,n)))}function removeEvent(e,t,n){e&&(e.removeEventListener?e.removeEventListener(t,n):e.detachEvent&&e.detachEvent("on"+t,n))}function doWhenReady(e){var t=function(){removeEvent(document,"DOMContentLoaded",t),removeEvent(window,"load",t),e()};"complete"===document.readyState?e():(addEvent(document,"DOMContentLoaded",t),addEvent(window,"load",t))}window.JSON||(window.JSON={parse:function(sJSON){return eval("("+sJSON+")")},stringify:function(){var e=Object.prototype.toString,t=Array.isArray||function(t){return"[object Array]"===e.call(t)},n={'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},r=function(e){return n[e]||"\\u"+(e.charCodeAt(0)+65536).toString(16).substr(1)},o=/[\\"\u0000-\u001F\u2028\u2029]/g;return function a(n){if(null==n)return"null";if("number"==typeof n)return isFinite(n)?n.toString():"null";if("boolean"==typeof n)return n.toString();if("object"==typeof n){if("function"==typeof n.toJSON)return a(n.toJSON());if(t(n)){for(var i="[",s=0;s<n.length;s++)i+=(s?", ":"")+a(n[s]);return i+"]"}if("[object Object]"===e.call(n)){var c=[];for(var l in n)n.hasOwnProperty(l)&&c.push(a(l)+": "+a(n[l]));return"{"+c.join(", ")+"}"}}return'"'+n.toString().replace(o,r)+'"'}}()}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var n;if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),o=r.length>>>0;if(0===o)return-1;var a=+t||0;if(Math.abs(a)===1/0&&(a=0),a>=o)return-1;for(n=Math.max(a>=0?a:o-Math.abs(a),0);o>n;){if(n in r&&r[n]===e)return n;n++}return-1}),function(){window.document.querySelectorAll||(document.querySelectorAll=document.body.querySelectorAll=Object.querySelectorAll=function(e,t,n,r,o){var a=document,i=a.createStyleSheet();for(o=a.all,t=[],e=e.replace(/\[for\b/gi,"[htmlFor").split(","),n=e.length;n--;){for(i.addRule(e[n],"k:v"),r=o.length;r--;)o[r].currentStyle.k&&t.push(o[r]);i.removeRule(0)}return t})}(),document.querySelector||(document.querySelector=function(e){var t=document.querySelectorAll(e);return t.length?t[0]:null}),Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,r=function(){},o=function(){return n.apply(this instanceof r?this:e,t.concat(Array.prototype.slice.call(arguments)))};return this.prototype&&(r.prototype=this.prototype),o.prototype=new r,o}),window.Element&&!Element.prototype.matches&&(Element.prototype.matches=function e(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),n=e.length;--n>=0&&e.item(n)!==this;);return n>-1});var attachedEvents=[];window.onunload=function(){var e,t;for(e=0;e<attachedEvents.length;e++)t=attachedEvents[e],t[0]&&t[0].detachEvent("on"+t[1],t[2]);attachedEvents=[]},function(){"use strict";var e,t,n="http://bits.beta.wmflabs.org/event.gif",r=[];/www.wikipedia.org/.test(location.hostname)&&(n="//www.wikipedia.org/beacon/event"),t={extend:function(e,t){var n,r={};for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&e[n]&&(r[n]=e[n]);for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]&&(r[n]=t[n]);return r},noop:function(){}};for(var o=0;256>o;o++)r[o]=(o+256).toString(16).slice(1);e=window.eventLoggingLite={schema:{},maxUrlSize:2e3,byteToHex:r,checkUrlSize:function(t,n){var r;return n.length>e.maxUrlSize?r="Url exceeds maximum length":void 0},generateRandomSessionId:function(){var t,n,r,o=new Array(8),a=window.crypto||window.msCrypto;if(a&&a.getRandomValues)t=new Uint8Array(8),a.getRandomValues(t);else for(t=new Array(8),n=0;8>n;n++)0===(3&n)&&(r=4294967296*Math.random()),t[n]=r>>>((3&n)<<3)&255;for(n=0;8>n;n++)o[n]=e.byteToHex[t[n]];return o.join("")},validate:function(e,t){var n,r,o,a=[];if(!t||!t.properties)return a.push("Missing or empty schema"),a;for(n in e)t.properties.hasOwnProperty(n)||a.push("Undeclared property: "+n);for(n in t.properties)o=t.properties[n],e.hasOwnProperty(n)?(r=e[n],o["enum"]&&o.required&&-1===o["enum"].indexOf(r)&&a.push('Value "'+JSON.stringify(r)+'" for property "'+n+'" is not one of '+JSON.stringify(o["enum"]))):o.required&&a.push("Missing property:",n);return a},prepare:function(n,r){for(var o=t.extend(n.defaults,r),a=e.validate(o,n);a.length;)console.log(a[a.length-1]),a.pop();return{event:o,revision:n.revision||-1,schema:n.name,webHost:location.hostname,wiki:"metawiki"}},makeBeaconUrl:function(e){var t=encodeURIComponent(JSON.stringify(e));return n+"?"+t+";"},sendBeacon:/1|yes/.test(navigator.doNotTrack)||!n?t.noop:navigator.sendBeacon?function(e){try{navigator.sendBeacon(e)}catch(t){}}:function(e){document.createElement("img").src=e},logEvent:function(t,n){var r=e.prepare(t,n),o=e.makeBeaconUrl(r),a=e.checkUrlSize(t,o);a||e.sendBeacon(o)}}}(),window.wmTest=function(e){"use strict";function t(e,t){var n=parseInt(e.slice(0,13),16);return n%t===0}function n(e){return t(e,i)?"baseline":"rejected"}function r(){var e=!0;try{localStorage.setItem("lsTest","lsTest"),localStorage.removeItem("slTest")}catch(t){e=!1}return e}var o,a=e.generateRandomSessionId(),i=2,s=9e5,c={GROUP:"portal_test_group",SESSION_ID:"portal_session_id",EXPIRES:"portal_test_group_expires"},l=!1;if(/www.wikipedia.org/.test(location.hostname)&&(i=200),l)o=location.hash.slice(1);else if(window.localStorage&&r()){var u=localStorage.getItem(c.GROUP),d=localStorage.getItem(c.SESSION_ID),m=localStorage.getItem(c.EXPIRES),h=(new Date).getTime();m&&d&&u&&h<parseInt(m,10)?(a=d,o="null"===u?null:u):(o=n(a),localStorage.setItem(c.SESSION_ID,a),localStorage.setItem(c.GROUP,o)),localStorage.setItem(c.EXPIRES,h+s)}else o="rejected";return{loggingDisabled:l,sessionId:a,group:o}}(eventLoggingLite);var mw=mw||{};mw.html=function(){function e(e){switch(e){case"'":return"'";case'"':return""";case"<":return"<";case">":return">";case"&":return"&"}}return{escape:function(t){return t.replace(/['"<>&]/g,e)},element:function(e,t,n){var r,o,a="<"+e;for(o in t){if(r=t[o],r===!0)r=o;else if(r===!1)continue;a+=" "+o+'="'+this.escape(String(r))+'"'}if(void 0===n||null===n)return a+="/>";switch(a+=">",typeof n){case"string":a+=this.escape(n);break;case"number":case"boolean":a+=String(n);break;default:if(n instanceof this.Raw)a+=n.value;else{if(!(n instanceof this.Cdata))throw new Error("mw.html.element: Invalid type of contents");if(/<\/[a-zA-z]/.test(n.value))throw new Error("mw.html.element: Illegal end tag found in CDATA");a+=n.value}}return a+="</"+e+">"},Raw:function(e){this.value=e},Cdata:function(e){this.value=e}}}();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 r(e,t){if(u=encodeURIComponent(t)||"en",d=encodeURIComponent(e),0===d.length)return void a();var r=document.getElementById("api_opensearch"),o=document.getElementsByTagName("head")[0],i="//"+u+".wikipedia.org/w/api.php?";r&&o.removeChild(r),r=document.createElement("script"),r.id="api_opensearch";var s={action:"query",format:"json",generator:"prefixsearch",prop:"pageprops|pageimages|pageterms",redirects:"",list:"prefixsearch",ppprop:"displaytitle",piprop:"thumbnail",pithumbsize:80,pilimit:6,wbptterms:"description",gpssearch:e,gpsnamespace:0,gpslimit:6,pssearch:e,pslimit:6,callback:"portalOpensearchCallback"};r.src=i+n(s),o.appendChild(r)}function o(e){for(var t='<ul class="suggestions-dropdown">',n=0;n<e.length;n++){var r,o,a,s,c,l,m=e[n],h=!1;m.thumbnail&&m.thumbnail.source&&(h=m.thumbnail.source.replace(/\"/g,"%22"),h=h.replace(/'/g,"%27")),l=mw.html.element("p",{"class":"suggestion-description"},m.terms&&m.terms.description?m.terms.description.toString():""),c=mw.html.element("h3",{"class":"suggestion-title"},new mw.html.Raw(i(m.title,d))),s=mw.html.element("div",{"class":"suggestion-text"},new mw.html.Raw(c+l)),a=mw.html.element("div",{"class":"suggestion-thumbnail",style:h?"background-image:url("+h+")":!1},""),o=mw.html.element("a",{"class":"suggestion-link",href:"https://"+u+".wikipedia.org/wiki/"+encodeURIComponent(m.title.replace(/ /gi,"_"))},new mw.html.Raw(s+a)),r=mw.html.element("li",{"class":"suggestion-item"},new mw.html.Raw(o)),t+=r}return t+="</ul>"}function a(){setTimeout(function(){p.innerHTML="";var e=document.getElementById("api_opensearch");e&&(e.src=!1)},300)}function i(e,t){var n=mw.html.escape(t),r=new RegExp(n,"i"),o=e.search(r),a=mw.html.escape(e);if(o>=0){var i=o+n.length,s=e.substring(o,i),c=e.substring(0,o),l=e.substring(i,e.length);a=c+mw.html.element("em",{"class":"suggestion-highlight"},s)+l}return a}function s(e,t){for(var n=" active",r=0;r<t.length;r++){var o=t[r];o!==e?o.className=o.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 r=p.firstChild.childNodes,o=r.length;40===n?c(1,o):c(-1,o),h=p.firstChild?p.firstChild.childNodes[w]:!1,s(h,r)}13===n&&h&&(t.preventDefault?t.preventDefault():t.returnValue=!1,h.children[0].click())}}var u,d,m,h,g="typeahead-suggestions",p=document.getElementById(g),f=document.getElementById(e),v=document.getElementById(t),w=-1;return p||(p=document.createElement("div"),p.id=g,f.appendChild(p)),window.portalOpensearchCallback=function(e){if(document.activeElement===v){var t=[],n=e.query&&e.query.pages?e.query.pages:[];for(var r in n){var a=n[r];t[a.index-1]=a}var i=o(t);p.innerHTML=i,m=p.childNodes[0].childNodes;for(var c=0;c<m.length;c++){var l=m[c];addEvent(l,"mouseenter",s.bind(this,l,m)),addEvent(l,"mouseleave",s.bind(this,l,m))}}},addEvent(v,"keydown",l),addEvent(v,"blur",a),{typeAheadEl:p,query:r}},_=_||{};_.now=Date.now||function(){return(new Date).getTime()},_.throttle=function(e,t,n){var r,o,a,i=null,s=0;n||(n={});var c=function(){s=n.leading===!1?0:_.now(),i=null,a=e.apply(r,o),i||(r=o=null)};return function(){var l=_.now();s||n.leading!==!1||(s=l);var u=t-(l-s);return r=this,o=arguments,0>=u||u>t?(i&&(clearTimeout(i),i=null),s=l,a=e.apply(r,o),i||(r=o=null)):i||n.trailing===!1||(i=setTimeout(c,u)),a}},_.debounce=function(e,t,n){var r,o,a,i,s,c=function(){var l=_.now()-i;t>l&&l>=0?r=setTimeout(c,t-l):(r=null,n||(s=e.apply(a,o),r||(a=o=null)))};return function(){a=this,o=arguments,i=_.now();var l=n&&!r;return r||(r=setTimeout(c,t)),l&&(s=e.apply(a,o),a=o=null),s}},function(e,t){"use strict";function n(e,t){var n,r,o={};for(n=0;n<t.length;n++){var a=t[n].nodes;for(r=0;r<a.length;r++)a[r].contains(e)&&(o=t[n])}return o.name}function r(e){return"A"!==e.tagName&&e.parentElement?r(e.parentElement):e}function o(){u={event_type:"landing"},e.logEvent(s,u),u=null}function a(t){var o,a=t||window.event,i=a.target||a.srcElement;i.matches("a, a *")&&(o=r(i),u={event_type:"clickthrough",destination:o.href,section_used:n(o,c)},u.section_used&&e.logEvent(s,u))}function i(t){var r=t||window.event,o=r.target||r.srcElement;null===u&&(u={event_type:"clickthrough",section_used:n(o,c),destination:o.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:navigator&&navigator.language?navigator.language:navigator.browserLanguage,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",a),l=document.getElementsByTagName("form");for(var m=0;m<l.length;m++)addEvent(l[m],"submit",i);d&&(s.defaults.country=d.toString().split("=")[1],addEvent(window,"load",o)),addEvent(window,"load",o)}}(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 r(){var e=document.cookie.match(/(?:^|\W)searchLang=([^;]+)/);return(e?e[1]:n()).toLowerCase()}function o(e,t){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}function a(t){var n,r,a="data-convert-hans",i="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)r=e(s[n]),r&&(r.hasAttribute(a)&&o(r,r.getAttribute(a)),r.hasAttribute(i)&&(r.title=r.getAttribute(i)))}}function i(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+"/")),a(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,r=document.getElementsByTagName("head")[0],o=e("searchLanguage").value,a=e("api_opensearch"),i=encodeURIComponent(n.value);t=o+".wikipedia.org",a&&r.removeChild(a),a=document.createElement("script"),a.id="api_opensearch",a.src="//"+encodeURIComponent(t)+"/w/api.php?action=opensearch&limit=10&format=json&callback=portalOpensearchCallback&search="+i,r.appendChild(a)},200))}}function c(e){if(e){var r=n(),o=r.match(/^\w+/),a=new Date;t(e),o&&o[0]===e?a.setTime(a.getTime()-1):a.setFullYear(a.getFullYear()+1),document.cookie="searchLang="+e+";expires="+a.toUTCString()+";domain="+location.host+";"}}function l(){return void 0!==window.devicePixelRatio?window.devicePixelRatio:void 0!==window.msMatchMedia?window.msMatchMedia("(min-resolution: 192dpi)").matches?2:window.msMatchMedia("(min-resolution: 144dpi)").matches?1.5:1:1}function u(e,t){var n,r,o,a,i={ratio:1};for(n=t.split(/ *, */),o=0;o<n.length;o++)r=n[o].match(/\s*(\S+)(?:\s*([\d.]+)w)?(?:\s*([\d.]+)h)?(?:\s*([\d.]+)x)?\s*/),a=r[4]&&parseFloat(r[4]),e>=a&&a>i.ratio&&(i.ratio=a,i.src=r[1],i.width=r[2]&&parseFloat(r[2]),i.height=r[3]&&parseFloat(r[3]));return i}function d(){var e,t,n=l(),r=new Image;if(n>1&&void 0===r.srcset)for(e=document.getElementsByTagName("img"),t=0;t<e.length;t++){var o,a=e[t],i=a.getAttribute("srcset");"string"==typeof i&&""!==i&&(o=u(n,i),void 0!==o.src&&(a.setAttribute("src",o.src),void 0!==o.width&&a.setAttribute("width",o.width),void 0!==o.height&&a.setAttribute("height",o.height)))}}doWhenReady(function(){var n,a,s,c,l,u,d,m,h,g=r();if(g&&(i(g),n=g.match(/^\w+/),n&&(n="nb"===n[0]?"no":n[0],a=e("searchLanguage")))){for(s=a.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,m=document.createElement("option"),m.setAttribute("lang",n),m.setAttribute("value",n),h=d.textContent||d.innerText||n,o(m,h),a.appendChild(m))),u&&(a.value=u,t(u))}}),window.wmSuggestionsEL=null,window.portalOpensearchCallback=_.debounce(function(t){var n,r=window.wmSuggestionsEL||e("suggestions"),o=r.children,a=document.createDocumentFragment();for(n=0;n<t[1].length;n+=1){var i=o[n]||document.createElement("option");i.value=t[1][n],o[n]||a.appendChild(i)}r.appendChild(a.cloneNode(!0))},100),doWhenReady(function(){var t,n,r,o=e("searchInput"),a=e("searchLanguage");if(o)for(o.setAttribute("results","10"),s(),void 0===o.autofocus?o.focus():window.scroll(0,0),t=location.search&&location.search.substr(1).split("&"),n=0;n<t.length;n+=1)if(r=t[n].split("="),"search"===r[0]&&r[1]){o.value=decodeURIComponent(r[1].replace(/\+/g," "));break}addEvent(a,"change",function(){a.blur(),c(a.value)})}),doWhenReady(function(){var e=document.searchwiki&&document.searchwiki.elements.uselang;e&&(e.value=n())}),doWhenReady(d)}(),window.mw||(window.mw=window.mediaWiki={loader:{state:function(){}}}),function(e,t){doWhenReady(function(){var e,n=document.getElementById("searchInput"),r=n.cloneNode(!0);n.parentNode.replaceChild(r,n),r.focus();var o=new t("search-input","searchInput");e="oninput"in document?"input":"propertychange",addEvent(r,e,_.debounce(function(){o.query(r.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 85b7504..fca73fe 100644 --- a/prod/wikipedia.org/index.html +++ b/prod/wikipedia.org/index.html @@ -639,7 +639,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-b335ba9eb0.js"></script> +<script src="portal/wikipedia.org/assets/js/index-ed68a8db0a.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/276488 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I949450a9a9aa94481e79e8ac0296618fc97142ad Gerrit-PatchSet: 1 Gerrit-Project: wikimedia/portals Gerrit-Branch: master Gerrit-Owner: Jdrewniak <jdrewn...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits