Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135741

Change subject: Show error message when server is not reachable
......................................................................

Show error message when server is not reachable

Change-Id: Ic8bf615e8daeaa2e51a30222bed6cdc51b07db3e
---
M modules/source/ext.cx.source.js
1 file changed, 17 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/41/135741/1

diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index a897fd1..8d2d4c1 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -11,11 +11,23 @@
 ( function ( $, mw ) {
        'use strict';
 
-       mw.cx.fetchPage = function ( sourcePage, sourceLanguage ) {
-               $.get( mw.config.get( 'wgContentTranslationServerURL' ) + 
'/page/' + sourceLanguage + '/' + sourcePage, function ( response ) {
-                       mw.cx.data = response;
-                       mw.hook( 'mw.cx.source.ready' ).fire();
-               } );
+       /**
+        * Fetch the page with given title and language.
+        * Response contains
+        * @param {string} title Title of the page to be fetched
+        * @param {string} language Language of the page requested. This will 
be used to
+        *     identify the host wiki.
+        */
+       mw.cx.fetchPage = function ( title, language ) {
+               $.get( mw.config.get( 'wgContentTranslationServerURL' ) + 
'/page/' + language + '/' + title )
+                       .done( function ( response ) {
+                               mw.cx.data = response;
+                               mw.hook( 'mw.cx.source.ready' ).fire();
+                       } ).fail( function () {
+                               $( '.cx-header__infobar' )
+                                       .text( mw.msg( 
'cx-error-server-connection' ) )
+                                       .show();
+                       } );
        };
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8bf615e8daeaa2e51a30222bed6cdc51b07db3e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to