/firefox/latrus/trunk/update.rdf |
---|
File deleted |
/firefox/latrus/trunk/TODO |
---|
File deleted |
/firefox/latrus/trunk/src/chrome/content/latrusMessengerCompose.xul |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/firefox/latrus/trunk/src/chrome/content/latrus.js |
---|
File deleted |
/firefox/latrus/trunk/src/chrome/content/latrusBrowser.xul |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/firefox/latrus/trunk/src/chrome/content/latrusMessenger.xul |
---|
File deleted |
Property changes: |
Deleted: svn:mergeinfo |
/firefox/latrus/trunk/src/install.rdf |
---|
File deleted |
/firefox/latrus/trunk/src/chrome.manifest |
---|
File deleted |
/firefox/latrus/trunk/bin/deploy.sh |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/firefox/latrus/tags/001_with_nsIWebProgressListener/update.rdf |
---|
File deleted |
/firefox/latrus/tags/001_with_nsIWebProgressListener/TODO |
---|
File deleted |
/firefox/latrus/tags/001_with_nsIWebProgressListener/src/install.rdf |
---|
File deleted |
/firefox/latrus/tags/001_with_nsIWebProgressListener/src/chrome.manifest |
---|
File deleted |
/firefox/latrus/tags/001_with_nsIWebProgressListener/src/chrome/content/latrus.js |
---|
File deleted |
/firefox/latrus/tags/001_with_nsIWebProgressListener/src/chrome/content/latrus.xul |
---|
File deleted |
/firefox/latrus/tags/001_with_nsIWebProgressListener/bin/deploy.sh |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/mozilla/latrus/trunk/src/chrome/content/latrusMessengerCompose.xul |
---|
0,0 → 1,38 |
<?xml version="1.0"?> |
<overlay id="latrus" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://latrus/content/latrus.js" /> |
<window id="msgcomposeWindow"> |
<commandset id="latrus-commandset"> |
<command id="latrus-command" oncommand="LatRus.toggleEnabled();" /> |
</commandset> |
<keyset id="latrus-keyset"> |
<key id="latrus-key" modifiers="accel,alt" key="L" command="latrus-command" /> |
</keyset> |
</window> |
<popup id="msgComposeContext"> |
<menuitem id="context-latrus-enabled" type="checkbox" label="Convert lat->rus" |
oncommand="LatRus.toggleEnabled();" accessKey="L" key="latrus-key" /> |
<menu id="context-latrus-submenu" label="LatRus"> |
<menupopup id="context-latrus-menupopup" onpopupshowing="LatRus.onMenuPopupShowing()"> |
<menuitem id="context-latrus-tolat" label="Selected text to LAT" |
oncommand="LatRus.selectedToLat()" /> |
<menuitem id="context-latrus-torus" label="Selected text to RUS" |
oncommand="LatRus.selectedToRus()" /> |
<menuseparator id="context-latrus-menupopup-sep" /> |
<menuitem id="context-latrus-options" label="Options" |
oncommand="LatRus.showOptions()" /> |
</menupopup> |
</menu> |
</popup> |
<statusbar id="status-bar"> |
<statusbarpanel id="latrus-panel" onclick="if(event.button == 0) LatRus.toggleEnabled();" /> |
</statusbar> |
</overlay> |
Property changes: |
Added: svn:mergeinfo |
/mozilla/latrus/trunk/src/chrome/content/latrusBrowser.xul |
---|
0,0 → 1,47 |
<?xml version="1.0"?> |
<overlay id="latrus" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://latrus/content/latrus.js" /> |
<window id="main-window"> |
<commandset id="latrus-commandset"> |
<command id="latrus-command" oncommand="LatRus.toggleEnabled();" /> |
</commandset> |
<keyset id="latrus-keyset"> |
<key id="latrus-key" modifiers="accel,alt" key="L" command="latrus-command" /> |
</keyset> |
</window> |
<popup id="contentAreaContextMenu"> |
<menu id="context-latrus-submenu" label="LatRus" insertafter="spell-separator"> |
<menupopup id="context-latrus-menupopup" onpopupshowing="LatRus.onMenuPopupShowing()"> |
<menuitem id="context-latrus-tolat" label="Selected text to LAT" |
oncommand="LatRus.selectedToLat()" /> |
<menuitem id="context-latrus-torus" label="Selected text to RUS" |
oncommand="LatRus.selectedToRus()" /> |
<menuseparator id="context-latrus-menupopup-sep" /> |
<menuitem id="context-latrus-options" label="Options" |
oncommand="LatRus.showOptions()" /> |
</menupopup> |
</menu> |
<menuitem id="context-latrus-enabled" type="checkbox" label="Convert lat->rus" |
oncommand="LatRus.toggleEnabled();" insertafter="spell-separator" |
accessKey="L" key="latrus-key" /> |
</popup> |
<popupset id="mainPopupSet"> |
<popup id="panel-latrus-popup"> |
<menuitem id="panel-latrus-options" label="Options" oncommand="LatRus.showOptions()" /> |
</popup> |
</popupset> |
<statusbar id="status-bar"> |
<statusbarpanel id="latrus-panel" onclick="if(event.button == 0) LatRus.toggleEnabled();" |
contextmenu="panel-latrus-popup"> |
</statusbarpanel> |
</statusbar> |
</overlay> |
Property changes: |
Added: svn:mergeinfo |
/mozilla/latrus/trunk/src/chrome/content/latrusMessenger.xul |
---|
0,0 → 1,22 |
<?xml version="1.0"?> |
<overlay id="latrus" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://latrus/content/latrus.js" /> |
<window id="messengerWindow"> |
<commandset id="latrus-commandset"> |
<command id="latrus-command" oncommand="LatRus.toggleEnabled();" /> |
</commandset> |
<keyset id="latrus-keyset"> |
<key id="latrus-key" modifiers="accel,alt" key="L" command="latrus-command" /> |
</keyset> |
</window> |
<statusbar id="status-bar"> |
<statusbarpanel id="latrus-panel" onclick="if(event.button == 0) LatRus.toggleEnabled();" /> |
</statusbar> |
</overlay> |
Property changes: |
Added: svn:mergeinfo |
/mozilla/latrus/trunk/src/chrome/content/latrus.js |
---|
0,0 → 1,198 |
var latRusWorker = null; |
var latRusEnabled = false; |
var LatRus = { |
init: function() |
{ |
latRusWorker = new Worker(); |
LatRus.setEnabled(false); |
}, |
onKeyPress: function(aEvent) |
{ |
if(!latRusEnabled) return; |
if(aEvent.ctrlKey || aEvent.altKey || aEvent.charCode == 0) return true; |
if(aEvent.keyCode == 255) return; // our loop event |
var newEvent = aEvent.target.ownerDocument.createEvent("KeyEvents"); |
newEvent.initKeyEvent(aEvent.type, aEvent.bubbles, aEvent.cancelable, aEvent.view, |
false, false, false, false, 255, latRusWorker.convertCode(aEvent.charCode)); |
aEvent.preventDefault(); |
aEvent.originalTarget.dispatchEvent(newEvent); |
}, |
toggleEnabled: function() |
{ |
LatRus.setEnabled(!latRusEnabled); |
}, |
setEnabled: function(enabled) |
{ |
latRusEnabled = enabled; |
LatRus.updateEnabled(); |
}, |
updateEnabled: function() |
{ |
var item = document.getElementById("context-latrus-enabled"); |
if(item) { |
item.setAttribute("checked", latRusEnabled); |
} |
var panel = document.getElementById("latrus-panel"); |
if(panel) { |
panel.label = (latRusEnabled ? "RUS" : "LAT"); |
} |
}, |
onMenuPopupShowing: function(menu) |
{ |
if(!gContextMenu) return null; |
var textSelected = (LatRus.getSelectedText(gContextMenu.target) != null); |
var itemToLat = document.getElementById("context-latrus-tolat"); |
if(itemToLat) { |
itemToLat.disabled = !textSelected; |
} |
var itemToRus = document.getElementById("context-latrus-torus"); |
if(itemToRus) { |
itemToRus.disabled = !textSelected; |
} |
}, |
selectedToLat: function() |
{ |
if(!gContextMenu) return null; |
LatRus.convertSelectedText(gContextMenu.target, 'convertStringBackward'); |
}, |
selectedToRus: function() |
{ |
if(!gContextMenu) return null; |
LatRus.convertSelectedText(gContextMenu.target, 'convertStringForward'); |
}, |
getSelectedText: function(e) |
{ |
if(!e) return null; |
if(!e.value) return null; |
var start = e.selectionStart; |
var end = e.selectionEnd; |
if(start < 0 || end < 0 || start >= end) return null; |
return e.value.toString().substring(start, end); |
}, |
convertSelectedText: function(e, transformation) |
{ |
var selection = LatRus.getSelectedText(e); |
if(!selection) return; |
var res = latRusWorker[transformation].call(latRusWorker, selection); |
var start = e.selectionStart; |
var end = e.selectionEnd; |
var scrollTop = e.scrollTop; |
var scrollLeft = e.scrollLeft; |
e.value = e.value.substring(0, start) + res + e.value.substring(end); |
e.setSelectionRange(start, start + res.length); |
e.scrollTop = scrollTop; |
e.scrollLeft = scrollLeft; |
}, |
showOptions: function() |
{ |
alert("latrus options"); |
}, |
}; |
/* REGISTER */ |
if(!latRusWorker && !window.frameElement) { |
window.addEventListener('load', LatRus.init, false); |
window.addEventListener('keypress', LatRus.onKeyPress, true); |
} |
Worker.engTable = new Array( |
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', |
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', |
'\"', '\'', '§', '$', '&', '/', '(', ')', '=', '?', '`', '-', |
'_', '#', '+', '*', ',', '.', 'ä', 'ö', 'ü', 'ß'); |
Worker.rusTable1 = new Array( |
'а', 'б', 'ц', 'д', 'е', 'ф', 'г', 'х', 'и', 'й', 'к', 'л', 'м', |
'н', 'о', 'п', 'ч', 'р', 'с', 'т', 'у', 'в', 'ш', 'ж', 'я', 'з', |
'ъ', 'ь', '§', '$', '&', '/', '(', ')', '=', '?', '`', '-', |
'_', '#', '+', '*', ',', '.', 'э', 'ы', 'ю', 'щ'); |
Worker.rusTable2 = new Array( |
'ф', 'и', 'с', 'в', 'у', 'а', 'п', 'р', 'ш', 'о', 'л', 'д', 'ь', |
'т', 'щ', 'з', 'й', 'к', 'ы', 'е', 'г', 'м', 'ц', 'ч', 'я', 'н', |
'\"', '/', 'â„–', ';', ':', '?', '*', '(', ')', '_', '=', '.', |
',', '\\', 'ъ', 'Ъ', 'б', 'ю'); |
function Worker() |
{ |
this.convertCodes = new Object(); |
this.convertChars = new Object(); |
this.backCodes = new Object(); |
this.backChars = new Object(); |
Worker.buildConvertTable(Worker.engTable, Worker.rusTable1, true, this.convertCodes, this.convertChars); |
Worker.buildConvertTable(Worker.rusTable1, Worker.engTable, true, this.backCodes, this.backChars); |
} |
Worker.buildConvertTable = function(fromTable, toTable, autoUpperCase, resCodes, resChars) |
{ |
for(var i = 0, l = Math.min(fromTable.length, toTable.length); i < l; ++i) { |
resCodes[fromTable[i].charCodeAt(0)] = toTable[i].charCodeAt(0); |
resChars[fromTable[i].charAt(0)] = toTable[i].charAt(0); |
if(autoUpperCase) { |
var fromUpper = fromTable[i].toUpperCase() |
if(fromUpper != fromTable[i]) { |
var toUpper = toTable[i].toUpperCase(); |
resCodes[fromUpper.charCodeAt(0)] = toUpper.charCodeAt(0); |
resChars[fromUpper.charAt(0)] = toUpper.charAt(0); |
} |
} |
} |
} |
Worker.prototype.convertCode = function(c) |
{ |
return this.convert(this.convertCodes, c); |
} |
Worker.prototype.convertStringForward = function(s) |
{ |
return this.convertString(this.convertChars, s); |
} |
Worker.prototype.convertStringBackward = function(s) |
{ |
return this.convertString(this.backChars, s); |
} |
Worker.prototype.convertString = function(table, s) |
{ |
var res = ""; |
for(var i = 0, l = s.length; i < l; ++i) { |
res += this.convert(table, s.charAt(i)); |
} |
return res; |
} |
Worker.prototype.convert = function(table, c) |
{ |
if(table) { |
var r = table[c]; |
if(r != undefined) return r; |
} |
return c; // not found or no table |
} |
/mozilla/latrus/trunk/src/install.rdf |
---|
0,0 → 1,36 |
<?xml version="1.0"?> |
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
xmlns:em="http://www.mozilla.org/2004/em-rdf#"> |
<Description about="urn:mozilla:install-manifest"> |
<em:id>{442BFBA6-ADD9-11DD-BDE2-BC5D1A6F0FEF}</em:id> |
<em:version>1.0</em:version> |
<em:type>2</em:type> |
<!-- firefox --> |
<em:targetApplication> |
<Description> |
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> |
<em:minVersion>3</em:minVersion> |
<em:maxVersion>3.0.*</em:maxVersion> |
</Description> |
</em:targetApplication> |
<!-- thunderbird --> |
<em:targetApplication> |
<Description> |
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id> |
<em:minVersion>2</em:minVersion> |
<em:maxVersion>2.0.0.*</em:maxVersion> |
</Description> |
</em:targetApplication> |
<em:name>LatRus</em:name> |
<em:description>Convert latin char to russian on-the-fly</em:description> |
<em:creator>Anatoli Klassen</em:creator> |
<em:homepageURL>http://www.26th.net/public/projects/latrus-mozilla</em:homepageURL> |
<em:updateURL>http://www.26th.net/public/projects/latrus-mozilla/update.rdf</em:updateURL> |
<em:updateKey>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0n3FJvEygIzLWtleG7RQGsW33KlWt2CEKm4cNdyYtos2PXb68ZwMIGDduDeAdv0kg90Y2vnHpEgJwE4O6Ce6bfjxQWNbCWj6UgjRaosuzqKq4+BBwT65hMcIs72K1x3zQde6oNBsnYiEP18Cy7aY26+QA7M/vcOY5Rut66xYcjQIDAQAB</em:updateKey> |
</Description> |
</RDF> |
/mozilla/latrus/trunk/src/chrome.manifest |
---|
0,0 → 1,5 |
content latrus chrome/content/ |
overlay chrome://browser/content/browser.xul chrome://latrus/content/latrusBrowser.xul |
overlay chrome://messenger/content/messenger.xul chrome://latrus/content/latrusMessenger.xul |
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://latrus/content/latrusMessengerCompose.xul |
/mozilla/latrus/trunk/TODO |
---|
0,0 → 1,4 |
* settings (convert table, default state etc) |
* standard char map |
* window with currect charmap, clickable |
* enable per tab (?) |
/mozilla/latrus/trunk/update.rdf |
---|
0,0 → 1,24 |
<?xml version="1.0"?> |
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#" |
xmlns:NC="http://home.netscape.com/NC-rdf#" |
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
<RDF:Description RDF:about="rdf:#$nTfq11" |
em:version="1.2"> |
<em:targetApplication RDF:resource="rdf:#$qTfq11"/> |
</RDF:Description> |
<RDF:Seq RDF:about="rdf:#$mTfq11"> |
<RDF:li RDF:resource="rdf:#$nTfq11"/> |
</RDF:Seq> |
<RDF:Description RDF:about="rdf:#$qTfq11" |
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" |
em:minVersion="3" |
em:maxVersion="3.0.*" |
em:updateLink="http://www.26th.net/public/projects/latrus-mozilla/latrus.xpi" /> |
<RDF:Description RDF:about="urn:mozilla:extension:{442BFBA6-ADD9-11DD-BDE2-BC5D1A6F0FEF}" |
em:version="1.0" |
em:updateLink="http://www.26th.net/public/projects/latrus-mozilla/latrus.xpi" |
em:updateHash="sha256:0000000000000000000000000000000000000000000000000000000000000000" |
em:signature="MIGTMA0GCSqGSIb3DQEBDQUAA4GBALmmXuf+VpiYfe8jkC8RnOmNDaQ49Lv8BFJOg3V99PPThO6jqAPKhI8or2qyQD0Nva/gb6OgaROGuo5FJsP6kXekhi91HltVUq9r1aSFvQ4iPf3IkyGZnqIQmECYdVmQgMwsRsOES5R+1SuH55wyGdaxtHpy9mg2ce+MMoqeQFKd"> |
<em:updates RDF:resource="rdf:#$mTfq11"/> |
</RDF:Description> |
</RDF:RDF> |
/mozilla/latrus/trunk/bin/deploy.sh |
---|
0,0 → 1,15 |
#!/bin/sh |
T="$1" |
D="$(dirname $0)/.." |
if [ -z "$T" ] ; then |
echo "Need one parameter - the target dir" >> /dev/stderr |
return 1 |
fi |
rm "$T/latrus.xpi" |
(cd "$D/src"; find . -not -path '*/.svn*' | zip -@ "$T/latrus.xpi") |
cp "$D/update.rdf" "$T" |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/TODO |
---|
0,0 → 1,4 |
* address bar, search bar etc |
* settings (convert table, default state etc) |
* standard char map |
* window with currect charmap, clickable |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/src/chrome/content/latrus.xul |
---|
0,0 → 1,45 |
<?xml version="1.0"?> |
<overlay id="latrus" |
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
<script type="application/x-javascript" src="chrome://latrus/content/latrus.js" /> |
<window id="main-window"> |
<commandset id="latrus-commandset"> |
<command id="latrus-command" oncommand="LatRus.toggleEnabled();" /> |
</commandset> |
<keyset id="latrus-keyset"> |
<key id="latrus-key" modifiers="accel,alt" key="L" command="latrus-command" /> |
</keyset> |
</window> |
<popup id="contentAreaContextMenu"> |
<menu id="context-latrus-submenu" label="LatRus" insertafter="spell-separator"> |
<menupopup id="context-latrus-menupopup" onpopupshowing="LatRus.onMenuPopupShowing()"> |
<menuitem id="context-latrus-tolat" label="Selected text to LAT" |
oncommand="LatRus.selectedToLat()" /> |
<menuitem id="context-latrus-torus" label="Selected text to RUS" |
oncommand="LatRus.selectedToRus()" /> |
<menuseparator id="context-latrus-menupopup-sep" /> |
<menuitem id="context-latrus-options" label="Options" |
oncommand="LatRus.showOptions()" /> |
</menupopup> |
</menu> |
<menuitem id="context-latrus-enabled" type="checkbox" label="Convert lat->rus" |
oncommand="LatRus.toggleEnabled();" insertafter="spell-separator" |
accessKey="L" key="latrus-key" /> |
</popup> |
<popup id="panel-latrus-popup"> |
<menuitem id="panel-latrus-options" label="Options" oncommand="LatRus.showOptions()" /> |
</popup> |
<statusbar id="status-bar"> |
<statusbarpanel id="latrus-panel" onclick="if(event.button == 0) LatRus.toggleEnabled();" |
contextmenu="panel-latrus-popup"> |
</statusbarpanel> |
</statusbar> |
</overlay> |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/src/chrome/content/latrus.js |
---|
0,0 → 1,246 |
const STATE_START = Components.interfaces.nsIWebProgressListener.STATE_START; |
const STATE_TRANSFERRING = Components.interfaces.nsIWebProgressListener.STATE_TRANSFERRING; |
const STATE_STOP = Components.interfaces.nsIWebProgressListener.STATE_STOP; |
var LatRusWebProgressListener = { |
QueryInterface: function(aIID) |
{ |
if(aIID.equals(Components.interfaces.nsIWebProgressListener) |
|| aIID.equals(Components.interfaces.nsISupportsWeakReference) |
|| aIID.equals(Components.interfaces.nsISupports)) |
{ |
return this; |
} |
throw Components.results.NS_NOINTERFACE; |
}, |
onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) |
{ |
// try to take control at first possible stage |
if(aFlag & (STATE_START | STATE_TRANSFERRING | STATE_STOP)) { |
aWebProgress.DOMWindow.document.removeEventListener('keypress', LatRus.onKeyPress, true); |
aWebProgress.DOMWindow.document.addEventListener('keypress', LatRus.onKeyPress, true); |
} |
return 0; |
}, |
onLocationChange: function() { return 0; }, |
onProgressChange: function() { return 0; }, |
onStatusChange: function() { return 0; }, |
onSecurityChange: function() { return 0; }, |
onLinkIconAvailable: function() { return 0; }, |
} |
var latRusWorker = null; |
var LatRus = { |
init: function() |
{ |
latRusWorker = new Worker(); |
gBrowser.addProgressListener(LatRusWebProgressListener, |
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT); |
gBrowser.tabContainer.addEventListener("TabSelect", LatRus.onTabSelect, false); |
LatRus.setEnabled(false); |
}, |
uninit: function() |
{ |
gBrowser.removeProgressListener(LatRusWebProgressListener); |
}, |
onTabSelect: function(aEvent) |
{ |
if(aEvent.target.linkedBrowser.latRusEnabled == undefined) { |
aEvent.target.linkedBrowser.latRusEnabled = false; // the default value |
} |
LatRus.updateEnabled(); |
}, |
onKeyPress: function(aEvent) |
{ |
if(!gBrowser.selectedBrowser.latRusEnabled) return; |
if(aEvent.ctrlKey || aEvent.altKey || aEvent.charCode == 0) return true; |
if(aEvent.keyCode == 255) return; // our loop event |
var newEvent = document.commandDispatcher.focusedWindow.document.createEvent("KeyEvents"); |
newEvent.initKeyEvent(aEvent.type, aEvent.bubbles, aEvent.cancelable, aEvent.view, |
false, false, false, false, 255, latRusWorker.convertCode(aEvent.charCode)); |
aEvent.preventDefault(); |
aEvent.target.dispatchEvent(newEvent); |
}, |
toggleEnabled: function() |
{ |
LatRus.setEnabled(!gBrowser.selectedBrowser.latRusEnabled); |
}, |
setEnabled: function(enabled) |
{ |
gBrowser.selectedBrowser.latRusEnabled = enabled; |
LatRus.updateEnabled(); |
}, |
updateEnabled: function() |
{ |
var item = document.getElementById("context-latrus-enabled"); |
if(item) { |
item.setAttribute("checked", gBrowser.selectedBrowser.latRusEnabled); |
} |
var panel = document.getElementById("latrus-panel"); |
if(panel) { |
panel.label = (gBrowser.selectedBrowser.latRusEnabled ? "RUS" : "LAT"); |
} |
}, |
onMenuPopupShowing: function(menu) |
{ |
if(!gContextMenu) return null; |
var textSelected = (LatRus.getSelectedText(gContextMenu.target) != null); |
var itemToLat = document.getElementById("context-latrus-tolat"); |
if(itemToLat) { |
itemToLat.disabled = !textSelected; |
} |
var itemToRus = document.getElementById("context-latrus-torus"); |
if(itemToRus) { |
itemToRus.disabled = !textSelected; |
} |
}, |
selectedToLat: function() |
{ |
if(!gContextMenu) return null; |
LatRus.convertSelectedText(gContextMenu.target, 'convertStringBackward'); |
}, |
selectedToRus: function() |
{ |
if(!gContextMenu) return null; |
LatRus.convertSelectedText(gContextMenu.target, 'convertStringForward'); |
}, |
getSelectedText: function(e) |
{ |
if(!e) return null; |
if(!e.value) return null; |
var start = e.selectionStart; |
var end = e.selectionEnd; |
if(start < 0 || end < 0 || start >= end) return null; |
return e.value.toString().substring(start, end); |
}, |
convertSelectedText: function(e, transformation) |
{ |
var selection = LatRus.getSelectedText(e); |
if(!selection) return; |
var res = latRusWorker[transformation].call(latRusWorker, selection); |
var start = e.selectionStart; |
var end = e.selectionEnd; |
var scrollTop = e.scrollTop; |
var scrollLeft = e.scrollLeft; |
e.value = e.value.substring(0, start) + res + e.value.substring(end); |
e.setSelectionRange(start, start + res.length); |
e.scrollTop = scrollTop; |
e.scrollLeft = scrollLeft; |
}, |
showOptions: function() |
{ |
alert("latrus options"); |
}, |
}; |
window.addEventListener('load', LatRus.init, false); |
window.addEventListener('unload', LatRus.uninit, false); |
Worker.engTable = new Array( |
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', |
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', |
'\"', '\'', '§', '$', '&', '/', '(', ')', '=', '?', '`', '-', |
'_', '#', '+', '*', ',', '.', 'ä', 'ö', 'ü', 'ß'); |
Worker.rusTable1 = new Array( |
'а', 'б', 'ц', 'д', 'е', 'ф', 'г', 'х', 'и', 'й', 'к', 'л', 'м', |
'н', 'о', 'п', 'ч', 'р', 'с', 'т', 'у', 'в', 'ш', 'ж', 'я', 'з', |
'ъ', 'ь', '§', '$', '&', '/', '(', ')', '=', '?', '`', '-', |
'_', '#', '+', '*', ',', '.', 'э', 'ы', 'ю', 'щ'); |
Worker.rusTable2 = new Array( |
'ф', 'и', 'с', 'в', 'у', 'а', 'п', 'р', 'ш', 'о', 'л', 'д', 'ь', |
'т', 'щ', 'з', 'й', 'к', 'ы', 'е', 'г', 'м', 'ц', 'ч', 'я', 'н', |
'\"', '/', 'â„–', ';', ':', '?', '*', '(', ')', '_', '=', '.', |
',', '\\', 'ъ', 'Ъ', 'б', 'ю'); |
function Worker() |
{ |
this.convertCodes = new Object(); |
this.convertChars = new Object(); |
this.backCodes = new Object(); |
this.backChars = new Object(); |
Worker.buildConvertTable(Worker.engTable, Worker.rusTable1, true, this.convertCodes, this.convertChars); |
Worker.buildConvertTable(Worker.rusTable1, Worker.engTable, true, this.backCodes, this.backChars); |
} |
Worker.buildConvertTable = function(fromTable, toTable, autoUpperCase, resCodes, resChars) |
{ |
for(var i = 0, l = Math.min(fromTable.length, toTable.length); i < l; ++i) { |
resCodes[fromTable[i].charCodeAt(0)] = toTable[i].charCodeAt(0); |
resChars[fromTable[i].charAt(0)] = toTable[i].charAt(0); |
if(autoUpperCase) { |
var fromUpper = fromTable[i].toUpperCase() |
if(fromUpper != fromTable[i]) { |
var toUpper = toTable[i].toUpperCase(); |
resCodes[fromUpper.charCodeAt(0)] = toUpper.charCodeAt(0); |
resChars[fromUpper.charAt(0)] = toUpper.charAt(0); |
} |
} |
} |
} |
Worker.prototype.convertCode = function(c) |
{ |
return this.convert(this.convertCodes, c); |
} |
Worker.prototype.convertStringForward = function(s) |
{ |
return this.convertString(this.convertChars, s); |
} |
Worker.prototype.convertStringBackward = function(s) |
{ |
return this.convertString(this.backChars, s); |
} |
Worker.prototype.convertString = function(table, s) |
{ |
var res = ""; |
for(var i = 0, l = s.length; i < l; ++i) { |
res += this.convert(table, s.charAt(i)); |
} |
return res; |
} |
Worker.prototype.convert = function(table, c) |
{ |
if(table) { |
var r = table[c]; |
if(r != undefined) return r; |
} |
return c; // not found or no table |
} |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/src/install.rdf |
---|
0,0 → 1,26 |
<?xml version="1.0"?> |
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
xmlns:em="http://www.mozilla.org/2004/em-rdf#"> |
<Description about="urn:mozilla:install-manifest"> |
<em:id>{442BFBA6-ADD9-11DD-BDE2-BC5D1A6F0FEF}</em:id> |
<em:version>1.0</em:version> |
<em:type>2</em:type> |
<em:targetApplication> |
<Description> |
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> |
<em:minVersion>3</em:minVersion> |
<em:maxVersion>3.0.*</em:maxVersion> |
</Description> |
</em:targetApplication> |
<em:name>LatRus</em:name> |
<em:description>Convert latin char to russian on-the-fly</em:description> |
<em:creator>Anatoli Klassen</em:creator> |
<em:homepageURL>http://www.26th.net/public/projects/latrus-mozilla</em:homepageURL> |
<em:updateURL>http://www.26th.net/public/projects/latrus-mozilla/update.rdf</em:updateURL> |
<em:updateKey>MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD0n3FJvEygIzLWtleG7RQGsW33KlWt2CEKm4cNdyYtos2PXb68ZwMIGDduDeAdv0kg90Y2vnHpEgJwE4O6Ce6bfjxQWNbCWj6UgjRaosuzqKq4+BBwT65hMcIs72K1x3zQde6oNBsnYiEP18Cy7aY26+QA7M/vcOY5Rut66xYcjQIDAQAB</em:updateKey> |
</Description> |
</RDF> |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/src/chrome.manifest |
---|
0,0 → 1,2 |
content latrus chrome/content/ |
overlay chrome://browser/content/browser.xul chrome://latrus/content/latrus.xul |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/update.rdf |
---|
0,0 → 1,24 |
<?xml version="1.0"?> |
<RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#" |
xmlns:NC="http://home.netscape.com/NC-rdf#" |
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> |
<RDF:Description RDF:about="rdf:#$nTfq11" |
em:version="1.2"> |
<em:targetApplication RDF:resource="rdf:#$qTfq11"/> |
</RDF:Description> |
<RDF:Seq RDF:about="rdf:#$mTfq11"> |
<RDF:li RDF:resource="rdf:#$nTfq11"/> |
</RDF:Seq> |
<RDF:Description RDF:about="rdf:#$qTfq11" |
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" |
em:minVersion="3" |
em:maxVersion="3.0.*" |
em:updateLink="http://www.26th.net/public/projects/latrus-mozilla/latrus.xpi" /> |
<RDF:Description RDF:about="urn:mozilla:extension:{442BFBA6-ADD9-11DD-BDE2-BC5D1A6F0FEF}" |
em:version="1.0" |
em:updateLink="http://www.26th.net/public/projects/latrus-mozilla/latrus.xpi" |
em:updateHash="sha256:0000000000000000000000000000000000000000000000000000000000000000" |
em:signature="MIGTMA0GCSqGSIb3DQEBDQUAA4GBALmmXuf+VpiYfe8jkC8RnOmNDaQ49Lv8BFJOg3V99PPThO6jqAPKhI8or2qyQD0Nva/gb6OgaROGuo5FJsP6kXekhi91HltVUq9r1aSFvQ4iPf3IkyGZnqIQmECYdVmQgMwsRsOES5R+1SuH55wyGdaxtHpy9mg2ce+MMoqeQFKd"> |
<em:updates RDF:resource="rdf:#$mTfq11"/> |
</RDF:Description> |
</RDF:RDF> |
/mozilla/latrus/tags/001_with_nsIWebProgressListener/bin/deploy.sh |
---|
0,0 → 1,15 |
#!/bin/sh |
T="$1" |
D="$(dirname $0)/.." |
if [ -z "$T" ] ; then |
echo "Need one parameter - the target dir" >> /dev/stderr |
return 1 |
fi |
rm "$T/latrus.xpi" |
(cd "$D/src"; find . -not -path '*/.svn*' | zip -@ "$T/latrus.xpi") |
cp "$D/update.rdf" "$T" |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |