-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mike Andrzejewski
committed
May 1, 2015
1 parent
298cac9
commit 674cbb6
Showing
23 changed files
with
292 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
isActive: false, | ||
|
||
isActiveChanged: Ember.observer('isActive', function () { | ||
var active = this.get('isActive'); | ||
C2LSettings.setActive(active, function () { | ||
console.log('C2L extension is now ' + (active ? 'enabled' : 'disabled')); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
|
||
setupController: function (controller, context) { | ||
this._super(controller, context); | ||
|
||
C2LSettings.loadActive(function (active) { | ||
controller.set('isActive', active); | ||
}); | ||
} | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
* | ||
color: rgba(80, 80, 80, 1) | ||
|
||
body | ||
margin: 0 | ||
|
||
|
||
.c2l-main | ||
min-width: 250px | ||
|
||
|
||
.c2l-header | ||
padding: 5px 10px 20px 10px | ||
background-color: rgba(192, 192, 192, 0.2) | ||
border-bottom: solid 1px rgba(192, 192, 192, 0.4) | ||
|
||
h4 | ||
margin: 5px 0px; | ||
font-size: 120% | ||
|
||
.c2l-legend | ||
font-style: italic | ||
font-size: 90% | ||
color: rgba(128, 128, 128, 1) | ||
font-weight: 200; | ||
|
||
|
||
.c2l-settings | ||
padding: 10px | ||
|
||
.c2l-active |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
|
||
<h4>SBrOwse</h4> | ||
<div class="c2l-header"> | ||
<h4>C2L</h4> | ||
<div class="c2l-legend"> | ||
Cyrillic to Latin alphabet transcoding | ||
</div> | ||
</div> | ||
|
||
<div class="c2l-settings"> | ||
<div class="c2l-active"> | ||
{{input id="c2l-is-active" type="checkbox" checked=controller.isActive}} | ||
<label for="c2l-is-active"> | ||
Always active | ||
</label> | ||
</div> | ||
</div> | ||
|
||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.View.extend({ | ||
classNames: 'c2l-main'.w() | ||
}); |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,141 @@ | ||
|
||
console.log('PAF!'); | ||
var dict = Ember.Object.create({ | ||
'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Ђ': 'Đ', 'Ж': 'Ž', 'З': 'Z', 'И': 'I', | ||
'К': 'K', 'Л': 'L', 'Љ': 'LJ', 'М': 'M', 'Н': 'N', 'Њ': 'NJ', 'П': 'P', 'Р': 'R', | ||
'С': 'S', 'Т': 'T', 'Ћ': 'Ć', 'У': 'U', 'Ф': 'F', 'Х': 'H', 'Ц': 'C', 'Ч': 'Č', | ||
'Џ': 'DŽ', 'Ш': 'Š', | ||
|
||
'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'ђ': 'đ', 'ж': 'ž', 'з': 'z', 'и': 'i', | ||
'к': 'k', 'л': 'l', 'љ': 'lj', 'м': 'm', 'н': 'n', 'њ': 'nj', 'п': 'p', 'р': 'r', | ||
'с': 's', 'т': 't', 'ћ': 'ć', 'у': 'u', 'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'č', | ||
'џ': 'dž', 'ш': 'š', | ||
|
||
transcode: function (text) { | ||
return text.split('').map(function (c) { | ||
if (['.'].contains(c)) { | ||
return c; | ||
} | ||
return this.getWithDefault(c, c); | ||
}, this).join(''); | ||
} | ||
}); | ||
|
||
function css (style) { | ||
return Ember.keys(style).map(function (k) { | ||
return '%@: %@;'.fmt(k, style[k]); | ||
}).join(' '); | ||
} | ||
|
||
var progress = Ember.Object.extend({ | ||
el: null, | ||
|
||
init: function () { | ||
var style = { | ||
'position': 'absolute', | ||
'left': 0, | ||
'top': 0, | ||
'background': ' rgba(255, 255, 255, 0.5)', | ||
'border': 'solid 1px rgba(0, 0, 0, 0.5)', | ||
'border-radius': '5px', | ||
'margin': '10px', | ||
'font-family': 'sans-serif', | ||
'font-size': '8pt', | ||
'z-index': 10000, | ||
'overflow': 'hidden' | ||
}, | ||
bar = { | ||
'width': 0, | ||
'background-color': 'rgba(0, 192, 0, 0.25)', | ||
'position': 'absolute', | ||
'height': '100%', | ||
'z-index': -1 | ||
}; | ||
|
||
var el = Ember.$( | ||
'<div class="c2l-progress" style="%@">'.fmt(css(style)) + | ||
'<div class="c2l-bar" style="%@"></div>'.fmt(css(bar)) + | ||
'<div class="c2l-label" style="padding: 5px 10px;">Cyrillic to Latin processing...</div>' + | ||
'</div>' | ||
); | ||
el.appendTo('body'); | ||
this.set('el', el); | ||
}, | ||
|
||
show: function () { | ||
this.get('el').show(); | ||
console.log('C2L processing started...'); | ||
|
||
this.setProperties({ | ||
count: Ember.$('*').contents().filter(function () { return this.nodeType === 3; }).length, | ||
index: 0 | ||
}); | ||
}, | ||
hide: function () { | ||
this.get('el').fadeOut(300); | ||
console.log('C2L processing complete'); | ||
}, | ||
|
||
increment: function () { | ||
this.incrementProperty('index'); | ||
this.get('el').find('.c2l-bar').width('%@%'.fmt(this.get('index') * 100 / this.get('count'))); | ||
} | ||
}).create(); | ||
|
||
|
||
function processElement (el) { | ||
el.contents().each(function (i, content) { | ||
switch (content.nodeName) { | ||
case '#text': | ||
Ember.$(content).replaceWith(dict.transcode(content.wholeText)); | ||
break; | ||
|
||
case 'INPUT': | ||
content.placeholder = dict.transcode(content.placeholder); | ||
content.value = dict.transcode(content.value); | ||
break; | ||
|
||
default: | ||
processElement(Ember.$(content)); | ||
} | ||
}); | ||
progress.increment(); | ||
} | ||
|
||
var alreadyProcessed = false; | ||
|
||
function processPageIf (active) { | ||
if (active) { | ||
console.log('C2L extension is enabled'); | ||
|
||
progress.show(); | ||
processElement(Ember.$(document)); | ||
progress.hide(); | ||
|
||
alreadyProcessed = true; | ||
} else { | ||
console.log('C2L extension is disabled'); | ||
|
||
if (alreadyProcessed) { | ||
window.location.reload(); | ||
} | ||
} | ||
} | ||
|
||
var extensionActive = false; | ||
C2LSettings.loadActive(function (active) { | ||
extensionActive = active; | ||
processPageIf(active); | ||
}); | ||
|
||
C2LSettings.whenActive(function (active) { | ||
extensionActive = active; | ||
processPageIf(active); | ||
}); | ||
|
||
Ember.$(function () { | ||
document.addEventListener('DOMNodeInserted', function (event) { | ||
if (extensionActive) { | ||
processElement(Ember.$(event.target)); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"manifest_version": 2, | ||
|
||
"name": "C2L", | ||
"description": "Cyrilic to Latin characters transcoding", | ||
"version": "1.0.0", | ||
"icons": { | ||
"128": "chrome-icon-lg.png" | ||
}, | ||
|
||
"web_accessible_resources": [ | ||
"assets/vendor.map" | ||
], | ||
|
||
"browser_action": { | ||
"default_icon": "chrome-icon.png", | ||
"default_popup": "index.html", | ||
"default_title": "C2L" | ||
}, | ||
"content_scripts": [{ | ||
"matches": ["<all_urls>"], | ||
"js": [ | ||
"assets/vendor.js", | ||
"content-script.js" | ||
], | ||
"run_at": "document_end", | ||
"all_frames": true | ||
}], | ||
"permissions": [ | ||
"storage", | ||
"tabs", | ||
"bookmarks", | ||
"activeTab", | ||
"<all_urls>", | ||
"https://ajax.googleapis.com/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.