FANDOM


  • Is there a better way to find it out than using that code:

        $.get('/wiki/User_talk:' + mw.config.get('wgUserName'), function (data) {
            nmspc = data.slice(data.indexOf('"wgCanonicalNamespace":"') + 24, data.indexOf('","wgCanonicalSpecialPageName'));
        });

    Thanks in advance!
    Zuri

      Loading editor
    • Possibly checking if there is a User talk page or Message Wall page in the global nav dropdown.

      Selectors:

      • Wall: .wds-global-navigation__dropdown-link[data-tracking-label="account.message-wall"]
      • Talk: .wds-global-navigation__dropdown-link[data-tracking-label="account.talk"]
        Loading editor
    • That's hacky though, but better than what I found.

      Thanks, Speedit

        Loading editor
    • I concede that it is, just can't find an alternative global variable :)

        Loading editor
    • Okay, I could ask the support to implement such a variable but I guess they would not do it any time soon, because the wiki lab features are not their current point of interest.

        Loading editor
    • Unai01
      Unai01 removed this reply because:
      Doesn't work :P
      16:09, July 9, 2017
      This reply has been removed
    • I wonder why it says that this wiki has the Walls enabled because it doesn't.

      function messageWallEnabled() {
          return typeof mw.config.get('Wall') === 'function';
      }
        Loading editor
    • I use this snippet for checking if walls are enabled myself

      $.nirvana.getJson('WikiFeaturesSpecialController', 'index').done(function(d) {
          if(
              d.features.filter(function(t) {
                  return t.name === 'wgEnableWallExt' && t.enabled;
              }).length === 0
          ) {
              // wiki doesn't have message walls
          } else {
              // wiki has message walls
          });
      });
      but it doesn't work on wikis where Special:WikiFeatures is disabled.
        Loading editor
    • RE: #7, it checks if the user is currently in a Thread-based environment.

        Loading editor
    • $.ajax({
          type: 'HEAD',
          url: wgServer + '/wiki/Message_Wall:' + wgUserName,
          success: function() {
              // do have message walls
          },
          error: function() {
              //doesn't have message walls
          }
      });

      is what I use

        Loading editor
    • @Sophiedp: That's like the method I posted in the first post and it's hacky as well. So I prefer KockaAdmiralac's method and would suggest Speedit's method for wikis where Special:WikiFeatures is disabled.

        Loading editor
    • // Complete solution with integrated fallback
      // AJAX by KockaAdmiralac
      // Fallback by Speedit
      // Assembly by Colouratura
      var messageWallExists = function (name) {
      	return new Promise(function (resolve, reject) {
      		$.nirvana
      			.getJson('WikiFeaturesSpecialController', 'index')
      			.done(function (d) {
      				var disabled = 
      					d.features.filter(function (t) {
      						return t.name === 'wgEnableWallExt' && t.enabled;
      					}).length === 0;
       
      				if (disabled) {
      					reject();
      				} else {
      					resolve();
      				}
      			})
      			.error(function () {
      				var wall = '.wds-global-navigation__dropdown-link[data-tracking-label="account.message-wall"]';
       
      				if ($(wall).length === 0) {
      					reject();
      				} else {
      					resolve();
      				}
      			});
      	});
      };
       
      messageWallExists(mw.config.get('wgUserName')).then(
      	function () {
      		console.log('Message walls exist on this wiki');
      	},
      	function () {
      		console.log('Message walls do not exist on this wiki');
      	}
      );
        Loading editor
    • Thanks, Colouratura!

      Instead of .length !== 0 there could be used .exists() as well. It that recommended?

        Loading editor
    • What about

      Object.values(wgNamespaceIds).indexOf(1200)
      

      ?

        Loading editor
    • Would be neater than Speedit's fallback solution, I guess.

        Loading editor
    • hmm, actually it seems to be always present, so nope

        Loading editor
    • 1200 is always present, but 1201?

        Loading editor
    • exists too. there is no point to check namespaces. if u want to perform quick check, without async request, then check against .wds... it works well enough.

        Loading editor
    •   Loading editor
    • it is a script from #12 :)

        Loading editor
    • Okay, thanks for the script (Y)

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message