User:PerfektesChaos/js/localEdit/Firefox/chrome/content/prefs.js

/// chrome://wikilocaledit/content/prefs.js /// Manage preferences store. // Requires: //    * content/config.js //     * content/permissions.js //     * content/fileIO.js //  Used by: //    * content/config.xul //    * content/wikilocaledit.xul /// 2012-11-30 PerfektesChaos@de.wikipedia /// Fingerprint: #0#0# /// /*jshint curly:true, eqeqeq:true, strict:true, undef:true, white:false */ /*global window                                                       */ /*jslint white: true                                                  */ /*globals window: true                                                */

( function ( w ) {  "use strict";   var BRANCH, PREFS, WLE;   if ( ! w.wikiLocalEdit ) {     w.wikiLocalEdit  =  { };   }   WLE  =  w.wikiLocalEdit;   if ( ! WLE.prefs ) {     WLE.prefs  =  { };   }   PREFS        =  WLE.prefs;   PREFS.sDIR   =  "wikilocaledit.dir.";   PREFS.sLEAD  =  "wikilocaledit.leading";   PREFS.sUP    =  "wikilocaledit.userpages";

PREFS.branch = w.Components.classes[ "@mozilla.org/preferences-service;1" ] .getService( w.Components.interfaces.nsIPrefBranch ) .QueryInterface( w.Components.interfaces.nsIPrefBranchInternal ); BRANCH =  PREFS.branch;

PREFS.fetchBasedir =  function { // Perform local directory base selection and storing // Uses: //   >  .locale.selectDirBase //   .fileIO.find //   .prefs.setDirBase // 2012-11-25 PerfektesChaos@de.wikipedia var s =  WLE.fileIO.find( PREFS.getDirBase,                                 false,                                 false,                                 WLE.locale.selectDirBase,                                 false ); if ( s ) { PREFS.setDirBase( s ); }  };   // .prefs.fetchBasedir

PREFS.getDirBase =  function { if ( BRANCH.getPrefType( this.sDIR ) !== BRANCH.PREF_STRING ) { this.setDirBase( "" ); }     return BRANCH.getCharPref( this.sDIR ); };  // .prefs.getDirBase

PREFS.getDirSub =  function( account ) { var s =  this.sDIR + account; if ( BRANCH.getPrefType( s ) !== BRANCH.PREF_STRING ) { this.setDirSub( "", account ); }     return BRANCH.getCharPref( s ); };  // .prefs.getDirSub

PREFS.getLeading =  function { if ( BRANCH.getPrefType( this.sLEAD ) !== BRANCH.PREF_BOOL ) { this.setLeading( true ); }     return BRANCH.getBoolPref( this.sLEAD ); };  // .prefs.getLeading

PREFS.getUserlist =  function { var s =  this.getUserpages, r =  false; if ( s ) { r =  s.split( " " ); }     return r;   };   // .prefs.getUserlist

PREFS.getUserpages =  function { if ( BRANCH.getPrefType( this.sUP ) !== BRANCH.PREF_STRING ) { this.setUserpages( "" ); }     return BRANCH.getCharPref( this.sUP ); };  // .prefs.getUserpages

PREFS.setDirBase =  function( assign ) { BRANCH.setCharPref( this.sDIR, assign ); };  // .prefs.setDirBase

PREFS.setDirSub =  function( assign, account ) { BRANCH.setCharPref( this.sDIR + account, assign ); };  // .prefs.setDirSub

PREFS.setLeading =  function( assign ) { BRANCH.setBoolPref( this.sLEAD, assign ); };  // .prefs.setLeading

PREFS.setUserpages =  function( assign ) { BRANCH.setCharPref( this.sUP, assign ); };  // .prefs.setUserpages

} ( window ) );

/// EOF  content/prefs.js