FANDOM


  • Greetings.

    I am planning to enable JavaScript for my wiki once it hits 50 pages. I know it'll be a while until then, but I have a question in advance - I already have experience with JS.

    Recently I asked if it was possible to target pages with specific templates or categories using CSS, and I got a reply stating that can only be done through JavaScript. Does anyone know a code that can do that? 

    Thanks in advance,

    Wither

      Loading editor
    • Also, how do I get the Binary and Send buttons in the chat on this wiki to move to the left? I also have ChatHacks enabled and those buttons hide Binary and Send. I am using the second script.

        Loading editor
    • Withersoul 235Thread:1377441
      Does anyone know a code that can do that?

      there is no such code, cuz nobody knows ur templates.
      generally, if u want to target some template on some page (why do u need it? do u really need it?), then ur template must use some unique class\id (span class="mytemplate" or smth). page name lies in window.wgPageName. code will be like
      if (window.wgPageName === 'mypage' && $('.mytemplate').length) {
          //do stuff
      }
        Loading editor
    • Withersoul 235 wrote: Also, how do I get the Binary and Send buttons in the chat on this wiki to move to the left? I also have ChatHacks enabled and those buttons hide Binary and Send. I am using the second script.

      Try placing the following on MediaWiki:Chat.css.

      .Write .message {
          padding-left: 70px;
      }
       
      #ChatSendButton,
      #ChatBinaryButton {
          right: auto;
      }

      That is the simplest way. However, if you want to use CSS more similar to that for the "AFK" and "Clear" buttons:

      .Write .message {
          padding-left: 70px;
      }
      
      #ChatSendButton {
          right: auto;
          left: 55px;
      }
      
      #ChatBinaryButton {
          right: auto;
          bottom: auto;
          left: 55px;
          top: 0px;
      }
      

      Edit:

      By the way, in my opinion, using font-variant: small-caps; for page titles may not be the best idea as page names are case sensitive. As such, this may cause confusion when people try to link to the pages.

        Loading editor
    • I'll try it out, thanks. 

      Understood.

        Loading editor
    • The capital letters are a tad larger than the non-capitals; though, if people really have trouble with it and inform us of it, then I'll remove the small-caps.

        Loading editor
    • The second script is very unstable. It results in this:

      Ehm
        Loading editor
    • If some CSS from the forum doesn't seem to work fully, that's likely because the CSS selectors aren't specific enough.

      In this case, right: auto; is not overriding the script CSS. Put .ChatWindow  in front of Andrewds1021's code and it'll probably work:

      .ChatWindow .Write .message {
          padding-left: 70px;
      }
       
      .ChatWindow #ChatSendButton {
          right: auto;
          left: 55px;
      }
       
      .ChatWindow #ChatBinaryButton {
          right: auto;
          bottom: auto;
          left: 55px;
          top: 0px;
      }
        Loading editor
    • What Speedit said. I used the same selectors as the script so the fact that they are getting overridden means that the JS is applied after the CSS. I guess I should have expected that though. My apologies.

        Loading editor
    • It's not a problem. :)

        Loading editor
    • @Speedit: It works. Thanks!

        Loading editor
    • So there really is no such code in all of JS? (To target pages w/ specific categories/templates using CSS)

        Loading editor
    • Fngplg#3
      there is no such code, cuz nobody knows ur templates.

      however, js code to add categories as classes to body can be made.

        Loading editor
    • "there is no such code, cuz nobody knows ur templates."

      My templates would primarily be tophats.

      And yes? Really? How do I do that? And would it allow me to target categories and their contents with CSS?

        Loading editor
    • I believe what Fngplg is trying to say is that there is no copy-and-paste solution since the solution would need to be customized for your specific templates/categories. However, Fngplg did provide a generic solution for templates in #3.

        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