Index: wpfunction.js
===================================================================
--- wpfunction.js (revision 4)
+++ wpfunction.js (working copy)
@@ -1,538 +1,542 @@
-WP_HOVER ={
- DEBUG:1,
- index:[],
- listhoverlet:[],
- listcategory:[],
- listcategory1:[],
- listcategory11:[],
- listcategory12:[],
- finallyurl:'',
- finallyurl1:'',
- selected_word:'',
- _replace:false,
- linkData:[],
- currentData:[],
- text: '',
-
-
- init: function(_word) {
- var word = (_word.length ===0 )? '': window.decodeURIComponent(_word);
- WP_HOVER.hideRefresh();
- var temp = _word.replace(/[^a-zA-Z 0-9'"]+/g,'');
- document.getElementById('selectedword').value = temp;
- var activeEditor = tinyMCE.activeEditor;
- var str = activeEditor.getContent();
- WP_HOVER.linkDatas = ( !parent.window.WP_HOVER.previousHoverlets)?[]: parent.window.WP_HOVER.previousHoverlets;
-
- if(WP_HOVER.linkDatas.length>0){
- if(_word!=''){
- WP_HOVER.show_previous_hoverlets(document.getElementById('selectedword').value);
- }
- else{
- WP_HOVER.show_previous_hoverlets(document.getElementById('selectedword').value);
- }
-
- }
- },
-
- show_previous_hoverlets: function(_word){
-
- var linkDatas = parent.window.WP_HOVER.previousHoverlets;
-
- var used_hoverlets = document.getElementById('used_hoverlets');
- var usethis_btn = document.createElement("input");
- usethis_btn.setAttribute("type", 'button');
- usethis_btn.name = 'usethis';
- usethis_btn.value = 'Use This';
- usethis_btn.className = 'usebutton';
- var div_radio=document.createElement("div");
- div_radio.id='divradio';
- div_radio.cssText='display:none';
- used_hoverlets.appendChild(div_radio);
- for(var i=0;i< linkDatas.length ; i++){
- //add a chkbox and its events
- //Create an input type radio button dynamically.
- var radio_btn = document.createElement("input");
- radio_btn.setAttribute("type", 'radio');
- radio_btn.name = 'usedbtn';
- radio_btn.linkData = linkDatas[i];
- radio_btn.linkData.kw = (_word)? _word : linkDatas[i].kw;
- radio_btn.onclick=function(e){
-
- document.getElementById('divradio').linkData=this.linkData;
- };
-
-
-
- //add the label
- var _txt = document.createElement('span');
- _txt.style.cssText='cursor:pointer;margin:3px;';
- //_txt.innerHTML = '' + linkDatas[i].title + '
';
- _txt.innerHTML = linkDatas[i].title;
-
- //a parent row
- if(document.getElementById('u'+linkDatas[i].name) == null){
-
- var _row = document.createElement('div');
- _row.id = 'u'+linkDatas[i].name;
- _row.appendChild(radio_btn);
- _row.appendChild(_txt);
-
- used_hoverlets.appendChild(_row);
-
- YAHOO.util.Event.addListener(usethis_btn,'click', function(e){
- //when clicked simulate the "use this" button being clicked
- //refresh_hoverlet(_btn.linkData);
-
-
- var _link = WP_HOVER.convert_linkData_to(document.getElementById('divradio').linkData,"url");
- if(_word=='' && document.getElementById('selectedword').value!=''){
- WP_HOVER.keywordHover2(document.getElementById('selectedword').value,_link);
- }else{
- if(document.getElementById('selectedword').value!=''){
- WP_HOVER.keywordHover2(_word,_link);
- }
- }
-
- if(document.getElementById('keywordtext').value!=''){
- WP_HOVER.keywordHover();
- }
-
-
- WP_HOVER.hide_popup();
-
- });
- }
- }
- used_hoverlets.appendChild(usethis_btn);
- },
- convert_linkData_to:function(linkData,Option){
-
- WP_HOVER.finallyurl1='http://'+linkData.event+'.hover.in/hoverlet/'+linkData.nick+'/'+linkData.name;
- var encodedKw=linkData.kw.split('/');
- var kw1='';
- if(encodedKw.length>1){
- for(var i=0;i'+document.getElementById('selectedword').value+''));
- }
- }
- if(document.getElementById('keywordtext').value!=''){
- WP_HOVER.keywordHover();
- }
-
-
- }
-
- tinyMCEPopup.execCommand("mceEndUndoLevel");
- WP_HOVER.hide_popup();
- }
- },
-
- hide_popup:function(){
- tinyMCEPopup.close();
- },
-
-
- showRefresh:function() {
- document.getElementById('refresh').style.display='';
- },
-
- hideRefresh:function(){
- document.getElementById('refresh').style.display='none';
- },
-
- dynamic:function(url) {
- var x = document.createElement("script");
- x.setAttribute("type","text/javascript");
- x.setAttribute("src", url);
- document.getElementsByTagName("head")[0].appendChild(x);
- },
-
- returnUrl:function() {
- var url = "http://api.hover.in/public/hoverlet/community.yaws?callback=WP_HOVER.community_callback";
- return(url);
- },
-
- community_callback:function(Obj) {
-
-
- for(var i=0;i1; i--)
- {
-
- for(var j = 0; j < i-1; j++)
- {
- if(List[WP_HOVER.listcategory1[j]]';
-
- document.getElementById('wrapper1').appendChild(category1);
- var category2=document.createElement("div");
-
- category2.className="accordionContent";
-
- document.getElementById('wrapper1').appendChild(category2);
- category2.appendChild(category);
- }
-
-
- for(var i=0;i1){
- for(;j0){
- _final_word=_final_word.substring(0,_final_word.length-1);
- }
- }
- var _link=''+_word+'';
-
- newstr = WP_HOVER.replaceRegex( newstr, _final_word , _link);
- }
- activeEditor.setContent(newstr);
- },
-
- replaceRegex: function (oldstr,_word, _link ) {
- var div = document.createElement('div');
- div.innerHTML = oldstr;
- WP_HOVER.findAndReplace(_word,_link,div);
- var newstr = div.innerHTML;
- return newstr;
- },
- check1:function(){
-
- if(document.getElementById('keywordtext').style.display=='none'){
- document.getElementById('keywordtext').style.display='';
- }else {
-
- document.getElementById('keywordtext').style.display='none';
- }
- },
- check2:function(){
- if(WP_HOVER._replace){
- WP_HOVER._replace=false;
- }else{
- WP_HOVER._replace=true;
- }
- },
- trim: function(_word){
- return _word.replace(/^\s+/, '').replace(/\s+$/, '');
- },
- //when replace all is checked
- keywordHover1:function(_word){
- //var keywordt=parent.window.tinyMCE.activeEditor.selection.getContent({format:text});
- _word = WP_HOVER.trim(_word);
- var activeEditor = tinyMCE.activeEditor;
- var str = activeEditor.getContent();
- var encodedKw=_word.split('/');
- var _final_word=_word,j=0;
- if(encodedKw.length>1){
- for(;j0){
- _final_word=_final_word.substring(0,_final_word.length-1);
- }
- }
- var _link=''+_word+'';
-
- var newstr = WP_HOVER.replaceRegex( str, _word, _link);
-
- activeEditor.setContent(newstr);
- },
- findAndReplace: function(searchText, replacement, searchNode) {
- if (!searchText || typeof replacement === "undefined") {
- return;
- }
- var regex = typeof searchText === "string" ? new RegExp("([ ]+)*"+searchText+"([ ]+)*", "gim") : searchText, childNodes = (searchNode || document.body).childNodes, cnLength = childNodes.length, excludes = "html,head,style,title,link,meta,script,object,iframe,a,font,embed,object";
- while (cnLength--) {
- var currentNode = childNodes[cnLength];
- if (currentNode.nodeType === 1 &&
- (excludes + ",").indexOf(currentNode.nodeName.toLowerCase() + ",") === -1) {
- arguments.callee(searchText, replacement, currentNode);
- }
- if (currentNode.nodeType !== 3 || !regex.test(currentNode.data)) {
- continue;
- }
- var parent = currentNode.parentNode, frag = function () {var html = currentNode.data.replace(regex,function(){var rep;var pre = (arguments[1])?arguments[1]:'',post = (arguments[2])?arguments[2]:'';rep =pre.replace(' ',' ')+ replacement+post.replace(' ',' ');return rep;}), wrap = document.createElement("div"), frag = document.createDocumentFragment();wrap.innerHTML = html;while (wrap.firstChild) {frag.appendChild(wrap.firstChild);}return frag;}();
- parent.insertBefore(frag, currentNode);
- parent.removeChild(currentNode);
- }
- },
- keywordHover2:function(_word,_link){
- //var keywordt=parent.window.tinyMCE.activeEditor.selection.getContent({format:text});
- var activeEditor = tinyMCE.activeEditor;
- var str = activeEditor.getContent();
- var encodedKw=_word.split('/');
- var kw1='';
- if(encodedKw.length>1){
- var i=0;
- for(;i'+kw1+'';
-
- var newstr = WP_HOVER.replaceRegex( str, _word, _link);
- activeEditor.setContent(newstr);
- },
- log: function(msg){
- if(!WP_HOVER.DEBUG){
- return;
- }
- if("undefined" == typeof console){
- console = {log: function(_msg){
- alert(_msg);
- }
- };
- }
- try{console.log(msg);}catch(er){};
- }
-};
-
-var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}output=output+this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}if(enc4!=64){output=output+String.fromCharCode(chr3);}}output=Base64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}return string;}};
-
-
-(function(){
- var tabView = new YAHOO.widget.TabView('demo');
-})();
-
-
-jQuery(document).ready(
- function(){
- parent.window.WP_HOVER.previousHoverlets= ( !parent.window.WP_HOVER.previousHoverlets ) ? [] : parent.window.WP_HOVER.previousHoverlets;
- var _word = window.decodeURIComponent(parent.WP_HOVER.word);
- WP_HOVER.init(_word);
- WP_HOVER.dynamic(WP_HOVER.returnUrl());
-
- });
+WP_HOVER ={
+ DEBUG:1,
+ index:[],
+ listhoverlet:[],
+ listcategory:[],
+ listcategory1:[],
+ listcategory11:[],
+ listcategory12:[],
+ finallyurl:'',
+ finallyurl1:'',
+ selected_word:'',
+ _replace:false,
+ linkData:[],
+ currentData:[],
+ text: '',
+
+
+ init: function(_word) {
+ var word = (_word.length ===0 )? '': window.decodeURIComponent(_word);
+ WP_HOVER.hideRefresh();
+ var temp = _word.replace(/[^a-zA-Z 0-9'"]+/g,'');
+ document.getElementById('selectedword').value = temp;
+ var activeEditor = tinyMCE.activeEditor;
+ var str = activeEditor.getContent();
+ WP_HOVER.linkDatas = ( !parent.window.WP_HOVER.previousHoverlets)?[]: parent.window.WP_HOVER.previousHoverlets;
+
+ if(WP_HOVER.linkDatas.length>0){
+ if(_word!=''){
+ WP_HOVER.show_previous_hoverlets(document.getElementById('selectedword').value);
+ }
+ else{
+ WP_HOVER.show_previous_hoverlets(document.getElementById('selectedword').value);
+ }
+
+ }
+ },
+
+ show_previous_hoverlets: function(_word){
+
+ var linkDatas = parent.window.WP_HOVER.previousHoverlets;
+
+ var used_hoverlets = document.getElementById('used_hoverlets');
+ var usethis_btn = document.createElement("input");
+ usethis_btn.setAttribute("type", 'button');
+ usethis_btn.name = 'usethis';
+ usethis_btn.value = 'Use This';
+ usethis_btn.className = 'usebutton';
+ var div_radio=document.createElement("div");
+ div_radio.id='divradio';
+ div_radio.cssText='display:none';
+ used_hoverlets.appendChild(div_radio);
+ for(var i=0;i< linkDatas.length ; i++){
+ //add a chkbox and its events
+ //Create an input type radio button dynamically.
+ var radio_btn = document.createElement("input");
+ radio_btn.setAttribute("type", 'radio');
+ radio_btn.name = 'usedbtn';
+ radio_btn.linkData = linkDatas[i];
+ radio_btn.linkData.kw = (_word)? _word : linkDatas[i].kw;
+ radio_btn.onclick=function(e){
+
+ document.getElementById('divradio').linkData=this.linkData;
+ };
+
+
+
+ //add the label
+ var _txt = document.createElement('span');
+ _txt.style.cssText='cursor:pointer;margin:3px;';
+ //_txt.innerHTML = '' + linkDatas[i].title + '
';
+ _txt.innerHTML = linkDatas[i].title;
+
+ //a parent row
+ if(document.getElementById('u'+linkDatas[i].name) == null){
+
+ var _row = document.createElement('div');
+ _row.id = 'u'+linkDatas[i].name;
+ _row.appendChild(radio_btn);
+ _row.appendChild(_txt);
+
+ used_hoverlets.appendChild(_row);
+
+ YAHOO.util.Event.addListener(usethis_btn,'click', function(e){
+ //when clicked simulate the "use this" button being clicked
+ //refresh_hoverlet(_btn.linkData);
+
+
+ var _link = WP_HOVER.convert_linkData_to(document.getElementById('divradio').linkData,"url");
+ if(_word=='' && document.getElementById('selectedword').value!=''){
+ WP_HOVER.keywordHover2(document.getElementById('selectedword').value,_link);
+ }else{
+ if(document.getElementById('selectedword').value!=''){
+ WP_HOVER.keywordHover2(_word,_link);
+ }
+ }
+
+ if(document.getElementById('keywordtext').value!=''){
+ WP_HOVER.keywordHover();
+ }
+
+
+ WP_HOVER.hide_popup();
+
+ });
+ }
+ }
+ used_hoverlets.appendChild(usethis_btn);
+ },
+ convert_linkData_to:function(linkData,Option){
+
+ WP_HOVER.finallyurl1='http://'+linkData.event+'.hover.in/hoverlet/'+linkData.nick+'/'+linkData.name;
+ var encodedKw=linkData.kw.split('/');
+ var kw1='';
+ if(encodedKw.length>1){
+ for(var i=0;i'+document.getElementById('selectedword').value+''));
+ }
+ }
+ if(document.getElementById('keywordtext').value!=''){
+ WP_HOVER.keywordHover();
+ }
+
+
+ }
+
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
+ WP_HOVER.hide_popup();
+ }
+ },
+
+ hide_popup:function(){
+ tinyMCEPopup.close();
+ },
+
+
+ showRefresh:function() {
+ document.getElementById('refresh').style.display='';
+ },
+
+ hideRefresh:function(){
+ document.getElementById('refresh').style.display='none';
+ },
+
+ dynamic:function(url) {
+ var x = document.createElement("script");
+ x.setAttribute("type","text/javascript");
+ x.setAttribute("src", url);
+ document.getElementsByTagName("head")[0].appendChild(x);
+ },
+
+ returnUrl:function() {
+ var url = "http://api.hover.in/public/hoverlet/community.yaws?callback=WP_HOVER.community_callback";
+ return(url);
+ },
+
+ community_callback:function(Obj) {
+
+
+ for(var i=0;i1; i--)
+ {
+
+ for(var j = 0; j < i-1; j++)
+ {
+ if(List[WP_HOVER.listcategory1[j]]';
+
+
+
+ document.getElementById('wrapper1').appendChild(category1);
+ var category2=document.createElement("div");
+
+ category2.className="accordionContent";
+
+ document.getElementById('wrapper1').appendChild(category2);
+ category2.appendChild(category);
+ }
+
+
+ for(var i=0;i1){
+ for(;j0){
+ _final_word=_final_word.substring(0,_final_word.length-1);
+ }
+ }
+ var _link=''+_word+'';
+
+ newstr = WP_HOVER.replaceRegex( newstr, _final_word , _link);
+ }
+ activeEditor.setContent(newstr);
+ },
+
+ replaceRegex: function (oldstr,_word, _link ) {
+ var div = document.createElement('div');
+ div.innerHTML = oldstr;
+ WP_HOVER.findAndReplace(_word,_link,div);
+ var newstr = div.innerHTML;
+ return newstr;
+ },
+ check1:function(){
+
+ if(document.getElementById('keywordtext').style.display=='none'){
+ document.getElementById('keywordtext').style.display='';
+ }else {
+
+ document.getElementById('keywordtext').style.display='none';
+ }
+ },
+ check2:function(){
+ if(WP_HOVER._replace){
+ WP_HOVER._replace=false;
+ }else{
+ WP_HOVER._replace=true;
+ }
+ },
+ trim: function(_word){
+ return _word.replace(/^\s+/, '').replace(/\s+$/, '');
+ },
+ //when replace all is checked
+ keywordHover1:function(_word){
+ //var keywordt=parent.window.tinyMCE.activeEditor.selection.getContent({format:text});
+ _word = WP_HOVER.trim(_word);
+ var activeEditor = tinyMCE.activeEditor;
+ var str = activeEditor.getContent();
+ var encodedKw=_word.split('/');
+ var _final_word=_word,j=0;
+ if(encodedKw.length>1){
+ for(;j0){
+ _final_word=_final_word.substring(0,_final_word.length-1);
+ }
+ }
+ var _link=''+_word+'';
+
+ var newstr = WP_HOVER.replaceRegex( str, _word, _link);
+
+ activeEditor.setContent(newstr);
+ },
+ findAndReplace: function(searchText, replacement, searchNode) {
+ if (!searchText || typeof replacement === "undefined") {
+ return;
+ }
+ var regex = typeof searchText === "string" ? new RegExp("([ ]+)*"+searchText+"([ ]+)*", "gim") : searchText, childNodes = (searchNode || document.body).childNodes, cnLength = childNodes.length, excludes = "html,head,style,title,link,meta,script,object,iframe,a,font,embed,object";
+ while (cnLength--) {
+ var currentNode = childNodes[cnLength];
+ if (currentNode.nodeType === 1 &&
+ (excludes + ",").indexOf(currentNode.nodeName.toLowerCase() + ",") === -1) {
+ arguments.callee(searchText, replacement, currentNode);
+ }
+ if (currentNode.nodeType !== 3 || !regex.test(currentNode.data)) {
+ continue;
+ }
+ var parent = currentNode.parentNode, frag = function () {var html = currentNode.data.replace(regex,function(){var rep;var pre = (arguments[1])?arguments[1]:'',post = (arguments[2])?arguments[2]:'';rep =pre.replace(' ',' ')+ replacement+post.replace(' ',' ');return rep;}), wrap = document.createElement("div"), frag = document.createDocumentFragment();wrap.innerHTML = html;while (wrap.firstChild) {frag.appendChild(wrap.firstChild);}return frag;}();
+ parent.insertBefore(frag, currentNode);
+ parent.removeChild(currentNode);
+ }
+ },
+ keywordHover2:function(_word,_link){
+ //var keywordt=parent.window.tinyMCE.activeEditor.selection.getContent({format:text});
+ var activeEditor = tinyMCE.activeEditor;
+ var str = activeEditor.getContent();
+ var encodedKw=_word.split('/');
+ var kw1='';
+ if(encodedKw.length>1){
+ var i=0;
+ for(;i'+kw1+'';
+
+ var newstr = WP_HOVER.replaceRegex( str, _word, _link);
+ activeEditor.setContent(newstr);
+ },
+ log: function(msg){
+ if(!WP_HOVER.DEBUG){
+ return;
+ }
+ if("undefined" == typeof console){
+ console = {log: function(_msg){
+ alert(_msg);
+ }
+ };
+ }
+ try{console.log(msg);}catch(er){};
+ }
+};
+
+var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=Base64._utf8_encode(input);while(i>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;}output=output+this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);}return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);}if(enc4!=64){output=output+String.fromCharCode(chr3);}}output=Base64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}}return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}return string;}};
+
+
+(function(){
+ var tabView = new YAHOO.widget.TabView('demo');
+})();
+
+
+jQuery(document).ready(
+ function(){
+ parent.window.WP_HOVER.previousHoverlets= ( !parent.window.WP_HOVER.previousHoverlets ) ? [] : parent.window.WP_HOVER.previousHoverlets;
+ var _word = window.decodeURIComponent(parent.WP_HOVER.word);
+ WP_HOVER.init(_word);
+ WP_HOVER.dynamic(WP_HOVER.returnUrl());
+
+ });