-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first working implementation of a debug plugin
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (C) 2011 by Nicolas Karageuzian | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,3 +1,8 @@ | ||
Debugger plugin for Aloha | ||
|
||
me.nka.aloha.Debugger | ||
|
||
Nicolas Karageuzian 2011 - http://nka.me/ | ||
Norbert | ||
|
||
|
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,52 @@ | ||
/** | ||
* Nka debugger plugin, from Norbert Pomaroli showcase at #aedc 201102 | ||
* | ||
*/ | ||
|
||
DebuggerPlugin = new GENTICS.Aloha.Plugin('me.nka.aloha.Debugger'); | ||
jQuery.extend(true,DebuggerPlugin,{ | ||
/** | ||
* Initialize plugin | ||
*/ | ||
init: function() { | ||
var that = this; | ||
jQuery('body').append('<div id="NKA_debugger"></div>'); | ||
GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha, 'selectionChanged', function(event, rangeObject) { | ||
jQuery('#NKA_debugger').empty().append(that.renderRangeTree(rangeObject.getRangeTree())); | ||
}); | ||
}, | ||
renderRangeTree: function(tree) { | ||
var that = this; | ||
if (tree) { | ||
var list = jQuery('<ul></ul>'); | ||
jQuery.each(tree, function(index, item) { | ||
if (item.type == 'none') { | ||
return true; | ||
} | ||
var li = jQuery('<li></li>'); | ||
list.append(li); | ||
if (item.domobj) { | ||
var text = item.domobj.nodeName + ' (' + item.type + ') '; | ||
li.text(text); | ||
if (item.domobj.nodeType == 3) { | ||
var i = jQuery('<i></i>'); | ||
if (item.type == 'partial') { | ||
i.text(item.domobj.nodeValue.substring(item.startOffset, item.endOffset)); | ||
} else { | ||
i.text(item.domobj.nodeValue); | ||
} | ||
li.append(i); | ||
} | ||
var sub = that.renderRangeTree(item.children); | ||
if (sub) { | ||
li.append(sub); | ||
} | ||
} | ||
}); | ||
|
||
return list; | ||
} | ||
} | ||
|
||
|
||
}); |