Skip to content

Commit

Permalink
Getting the preferences and about:config working.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Feb 18, 2009
1 parent 92e036f commit c2385d1
Show file tree
Hide file tree
Showing 9 changed files with 799 additions and 8 deletions.
72 changes: 72 additions & 0 deletions extension/components/about.js
@@ -0,0 +1,72 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is PushMarks.
*
* The Initial Developer of the Original Code is Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Atul Varma <atul@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");

const Cc = Components.classes;
const Ci = Components.interfaces;

function PushMarksAboutHandler() {
}

PushMarksAboutHandler.prototype = {
newChannel : function(aURI) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);

var channel = ios.newChannel(
"chrome://pushmarks/content/index.html",
null,
null
);

channel.originalURI = aURI;
return channel;
},

getURIFlags: function(aURI) {
return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
},

classDescription: "About PushMarks Page",
classID: Components.ID("3a54db0f-281a-4af7-931c-de747c37b423"),
contractID: "@mozilla.org/network/protocol/about;1?what=pushmarks",
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule])
}

function NSGetModule(aCompMgr, aFileSpec) {
return XPCOMUtils.generateModule([PushMarksAboutHandler]);
}
10 changes: 8 additions & 2 deletions extension/content/index.html
@@ -1,6 +1,7 @@
<html> <html>
<head> <head>
<title>PushMarks</title> <title>PushMarks</title>
<base href="chrome://pushmarks/content"/>
<script type="text/javascript" src="jquery-1.3.1.min.js"></script> <script type="text/javascript" src="jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.6rc6.min.js"></script> <script type="text/javascript" src="jquery-ui-1.6rc6.min.js"></script>
<link type="text/css" href="theme/ui.all.css" rel="Stylesheet" /> <link type="text/css" href="theme/ui.all.css" rel="Stylesheet" />
Expand All @@ -23,6 +24,9 @@
.getService(Components.interfaces.nsIPrefService); .getService(Components.interfaces.nsIPrefService);
prefs = prefs.getBranch("extensions.pushmarks."); prefs = prefs.getBranch("extensions.pushmarks.");


var service = {};
Components.utils.import('resource://pushmarks/modules/service.js', service);

function save () { function save () {
var prefValues = { var prefValues = {
"deliciousEnabled" : $('input[name=deliciousEnabled]')[0].checked, "deliciousEnabled" : $('input[name=deliciousEnabled]')[0].checked,
Expand All @@ -33,8 +37,6 @@
prefs.setBoolPref('delicious.enabled', prefValues.deliciousEnabled); prefs.setBoolPref('delicious.enabled', prefValues.deliciousEnabled);
prefs.setCharPref('delicious.username', prefValues.deliciousUsername); prefs.setCharPref('delicious.username', prefValues.deliciousUsername);
prefs.setCharPref('delicious.password', prefValues.deliciousPassword); prefs.setCharPref('delicious.password', prefValues.deliciousPassword);
var service = {};
Components.utils.import('resource://pushmarks/modules/service.js', service);
service.refreshFromPrefs(); service.refreshFromPrefs();
} }


Expand All @@ -49,6 +51,10 @@
$('input[name=deliciousEnabled]')[0].checked = prefs.getBoolPref('delicious.enabled'); $('input[name=deliciousEnabled]')[0].checked = prefs.getBoolPref('delicious.enabled');
$('input[name=deliciousUsername]')[0].value = prefs.getCharPref('delicious.username'); $('input[name=deliciousUsername]')[0].value = prefs.getCharPref('delicious.username');
$('input[name=deliciousPassword]')[0].value = prefs.getCharPref('delicious.password'); $('input[name=deliciousPassword]')[0].value = prefs.getCharPref('delicious.password');

$('input[name=deliciousUsername]').bind('keypress', function(e){
$('input[name=deliciousEnabled]')[0].checked = true;
})
} }




Expand Down
2 changes: 1 addition & 1 deletion extension/content/overlay.xul
@@ -1,5 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<overlay id="pushmarks-overlay" <overlay id="pushmarks-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="overlay.js"/> <script src="overlay.js"/>
</overlay> </overlay>
9 changes: 9 additions & 0 deletions extension/content/preferences.xul
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript;version=1.7">
Components.utils.import("resource://pushmarks/modules/ubiqutils.js");
Application.activeWindow.open(Utils.url("about:pushmarks")).focus();
window.close();
</script>
</window>
1 change: 1 addition & 0 deletions extension/install.rdf
Expand Up @@ -15,5 +15,6 @@
<em:maxVersion>3.2a1pre</em:maxVersion> <em:maxVersion>3.2a1pre</em:maxVersion>
</Description> </Description>
</em:targetApplication> </em:targetApplication>
<em:optionsURL>chrome://pushmarks/content/preferences.xul</em:optionsURL>
</Description> </Description>
</RDF> </RDF>
Binary file added extension/pushmarks.xpi
Binary file not shown.
8 changes: 5 additions & 3 deletions extension/resource/modules/init.js
Expand Up @@ -55,9 +55,11 @@ var historyService = Components.classes["@mozilla.org/browser/nav-history-servic
.getService(Components.interfaces.nsINavHistoryService); .getService(Components.interfaces.nsINavHistoryService);
var uuidgen = Components.classes["@mozilla.org/uuid-generator;1"] var uuidgen = Components.classes["@mozilla.org/uuid-generator;1"]
.getService(Components.interfaces.nsIUUIDGenerator); .getService(Components.interfaces.nsIUUIDGenerator);


Components.utils.import("resource://gre/modules/JSON.jsm"); if (!JSON) {
Components.utils.import("resource://pushmarks/modules/service.js") Components.utils.import("resource://gre/modules/JSON.jsm");
Components.utils.import("resource://pushmarks/modules/service.js")
}


var withs = {}; Components.utils.import('resource://pushmarks/modules/withs.js', withs); var withs = {}; Components.utils.import('resource://pushmarks/modules/withs.js', withs);
var arrays = {}; Components.utils.import('resource://pushmarks/modules/arrays.js', arrays); var arrays = {}; Components.utils.import('resource://pushmarks/modules/arrays.js', arrays);
Expand Down

0 comments on commit c2385d1

Please sign in to comment.