FlightGear wiki:Instant-Refs: Difference between revisions

Jump to navigation Jump to search
m
→‎The script: add watchlist support
m (→‎The script: add watchlist support)
Line 433: Line 433:
// @name:it    Instant-Cquotes
// @name:it    Instant-Cquotes
// @license    public domain
// @license    public domain
// @version    0.36
// @version    0.37
// @date        2016-05-05
// @date        2016-05-05
// @description Automatically converts selected FlightGear mailing list and forum quotes into post-processed MediaWiki markup (i.e. cquotes).
// @description Automatically converts selected FlightGear mailing list and forum quotes into post-processed MediaWiki markup (i.e. cquotes).
Line 1,133: Line 1,133:
     <li><a href="#articles">Articles</a></li>
     <li><a href="#articles">Articles</a></li>
     <li><a href="#templates">Templates</a></li>
     <li><a href="#templates">Templates</a></li>
    <li><a href="#development">Development</a></li>
     <li><a href="#settings">Settings</a></li>
     <li><a href="#settings">Settings</a></li>
     <li><a href="#help">Help</a></li>
     <li><a href="#help">Help</a></li>
Line 1,142: Line 1,143:
     <label for="article_select">Select an article to update</label>
     <label for="article_select">Select an article to update</label>
     <select name="article_select" id="article_select">
     <select name="article_select" id="article_select">
    <optgroup id="news" label="news"/>
    <optgroup id="watchlist" label="watchlist"/>
     </select>
     </select>
     <p/>
     <p/>
Line 1,153: Line 1,156:
     <label for="article_select">Select an article</label>
     <label for="article_select">Select an article</label>
     <select name="article_select" id="article_select">
     <select name="article_select" id="article_select">
    <optgroup id="news" label="news"/>
    <optgroup id="watchlist" label="watchlist"/>
     </select>
     </select>


Line 1,184: Line 1,189:
   </div>
   </div>
   </div>
   </div>
  <div id="development">This tab is a placeholder for features currently under development
  </div>
   <div id="settings">This tab contains script specific settings
   <div id="settings">This tab contains script specific settings
   </div>
   </div>
Line 1,219: Line 1,227:
   // TODO: Currently, this is hard-coded, but should be made customizable via the "articles" tab at some point ...
   // TODO: Currently, this is hard-coded, but should be made customizable via the "articles" tab at some point ...
   var articles = [
   var articles = [
     {name: 'Frequently asked questions', url:'http://wiki.flightgear.org/Frequently_asked_questions'},
     {name:'Frequently asked questions', url:'http://wiki.flightgear.org/Frequently_asked_questions'},
     {name:'Next newsletter', url:'http://wiki.flightgear.org/index.php?title=Next_newsletter'},
     {name:'Next newsletter', url:'http://wiki.flightgear.org/index.php?title=Next_newsletter'},
     {name:'Next changelog', url:'http://wiki.flightgear.org/index.php?title=Next_changelog'},
     {name:'Next changelog', url:'http://wiki.flightgear.org/index.php?title=Next_changelog'},
Line 1,236: Line 1,244:
      
      
     // add the article list to the corresponding dropdown menus
     // add the article list to the corresponding dropdown menus
     updateArticleList('#article_select');
     updateArticleList('select#article_select optgroup#news');
   
   
   
    // populate watchlist (prototype for now)
     
    // https://www.mediawiki.org/wiki/API:Watchlist
    // http://wiki.flightgear.org/api.php?action=query&list=watchlist
      var watchlist_url = 'http://wiki.flightgear.org/api.php?action=query&list=watchlist&format=json';
      Host.download(watchlist_url, function(response) {
        try {
      var watchlist = JSON.parse(response.responseText);
           
      //$('div#options select#section_select', markup).empty(); // delete all sections
     
      $.each(watchlist.query.watchlist, function (i, article) {
      $('div#options select#article_select optgroup#watchlist', markup).append($('<option>', {
        value: article.title, //FIXME just a placeholder for now
        text : article.title
    }));
  }); //foreach section
 
        }
        catch (e) {
          UI.alert(e.message);
        }
      });
     
   
   
   
      
      
     // register an event handler for the main tab, so that article specific sections can be retrieved
     // register an event handler for the main tab, so that article specific sections can be retrieved
Line 1,267: Line 1,305:
         }
         }
         catch (e) {
         catch (e) {
           alert(e.message);
           UI.alert(e.message);
         }
         }
       
        //alert("Finsihed downloading FAQ sections:\n"+sections.parse.sections[0].line );
   
              
              
       }); //download sections
       }); //download sections
   
   
       
     
       
     
       
     } // login status is OK
     } // status is OK
 
     
     
        
        
   }); // Host.download() call
   }); // Host.download() call

Navigation menu