├── README.md └── plugins ├── Calculate.js ├── Custom page margin.js ├── Custom search scope.js ├── Custom table style.js ├── Edit with fillable form.js ├── Export records to CSV file.js ├── Insert checkbox.js ├── Insert quick text.js ├── Markdown2html.js ├── Markdownattach.js ├── Open folder location.js ├── README.md ├── Recover database.js ├── Save2QuickText.js ├── SetBackgroundColor.js ├── SetBackgroundImg.js ├── SetFontSize.js ├── Syntax highlight.js └── WordCount.js /README.md: -------------------------------------------------------------------------------- 1 | # myBase Plugins 2 | 3 | The .js files are **for myBase 7.x only**. 4 | 5 | > More information about myBase 7.x can be found in the following website: [http://www.wjjsoft.com/mybase.html](http://www.wjjsoft.com/mybase.html "myBase Website"). 6 | 7 | 8 | **Usage:** 9 | 1. Close the software 10 | 2. Copy the .js file to .\plugins sub folder. 11 | 3. Run the software again. 12 | 4. Based on the setting of the plugins, you can find the new functions from different menu. 13 | 5. More details can be found in myBase website: [http://www.wjjsoft.com/mybase_jsapi.html#install](http://www.wjjsoft.com/mybase_jsapi.html#install) 14 | 15 | **Note:** 16 | 1. There are self-developed plugins and the plugins developed by wjj. 17 | 2. Use the plugins **at your own risks**. 18 | 3. Please **fully test** before using to your productive data file. 19 | 4. Any question or problem, please raise an issue. 20 | 21 | -------------------------------------------------------------------------------- /plugins/Calculate.js: -------------------------------------------------------------------------------- 1 |  2 | //sValidation=nyfjs 3 | //sCaption=Calculate 4 | //sHint=Calculate 02072015 5 | //sCategory=MainMenu.TxtUtils 6 | //sPosition=XZ-255 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT; HTMLSELECTED 8 | //sID=p.gzhaha.Calculate 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=Xia Zhang 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Xia Zhang (MIT Licensed) 16 | ///////////////////////////////////////////////////////////////////// 17 | 18 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 19 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 20 | 21 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 22 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 23 | 24 | try{ 25 | var xNyf=new CNyfDb(-1); 26 | if(xNyf.isOpen()){ 27 | if(!xNyf.isReadonly()){ 28 | if(plugin.isContentEditable()){ 29 | 30 | 31 | //load math.js 32 | var xFn=new CLocalFile(plugin.getScriptFile()); 33 | var sDir=xFn.getDirectory(); 34 | xFn=new CLocalFile(sDir, 'math.js'); 35 | sCode=xFn.loadText(); 36 | 37 | if (sCode){ 38 | //get selected text from info item edit area 39 | var sCon = plugin.getSelectedText(-1, false); 40 | eval.call(null, sCode); 41 | 42 | //Calculate 43 | try{ 44 | //remove all space 45 | sCon1 = sCon.replace(/\s/g, '') 46 | 47 | //Rounding for four digits 48 | //var cResult = math.round(math.eval(sCon1)*10000)/10000; 49 | //11.01.2016 change to "toFixed", 4 is used to restrict the number digits 50 | var cResult = math.eval(sCon1).toFixed(4); 51 | var cFinal = sCon + " = " + cResult + ' '; 52 | plugin.replaceSelectedText(-1, cFinal, false); 53 | } 54 | catch(e){ 55 | alert(e); 56 | } 57 | }else{ 58 | alert('Component script file missing.'+'\n\n'+'math.js'); 59 | } 60 | }else{ 61 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 62 | } 63 | }else{ 64 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 65 | } 66 | }else{ 67 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 68 | } 69 | }catch(e){ 70 | alert(e); 71 | } 72 | -------------------------------------------------------------------------------- /plugins/Custom page margin.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Custom page margin ... 4 | //sHint=Set the margin attributes for of the page 5 | //sCategory=MainMenu.Paragraph 6 | //sPosition= 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT 8 | //sID=p.CustomPageMargins 9 | //sAppVerMin=7.0 10 | //sAuthor=wjjsoft 11 | 12 | ///////////////////////////////////////////////////////////////////// 13 | // Extension scripts for myBase Desktop v7.x 14 | // Copyright 2015 Wjj Software. All rights Reserved. 15 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 16 | ///////////////////////////////////////////////////////////////////// 17 | // This code is property of Wjj Software (WJJSOFT). You may not use it 18 | // for any commercial purpose without preceding consent from authors. 19 | ///////////////////////////////////////////////////////////////////// 20 | 21 | //11:20 9/24/2015 initial commit by wjj; 22 | //This plugin is used to set margin-left/right for element of the current HTML content; 23 | 24 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 25 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 26 | 27 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 28 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 29 | 30 | try{ 31 | var xNyf=new CNyfDb(-1); 32 | 33 | if(xNyf.isOpen()){ 34 | 35 | if(!xNyf.isReadonly()){ 36 | 37 | if(plugin.isContentEditable()){ 38 | 39 | var _unit_of=function(s){ 40 | //return (s||'').replace(/^([e\d\s]+)(?=em|px|pt|%$)/i, ''); 41 | return (s||'').replace(/^([e\d\s]+)(?=[a-z%]{0,2}$)/i, ''); 42 | }; 43 | 44 | var sCfgKey1='CustomPageMargins.Left', sCfgKey2='CustomPageMargins.Right'; 45 | 46 | var vVals=[ 47 | '|'+_lc('p.Common.Initial', 'Initial') 48 | , '0.2em', '0.4em', '0.6em', '0.8em', '1em', '1.2em', '1.4em', '1.6em', '1.8em', '2em', '2.5em', '3em', '4em', '5em' 49 | , '5px', '10px', '15px', '20px', '25px', '30px', '35px', '40px', '45px', '50px' 50 | ]; 51 | 52 | var sLeft0=''; 53 | { 54 | var sCode='cssUtil(document.body, "margin-left");'; 55 | sLeft0=plugin.runDomScript(-1, sCode); 56 | } 57 | 58 | var sRight0=''; 59 | { 60 | var sCode='cssUtil(document.body, "margin-right");'; 61 | sRight0=plugin.runDomScript(-1, sCode); 62 | } 63 | 64 | var vFields = [ 65 | {sField: "comboedit", sLabel: _lc2('Left', 'Left margin of page'), vItems: vVals, sInit: sLeft0||localStorage.getItem(sCfgKey1)||'', bReq: false} 66 | , {sField: "comboedit", sLabel: _lc2('Right', 'Right margin of page'), vItems: vVals, sInit: sRight0||localStorage.getItem(sCfgKey2)||'', bReq: false} 67 | ]; 68 | 69 | var vRes = input(plugin.getScriptTitle(), vFields, {nMinSize: 400, vMargins: [8, 0, 30, 0]}); 70 | if(vRes && vRes.length==2){ 71 | 72 | var sLeft=vRes[0], sRight=vRes[1]; 73 | 74 | localStorage.setItem(sCfgKey1, sLeft); 75 | localStorage.setItem(sCfgKey2, sRight); 76 | 77 | if(sLeft != '' && _unit_of(sLeft)=='') sLeft+='px'; 78 | if(sRight != '' && _unit_of(sRight)=='') sRight+='px'; 79 | 80 | var sCode='\n'+'g_xUndoStack.beginMacro("body margin");' 81 | + 'cssUtil(document.body, [{key: "margin-left", val: "%LEFT%"}, {key: "margin-right", val: "%RIGHT%"}]);' 82 | .replace(/%LEFT%/g, sLeft).replace(/%RIGHT%/g, sRight) 83 | + 'g_xUndoStack.endMacro();' 84 | ; 85 | if(plugin.runDomScript(-1, sCode)){ 86 | //done; 87 | } 88 | } 89 | 90 | }else{ 91 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 92 | } 93 | 94 | }else{ 95 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 96 | } 97 | 98 | }else{ 99 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 100 | } 101 | }catch(e){ 102 | alert(e); 103 | } 104 | -------------------------------------------------------------------------------- /plugins/Custom search scope.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Custom search scope ... 4 | //sHint=Search for words or RegExp within a specified scope 5 | //sCategory=MainMenu.Search 6 | //sPosition= 7 | //sCondition=CURDB 8 | //sID=p.CustomSearch 9 | //sAppVerMin=7.0 10 | //sAuthor=wjjsoft 11 | 12 | ///////////////////////////////////////////////////////////////////// 13 | // Extension scripts for myBase Desktop v7.x 14 | // Copyright 2015 Wjj Software. All rights Reserved. 15 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 16 | ///////////////////////////////////////////////////////////////////// 17 | // This code is property of Wjj Software (WJJSOFT). You may not use it 18 | // for any commercial purpose without preceding consent from authors. 19 | ///////////////////////////////////////////////////////////////////// 20 | 21 | //17:28 9/24/2015 initial commit by wjj; 22 | //This plugin is used to run searches for words or RegExp with in a specified scope; 23 | //To search for RegExp, make sure to add a pair of slashes surrouding the find phrase, like this: /pattern/i 24 | 25 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 26 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 27 | 28 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 29 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 30 | 31 | var _scale_file_size=function(n){ 32 | var nKilo=1024; 33 | var nMega=nKilo*nKilo; 34 | var nGiga=nKilo*nKilo*nKilo; 35 | var s=''; 36 | if(n>=nGiga){ 37 | s=''+Math.floor(n/nGiga*10)/10+' GiB'; 38 | }else if(n>=nMega){ 39 | s=''+Math.floor(n/nMega*10)/10+' MiB'; 40 | }else if(n>=nKilo){ 41 | s=''+Math.floor(n/nKilo*10)/10+' KiB'; 42 | }else{ 43 | s=''+n+' B'; 44 | } 45 | return s; 46 | }; 47 | 48 | try{ 49 | 50 | var xNyf=new CNyfDb(-1); 51 | if(xNyf.isOpen()){ 52 | 53 | var sCfgKey1='CustomSearch.sPhrase', sCfgKey2='CustomSearch.iRange', sCfgKey3='CustomSearch.bTitles', sCfgKey4='CustomSearch.bContents', sCfgKey5='CustomSearch.bAttachments', sCfgKey6='CustomSearch.bAllDbs'; 54 | 55 | var vRange=[ 56 | _lc('p.Common.CurBranch', 'Current branch') 57 | , _lc('p.Common.CurDB', 'Current database') 58 | ]; 59 | 60 | var vScope=[ 61 | localStorage.getItem(sCfgKey3)+'|'+'Item titles' 62 | , localStorage.getItem(sCfgKey4)+'|'+'HTML contents' 63 | , localStorage.getItem(sCfgKey5)+'|'+'Attachments' 64 | ]; 65 | 66 | var vFields = [ 67 | {sField: "lineedit", sLabel: _lc2('Phrase', 'Search for words or RegExp (eg. /pattern/i ):'), sInit: localStorage.getItem(sCfgKey1)||'', bReq: true} 68 | , {sField: 'check', sLabel: 'Data scope:', vItems: vScope} 69 | , {sField: "combolist", sLabel: _lc2('Range', 'Outline scope:'), vItems: vRange, nInit: localStorage.getItem(sCfgKey2)||'', bReq: false} 70 | , {sField: 'check', sLabel: '', vItems: [localStorage.getItem(sCfgKey6)+'|'+'With all opened databases']} 71 | ]; 72 | 73 | var vRes = input(plugin.getScriptTitle(), vFields, {nMinSize: 540, vMargins: [8, 0, 30, 0], bVert: true}); 74 | if(vRes && vRes.length>=4){ 75 | 76 | var sFor=vRes[0], vChk=vRes[1], iRng=vRes[2], bAllDbs=vRes[3][0]; 77 | var bTitles=vChk[0], bContents=vChk[1], bAttachments=vChk[2]; 78 | 79 | sFor=_trim(sFor); 80 | 81 | localStorage.setItem(sCfgKey1, sFor); 82 | localStorage.setItem(sCfgKey2, iRng); 83 | localStorage.setItem(sCfgKey3, bTitles); 84 | localStorage.setItem(sCfgKey4, bContents); 85 | localStorage.setItem(sCfgKey5, bAttachments); 86 | localStorage.setItem(sCfgKey6, bAllDbs); 87 | 88 | if(bTitles || bContents || bAttachments){ 89 | 90 | plugin.initProgressRange(plugin.getScriptTitle(), 0); 91 | 92 | var mToScan={}; 93 | var sDefNoteFn=plugin.getDefNoteFn(); 94 | 95 | var nCountOfEntries=0; 96 | 97 | //2013.12.12 users reported the 'runtime error' that possibly came from Array.push(); 98 | //We encountered the similar problem within the epub making scripts; 99 | //Workaround: use the key-val map to substitute the Array; 100 | 101 | var _push=function(i, p, n){ 102 | var v=mToScan[i]; 103 | if(!v) v=mToScan[i]=[]; 104 | v[v.length]={sSsgPath: p, sSsgName: n}; 105 | nCountOfEntries++; 106 | }; 107 | 108 | var _load_entries=function(iDbPos){ 109 | var bBranch=(iRng==0), sCurItem=bBranch ? plugin.getCurInfoItem(iDbPos) : plugin.getDefRootContainer(); 110 | if(!sCurItem){ 111 | sCurItem=plugin.getDefRootContainer(); 112 | bBranch=false; 113 | } 114 | var xDb=new CNyfDb(iDbPos); 115 | xDb.traverseOutline(sCurItem, bBranch, function(sSsgPath, iLevel){ 116 | 117 | var sTitle=xDb.getFolderHint(sSsgPath); if(!sTitle) sTitle='Untitled'; 118 | 119 | var bContinue=plugin.ctrlProgressBar(sTitle+' ['+nCountOfEntries+']', 1, true); 120 | if(!bContinue){mToScan={}; return true;} 121 | 122 | if(bTitles){ 123 | _push(iDbPos, sSsgPath, ''); 124 | } 125 | 126 | if(bContents||bAttachments){ 127 | var vFiles=xDb.listFiles(sSsgPath); 128 | for(var i in vFiles){ 129 | var sSsgName=vFiles[i]; 130 | if(sSsgName==sDefNoteFn){ 131 | if(bContents) _push(iDbPos, sSsgPath, sSsgName); 132 | }else{ 133 | if(bAttachments) _push(iDbPos, sSsgPath, sSsgName); 134 | } 135 | } 136 | } 137 | }); 138 | }; 139 | 140 | if(bAllDbs){ 141 | var n=plugin.getDbCount(); 142 | while( n-- > 0 ) _load_entries(n); 143 | 144 | }else{ 145 | _load_entries(plugin.getCurDbIndex()); 146 | } 147 | 148 | var xRE=undefined; 149 | { 150 | //construct the xRE; 151 | var v=sFor.match(/^\/(.*)\/([igm]*)$/); 152 | if(v && v.length>1){ 153 | var sRE=v[1], sOpt=v[2]; 154 | if(sRE){ 155 | xRE=new RegExp(sRE, sOpt.replace(/g/gi, '')); //remove the redundant 'g'. 156 | } 157 | } 158 | } 159 | 160 | var _match_boolean=function(s){ 161 | var bOK=false; 162 | //To-do ... ?????????? 163 | return bOK; 164 | }; 165 | 166 | var _match=function(s){ 167 | var bOK=false, s=s.replace(/[\r\n]/g, ' '); 168 | if(xRE!=undefined){ 169 | bOK=s.match(xRE); 170 | } 171 | if(!bOK){ 172 | bOK=_match_boolean(s); 173 | } 174 | if(!bOK){ 175 | bOK=s.toLowerCase().indexOf(sFor.toLowerCase())>=0; 176 | } 177 | return bOK; 178 | }; 179 | 180 | var _findstr_to_hilite=function(s){ 181 | s=s||''; 182 | if(xRE!=undefined){ 183 | //2012.2.7 consider the regexp control words, like: /\bmain\b/i, that is to highlight 'main', rather than 'b' or 'i'; 184 | s=s.replace(/\\\w/g, ''); 185 | s=s.replace(/\/[igm]*$/g, ''); 186 | } 187 | s=s.replace(/[`~\!@#\$%\^&\*\(\)_\+\-=\[\]\\\{\}\|;\'\:\"\,\.\/<>\?\Z\A]/g, ' ').replace(/\s{2,}/g, ' '); 188 | return _trim(s); 189 | }; 190 | 191 | //2011.9.4 this is used for highlighting the search words; 192 | var sFindStr=_findstr_to_hilite(sFor); 193 | 194 | //plugin.runQuery({bListOut: true}); //make sure the Query-results window is open and cleared; 195 | 196 | plugin.initProgressRange(plugin.getScriptTitle(), nCountOfEntries); 197 | 198 | plugin.showResultsPane(true, true); 199 | plugin.setResultsPaneTitle(plugin.getScriptTitle()+' ['+sFor+']'); 200 | 201 | var nFound=0; 202 | for(var iDbPos in mToScan){ 203 | 204 | var vII=mToScan[iDbPos]; 205 | if(vII.length>0){ 206 | 207 | var xDb=new CNyfDb(parseInt(iDbPos)), sDbFn=xDb.getDbFile(); 208 | for(var i in vII){ 209 | 210 | var xII=vII[i]; 211 | var sSsgPath=xII.sSsgPath, sSsgName=xII.sSsgName, xSsgFn=new CLocalFile(sSsgPath, sSsgName); 212 | var sTitle=xDb.getFolderHint(sSsgPath)||''; 213 | var bDefNote=(sSsgName==sDefNoteFn); 214 | 215 | var nSize=xDb.getFileSize(xSsgFn, false); 216 | 217 | var bContinue=plugin.ctrlProgressBar( ((bDefNote?'':sSsgName)||sTitle||'Untitled')+' ['+_scale_file_size(nSize)+']', 1, true); 218 | if(!bContinue) break; 219 | 220 | var sTxt=''; 221 | if(sSsgName){ 222 | 223 | var sTxt=xDb.parseFile(sSsgPath, sSsgName, false); 224 | 225 | if(bDefNote){ 226 | //if(sTitle) sTxt=sTitle+'\n'+sTxt; 227 | }else{ 228 | //2013.10.21 take a look at filenames as well for attachments. 229 | sTxt=sSsgName+'\n'+sTxt; 230 | } 231 | 232 | var sHint=xDb.getFileHint(xSsgFn); 233 | if(sHint) sTxt+='\n'+sHint; 234 | }else{ 235 | //To scan item titles only; 236 | sTxt=sTitle; 237 | } 238 | 239 | if(sTxt && _match(sTxt)){ 240 | nFound++; 241 | plugin.appendToResults(sDbFn, sSsgPath, sSsgName, sFindStr); 242 | } 243 | } 244 | } 245 | } 246 | 247 | plugin.setResultsPaneTitle(plugin.getScriptTitle()+' ['+sFor+'] '+_lc('p.Common.Found', 'Found: (%nFound%)').replace(/%nFound%/g, ''+nFound)); 248 | } 249 | } 250 | 251 | }else{ 252 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 253 | } 254 | 255 | }catch(e){ 256 | alert(e); 257 | } 258 | -------------------------------------------------------------------------------- /plugins/Custom table style.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Custom table style ... 4 | //sHint=Custom CSS properties for the current table 5 | //sCategory=MainMenu.Table; 6 | //sPosition=TBL-03-ATTR-03 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT; TABLE 8 | //sID=p.Table.CustomStyle 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=wjjsoft 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Wjj Software. All rights Reserved. 16 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 17 | ///////////////////////////////////////////////////////////////////// 18 | // This code is property of Wjj Software (WJJSOFT). You may not use it 19 | // for any commercial purpose without preceding consent from authors. 20 | ///////////////////////////////////////////////////////////////////// 21 | 22 | //17:11 8/6/2015 Initial commit by wjj; 23 | //This plugin is intended for sophisticated (IT) users to edit CSS properties for the current table with in a fillable form. 24 | //For a full list of CSS properties, see: http://www.w3.org/TR/CSS21/propidx.html 25 | 26 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 27 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 28 | 29 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 30 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 31 | 32 | try{ 33 | var xNyf=new CNyfDb(-1); 34 | 35 | if(xNyf.isOpen()){ 36 | 37 | if(!xNyf.isReadonly()){ 38 | 39 | if(plugin.isContentEditable()){ 40 | 41 | var _unserialize_style=function(sCss){ 42 | var v2=sCss.split(';'), xCss={}; 43 | for(var i in v2){ 44 | var a=_trim(v2[i]||''); 45 | var p=a.indexOf(':'); 46 | if(p>0){ 47 | var key=_trim(a.substr(0, p)), val=_trim(a.substr(p+1)); 48 | if(key){ 49 | xCss[key]=val; 50 | } 51 | } 52 | } 53 | return xCss; 54 | }; 55 | 56 | var _add_prop=function(vCss, k, v){ 57 | if(vCss && vCss.length!=undefined && k){ 58 | var bFound=false; 59 | for(var i in vCss){ 60 | if(vCss[i].sKey==k){ 61 | vCss[i].sVal=v; 62 | bFound=true; 63 | } 64 | } 65 | if(!bFound) vCss.push({sKey: k, sVal: v}); 66 | } 67 | }; 68 | 69 | var vWidths=[ 70 | '|'+_lc('p.Common.Default', 'Default') 71 | , '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%' 72 | , '100%|'+'100% (Full)' 73 | , '10pt', '20pt', '30pt', '40pt', '50pt', '60pt', '70pt', '80pt', '90pt' 74 | , '100pt', '150pt', '200pt', '250pt', '300pt', '350pt', '400pt', '450pt' 75 | , '500pt', '550pt', '600pt', '650pt', '700pt', '750pt', '800pt', '850pt' 76 | , '900pt', '950pt', '1000pt' 77 | , '10px', '20px', '30px', '40px', '50px', '60px', '70px', '80px', '90px' 78 | , '100px', '150px', '200px', '250px', '300px', '350px', '400px', '450px' 79 | , '500px', '550px', '600px', '650px', '700px', '750px', '800px', '850px' 80 | , '900px', '950px', '1000px' 81 | ]; 82 | 83 | var sCode='var xTbl=curTable(); cssUtil(xTbl)||"";'; 84 | var sCss=plugin.runDomScript(-1, sCode)||''; 85 | 86 | var vFields=[], vCss=[]; 87 | 88 | var xCss=_unserialize_style(sCss); 89 | for(var k in xCss){ 90 | var v=k ? xCss[k] : ''; 91 | if(k && v){ 92 | var f={sField: 'lineedit', sLabel: k, sInit: v||'', bReq: false}; 93 | if(k=='width'){ 94 | f.sField='comboedit'; 95 | f.vItems=vWidths; 96 | }else if(k.indexOf('-color')>0){ 97 | f.sField='color'; 98 | } 99 | vFields.push(f); 100 | _add_prop(vCss, k, v); 101 | } 102 | } 103 | 104 | vFields.push({sField: 'lineedit', sLabel: _lc2('AddProp', '* Add CSS properties *'), sInit: '', bReq: false}); 105 | 106 | var vRes = input(plugin.getScriptTitle(), vFields, {nMinSize: 500, vMargins: [8, 0, 30, 0]}); 107 | if(vRes && vRes.length>1){ 108 | 109 | for(var i=0; i/g, '>'); 38 | s=s.replace(/\"/g, '"'); 39 | s=s.replace(/\'/g, '''); 40 | s=s.replace(/\xA0/g, ' '); //http://www.fileformat.info/info/unicode/char/a0/index.htm 41 | s=s.replace(/ /g, '  '); 42 | s=s.replace(/\t/g, '        '); //  43 | //and more ... 44 | return s; 45 | }; 46 | 47 | try{ 48 | var xNyf=new CNyfDb(-1); 49 | 50 | if(xNyf.isOpen()){ 51 | 52 | if(!xNyf.isReadonly()){ 53 | 54 | if(plugin.isContentEditable()){ 55 | 56 | var c_sFontSize='10pt'; 57 | var c_sFontName='Lucida Console, Courier New'; 58 | 59 | var _parse_fields=function(vLines, bNewFields){ 60 | var vFields=[]; 61 | for(var i in vLines||[]){ 62 | 63 | var sLine=_trim(vLines[i]); if(!sLine) continue; 64 | var p=sLine.indexOf('='); 65 | 66 | /* 67 | //Detect the colon ':' as a delimiter 68 | if(p<0){ 69 | //detect if it is a timestamp, e.g. Last-modified:02/01/2007 10:32 AM 70 | var p1=sLine.indexOf(':'); 71 | if(p1>0){ 72 | var p2=sLine.search(/\b\d{1,2}\:\d{1,2}/); 73 | if(p2>0){ 74 | if(p10){ 85 | var k=_trim(sLine.substring(0, p)); 86 | var v=_trim(sLine.substring(p+1)); 87 | if(k){ 88 | vFields.push({sKey: k, sVal: v, iPos: (bNewFields ? -1 : i)}); 89 | } 90 | }else if(p<0){ 91 | if(bNewFields){ 92 | var k=_trim(sLine); 93 | vFields.push({sKey: k, sVal: '', iPos: -1}); 94 | } 95 | } 96 | } 97 | return vFields; 98 | }; 99 | 100 | var nMaxKeyLen=0; 101 | var _update_field_lines=function(vLines, vFields){ 102 | 103 | for(var i in vFields){ 104 | var f=vFields[i]; 105 | if(nMaxKeyLen=0 && f.iPos'.replace(/%nWidth%/g, Math.round(nMaxKeyLen*4/5)) 126 | + _html_encode(s.sKey||'') 127 | + '' 128 | + '=' 129 | + '' 130 | + _html_encode(s.sVal||'') 131 | + '' 132 | + '' 133 | ; 134 | }else{ //if(typeof(s)=='string') 135 | if(s){ 136 | sHtml+='
' + _html_encode(s||'') + '
'; 137 | }else{ 138 | sHtml+='
' + '
' + '
'; 139 | } 140 | } 141 | } 142 | return sHtml; 143 | }; 144 | 145 | var sTxt=_trim(plugin.getSelectedText(-1, false)||''), bFullContent=false; 146 | if(!sTxt){ 147 | bFullContent=true; 148 | sTxt=_trim(plugin.getTextContent(-1, false)||''); 149 | } 150 | 151 | if(sTxt){ 152 | 153 | var vLines=sTxt.split('\n'); 154 | var v0=_parse_fields(vLines), vFields=[]; 155 | for(var i=0; i=0){ 161 | 162 | vFields.push({sField: "lineedit", sLabel: '* Add New Fields *', vItems: [], sInit: ''}); 163 | 164 | var vRes = input(plugin.getScriptTitle(), vFields, {nSpacing: 3, nMinSize: 650, vMargins: [2, 0, 20, 0], bAutoScroll: true}); 165 | if(vRes && vRes.length==v0.length+1){ 166 | 167 | for(var i=0; i' 180 | ; 181 | 182 | if(bFullContent){ 183 | plugin.selectAllText(-1); 184 | } 185 | 186 | plugin.replaceSelectedText(-1, sHtml, true); 187 | } 188 | }else{ 189 | alert('No text fields available.'); 190 | } 191 | 192 | }else{ 193 | alert(_lc('Prompt.Warn.NoTextSelected', 'No text content is currently selected.')); 194 | } 195 | 196 | }else{ 197 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 198 | } 199 | 200 | }else{ 201 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 202 | } 203 | 204 | }else{ 205 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 206 | } 207 | }catch(e){ 208 | alert(e); 209 | } 210 | -------------------------------------------------------------------------------- /plugins/Export records to CSV file.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Export records to CSV file ... 4 | //sHint=Export data records to a CSV file 5 | //sCategory=MainMenu.Export 6 | //sCondition=CURDB; CURINFOITEM; 7 | //sID=p.ExportCSV 8 | //sAppVerMin=7.0 9 | //sShortcutKey= 10 | //sAuthor=wjjsoft 11 | 12 | ///////////////////////////////////////////////////////////////////// 13 | // Extension scripts for myBase Desktop v7.x 14 | // Copyright 2015 Wjj Software. All rights Reserved. 15 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 16 | ///////////////////////////////////////////////////////////////////// 17 | // This code is property of Wjj Software (WJJSOFT). You may not use it 18 | // for any commercial purpose without preceding consent from authors. 19 | ///////////////////////////////////////////////////////////////////// 20 | 21 | //15:03 7/11/2015 Initial commit by peihao wang; 22 | //This plugin searches the database/branch for a list of specified data records [key=value] and save results in a .csv file; 23 | 24 | 25 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 26 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 27 | 28 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 29 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 30 | 31 | try{ 32 | var xNyf=new CNyfDb(-1); 33 | 34 | if(xNyf.isOpen()){ 35 | 36 | var sCfgKey1='ExportCSV.sFields', sCfgKey2='ExportCSV.sFnDst', sCfgKey3='ExportCSV.iRange', sCfgKey4='ExportCSV.iCharset'; 37 | 38 | var vRange=[ 39 | _lc('p.Common.CurBranch', 'Current branch') 40 | , _lc('p.Common.CurDB', 'Current database') 41 | ]; 42 | 43 | var vCharset=[ 44 | _lc('p.Common.Ansi', 'ANSI (Current system locale)') 45 | , _lc('p.Common.Utf8', 'UTF-8') 46 | ]; 47 | 48 | var vInputFields = [ 49 | {sField: 'lineedit', sLabel: _lc2('Fields', 'Enter field names (separated with comma)'), sInit: localStorage.getItem(sCfgKey1)||''} 50 | , {sField: 'savefile', sLabel: _lc2('File', 'Save as .csv file'), sTitle: plugin.getScriptTitle(), sFilter: 'Comma-Separated Values (*.csv);;All files(*.*)', sInit: localStorage.getItem(sCfgKey2)||''} 51 | , {sField: 'combolist', sLabel: _lc2('Range', 'Data range'), vItems: vRange, nInit: localStorage.getItem(sCfgKey3)||''} 52 | , {sField: 'combolist', sLabel: _lc2('Encoding', 'Character encoding'), vItems: vCharset, nInit: localStorage.getItem(sCfgKey4)||''} 53 | ]; 54 | 55 | var vResInput=input(plugin.getScriptTitle(), vInputFields, {nMinSize: 700, vMargins: [6, 0, 30, 0], bVert: true}); 56 | if(vResInput && vResInput.length==4){ 57 | 58 | var sKeys=vResInput[0]||'', sFnDst=vResInput[1]||'', iRange=vResInput[2], iCharset=vResInput[3]; 59 | var vKeys=[]; 60 | { 61 | var v=sKeys.replace(/\t/g, ',').replace(/;/g, ',').replace(/\|/g, ',').split(','); 62 | for(var i in v){ 63 | var k=_trim(v[i]); 64 | if(k){ 65 | vKeys.push(k); 66 | } 67 | } 68 | } 69 | 70 | if(sFnDst && sKeys && vKeys && vKeys.length>0){ 71 | 72 | localStorage.setItem(sCfgKey1, sKeys); 73 | localStorage.setItem(sCfgKey2, sFnDst); 74 | localStorage.setItem(sCfgKey3, iRange); 75 | localStorage.setItem(sCfgKey4, iCharset); 76 | 77 | var sCurItem = ( (iRange==0) ? plugin.getCurInfoItem() : plugin.getDefRootContainer()); 78 | var bUtf8 = (iCharset==1) ? true : false; 79 | 80 | if(sCurItem){ 81 | 82 | var _parse_fields=function(vLines, bNewFields){ 83 | var vFields=[]; 84 | for(var i in vLines||[]){ 85 | 86 | var sLine=_trim(vLines[i]); if(!sLine) continue; 87 | var p=sLine.indexOf('='); 88 | 89 | /* 90 | //Detect the colon ':' as a delimiter 91 | if(p<0){ 92 | //detect if it is a timestamp, e.g. Last-modified:02/01/2007 10:32 AM 93 | var p1=sLine.indexOf(':'); 94 | if(p1>0){ 95 | var p2=sLine.search(/\b\d{1,2}\:\d{1,2}/); 96 | if(p2>0){ 97 | if(p10){ 108 | var k=_trim(sLine.substring(0, p)); 109 | var v=_trim(sLine.substring(p+1)); 110 | if(k){ 111 | vFields.push({sKey: k, sVal: v, iPos: (bNewFields ? -1 : i)}); 112 | } 113 | }else if(p<0){ 114 | if(bNewFields){ 115 | var k=_trim(sLine); 116 | vFields.push({sKey: k, sVal: '', iPos: -1}); 117 | } 118 | } 119 | } 120 | return vFields; 121 | }; 122 | 123 | var vRecords = []; 124 | { 125 | 126 | //2015.6.11 make sure to first commit current changes in the html editor; 127 | if(plugin.isContentEditable()) plugin.commitCurrentChanges(); 128 | 129 | var _act_on_treeitem = function(sSsgPath, iLevel){ 130 | var xSsgFn = new CLocalFile(sSsgPath); xSsgFn.append(plugin.getDefNoteFn()); 131 | var sTxt = xNyf.loadText(''+xSsgFn); sTxt = platform.extractTextFromHtml(sTxt); 132 | var vLines=sTxt.split('\n'); 133 | var v0=_parse_fields(vLines, false); 134 | if(v0 && v0.length > 0) vRecords.push(v0); 135 | } 136 | xNyf.traverseOutline(sCurItem, true, _act_on_treeitem); 137 | } 138 | 139 | var _retrieve_values=function(vFields){ 140 | if(vFields && vFields.length>0){ 141 | var vRes=[], sVal='', bFound=false; 142 | for(var j in vKeys){ 143 | var sKey=vKeys[j]; 144 | if(sKey){ 145 | sVal=''; 146 | for(var i in vFields){ 147 | var f=vFields[i]; 148 | if(f && f.sKey.toLowerCase()==sKey.toLowerCase()){ 149 | sVal=f.sVal; 150 | break; 151 | } 152 | } 153 | if(sVal){ 154 | bFound=true; 155 | } 156 | vRes.push(sVal); 157 | } 158 | } 159 | if(bFound) return vRes; 160 | } 161 | }; 162 | 163 | if(vRecords && vRecords.length>0){ 164 | 165 | var _is_number=function(s){ 166 | return (s||'').search(/^\d+$|^\d+\.\d+$|^\d+\.\d+e[+-]?\d{1,5}$|^0x[0-9a-f]+$/i)>=0; 167 | }; 168 | 169 | var sCsv='', sCrlf='\n'; //platform.getOsType()=='Win32' ? '\r\n' : '\n'; 170 | for(var i in vRecords){ 171 | var v=_retrieve_values(vRecords[i]); 172 | if(v && v.length>0){ 173 | var sLine=''; 174 | for(var j in v){ 175 | var sVal=v[j]; 176 | if(sLine) sLine+=','; 177 | /*if(_is_number(sVal)){ 178 | sLine+=sVal; 179 | }else{ 180 | sLine+='"'+sVal+'"'; 181 | }*/ 182 | sLine+='"'+sVal.replace(/\"/g, '""')+'"'; 183 | } 184 | if(sCsv) sCsv+=sCrlf; 185 | sCsv+=sLine; 186 | } 187 | } 188 | 189 | var sHeader=''; 190 | for(var i in vKeys){ 191 | if(sHeader) sHeader+=','; 192 | sHeader+='"'+vKeys[i]+'"'; 193 | } 194 | 195 | sCsv=(sHeader+sCrlf+sCsv); 196 | if(sCsv){ 197 | var xFnDst = new CLocalFile(sFnDst); 198 | var nBytes=bUtf8 ? xFnDst.saveUtf8(sCsv) : xFnDst.saveAnsi(sCsv); 199 | if(nBytes>0){ 200 | if(confirm(_lc2('Done', 'Successfully exported the CSV file. View it now?')+'\n\n'+sFnDst)){ 201 | //xFnDst.exec(''); 202 | textbox({ 203 | sTitle: plugin.getScriptTitle() 204 | , sDescr: _lc2('Descr', 'Comma-Separated Values') 205 | , sDefTxt: xFnDst.loadText() 206 | , bReadonly: true 207 | , bWordwrap: false 208 | , nWidth: 90 209 | , nHeight: 80 210 | }); 211 | } 212 | }else{ 213 | alert(_lc2('Failure', 'Failed to export records to CSV file.')+'\n\n'+sFnDst); 214 | } 215 | } 216 | } 217 | } 218 | }else{ 219 | alert('Bad input of file path or field names'); 220 | } 221 | } 222 | }else{ 223 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 224 | } 225 | }catch(e){ 226 | alert(e); 227 | } 228 | -------------------------------------------------------------------------------- /plugins/Insert checkbox.js: -------------------------------------------------------------------------------- 1 | //sValidation=nyfjs 2 | //sCaption=Insert Checkbox 3 | //sHint=Insert checkbox at current HTML Content 4 | //sCategory=MainMenu.Insert 5 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT 6 | //sID=p.Ins.Checkbox 7 | //sAppVerMin=7.0 8 | //sShortcutKey= 9 | //sAuthor=jun4rui 10 | 11 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 12 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 13 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 14 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 15 | try{ 16 | var xNyf=new CNyfDb(-1); 17 | if(xNyf.isOpen()){ 18 | if(!xNyf.isReadonly()){ 19 | if(plugin.isContentEditable()){ 20 | var sTxt=" "; 21 | plugin.replaceSelectedText(-1, sTxt, true); 22 | }else{ 23 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 24 | } 25 | }else{ 26 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 27 | } 28 | }else{ 29 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 30 | } 31 | }catch(e){ 32 | alert(e); 33 | } 34 | -------------------------------------------------------------------------------- /plugins/Insert quick text.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Insert quick text ... 4 | //sHint=Insert quick text into current HTML content 5 | //sCategory=MainMenu.Insert 6 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT 7 | //sID=p.Ins.QuickText 8 | //sAppVerMin=7.0 9 | //sShortcutKey= 10 | //sAuthor=wjjsoft 11 | 12 | ///////////////////////////////////////////////////////////////////// 13 | // Extension scripts for myBase Desktop v7.x 14 | // Copyright 2015 Wjj Software. All rights Reserved. 15 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 16 | ///////////////////////////////////////////////////////////////////// 17 | // This code is property of Wjj Software (WJJSOFT). You may not use it 18 | // for any commercial purpose without preceding consent from authors. 19 | ///////////////////////////////////////////////////////////////////// 20 | 21 | 22 | //11:34 6/10/2015 23 | //Plugin/Insert quick text: 24 | //Quick text is customizable, simply save quick text as *.q.txt files in either the program's install folder, 25 | //or the script's folder './plugins', or the current database's folder, and or the special sub folder './quicktext' under the program's folder; 26 | 27 | //For end-users to define a keyboard shortcut to this function, select 'View - Options - Keyboard', 28 | //find the 'Quick text' item in the list, and then press a shortcut key on it. 29 | 30 | 31 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 32 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 33 | 34 | try{ 35 | var xNyf=new CNyfDb(-1); 36 | 37 | if(xNyf.isOpen()){ 38 | 39 | if(!xNyf.isReadonly()){ 40 | 41 | if(plugin.isContentEditable()){ 42 | 43 | var vDisp=[ 44 | '----------------------------------------' 45 | , '////////////////////////////////////////' 46 | , '########################################' 47 | ]; 48 | 49 | var nStart=vDisp.length; 50 | 51 | var sSuffix='.q.txt'; 52 | var xRE=new RegExp(sSuffix.replace(/\./g, '\\.')+'$', 'gi'); 53 | 54 | var vDirs=[]; 55 | { 56 | vDirs.push(plugin.getAppWorkingDir()); 57 | vDirs.push(plugin.getAppWorkingDir()+'/quicktext'); 58 | vDirs.push(new CLocalFile(plugin.getScriptFile()).getDirectory()); 59 | vDirs.push(new CLocalFile(xNyf.getDbFile()).getDirectory()); 60 | } 61 | 62 | var vFiles=[]; 63 | for(var j in vDirs){ 64 | var xDir=new CLocalDir(vDirs[j]); 65 | if(xDir.exists()){ 66 | var v=xDir.listFiles('*'+sSuffix); 67 | for(var i in v){ 68 | var xFn=new CLocalFile(xDir.toString()); xFn.append(v[i]); 69 | var sTitle=xFn.getLeafName().replace(xRE, '') + ' ('+xDir+')'; 70 | vDisp.push(sTitle); 71 | vFiles.push(xFn.toString()); 72 | } 73 | } 74 | } 75 | 76 | var sDir=new CLocalFile(plugin.getScriptFile()).getDirectory(); 77 | 78 | var sCfgKey='InsertQuickText.iSel'; 79 | var sMsg=_lc2('SelText', 'Select a quick text from the list (customizable by saving quick text as *.q.txt files in the program folder)'); 80 | var iSel=dropdown(sMsg, vDisp, localStorage.getItem(sCfgKey)); 81 | if(iSel>=0){ 82 | 83 | localStorage.setItem(sCfgKey, iSel); 84 | 85 | var sTxt; 86 | if(iSel0){ 40 | for(var i in vFiles){ 41 | var xFn=new CLocalFile(vFiles[i]); 42 | var sExt=(xFn.getSuffix(false)||'').toLowerCase(); 43 | if(sExt == 'md'){ 44 | sSsgFn=xFn.toString(); 45 | } 46 | } 47 | 48 | if(!sSsgFn){ 49 | 50 | //For non-MD attachments, a popup asking for confirmation would be safer; 51 | var sContinue = confirm('This is a non-MD attachment, Continue?'); 52 | switch (sContinue){ 53 | case true: 54 | sSsgFn=vFiles[0]; //consider the first one if no .md documents selected; 55 | } 56 | } 57 | 58 | if(sSsgFn){ 59 | sMD=xNyf.loadText(sSsgFn)||''; 60 | } 61 | }else{ 62 | sSsgFn=plugin.getCurDocFile(); 63 | sMD=plugin.getTextContent()||''; 64 | } 65 | } 66 | 67 | if(sSsgFn && sMD && sMD.replace(/^\s+|\s+$/g, '')){ 68 | 69 | //load marked.js 70 | var sCode; 71 | { 72 | var xFn=new CLocalFile(plugin.getScriptFile()); 73 | var sDir=xFn.getDirectory(); 74 | xFn=new CLocalFile(sDir, 'marked.js'); 75 | sCode=xFn.loadText(); 76 | } 77 | 78 | if(sCode){ 79 | 80 | eval.call(null, sCode); 81 | 82 | var sHtml = marked(sMD); 83 | 84 | if(sHtml){ 85 | 86 | if(plugin.isContentEditable()) plugin.commitCurrentChanges(); 87 | 88 | plugin.setTextContent(-1, sHtml, true, sSsgFn); 89 | 90 | //formats(table,code,blockquote) 91 | sCode='\n'+'var x = document.createElement("STYLE"); var t = document.createTextNode("body, table{font-family: Arial; font-size: 18pt}\\ntable {border-collapse:collapse;border:solid black;border-width:2px 0 2px 1px;}\\nth, td {border:solid black;border-width:2px 1px 1px 0;padding:1px;}\\nth {background-color:#DDD}\\ntable tr:nth-child(2n) {background-color: #f8f8f8;}\\nblockquote{border-left: 6px solid #DDD; color:#777}\\ncode {background-color:#EEE;border-radius: 3px; padding: 3px 5px 0px 5px;border: 1px solid #D6D6D6;color: #D14;}\\np{font-weight:normal}"); x.appendChild(t); document.head.appendChild(x);'; 92 | plugin.runDomScript(-1, sCode); 93 | 94 | plugin.setDomDirty(-1, false); 95 | plugin.setDomReadonly(-1, true); 96 | 97 | }else{ 98 | alert('No content available to render.'); 99 | } 100 | 101 | }else{ 102 | alert('Component script file missing.'+'\n\n'+'marked.js'); 103 | } 104 | }else{ 105 | alert('No markdown documents selected.'); 106 | } 107 | 108 | 109 | 110 | 111 | 112 | /* 113 | var f=new CLocalFile(plugin.getCurInfoItem()); 114 | var sRes=plugin.getSelectedAttachments('\t')||''; 115 | if(sRes){ 116 | var vLines=sRes.split('\n'); 117 | for(var i in vLines){ 118 | var v=(vLines[i]||'').split('\t'); 119 | var sDbPath=v[0], sSsgPath=v[1], sSsgName=v[2]; 120 | var xFn=new CLocalFile(sSsgPath); xFn.append(sSsgName); 121 | sFnSel=xFn.toString(); 122 | } 123 | }else{ 124 | var xFn=new CLocalFile(plugin.getCurDocFile()); 125 | sFnSel=xFn.toString(); 126 | } 127 | if(sFnSel){ 128 | var sRtf=xNyf.loadText(sFnSel,'utf-8'); 129 | } 130 | //load marked.js 131 | var sFile = plugin.getScriptFile(); 132 | var jsPath = sFile.substring(0,sFile.lastIndexOf('/')); 133 | var s=new CLocalFile(jsPath+"/marked.js"); 134 | var sJs=s.loadText(); 135 | eval.call(null, sJs); 136 | 137 | var html = marked(sRtf); 138 | plugin.setTextContent(-1, html, true); 139 | 140 | //formats(table,code,blockquote) 141 | var sCode='\n'+'var x = document.createElement("STYLE"); var t = document.createTextNode("body, table{font-family: Arial; font-size: 18pt}\\ntable {border-collapse:collapse;border:solid black;border-width:2px 0 2px 1px;}\\nth, td {border:solid black;border-width:2px 1px 1px 0;padding:1px;}\\nth {background-color:#DDD}\\ntable tr:nth-child(2n) {background-color: #f8f8f8;}\\nblockquote{border-left: 6px solid #DDD; color:#777}\\ncode {background-color:#EEE;border-radius: 3px; padding: 3px 5px 0px 5px;border: 1px solid #D6D6D6;color: #D14;}\\np{font-weight:normal}"); x.appendChild(t); document.head.appendChild(x);'; 142 | plugin.runDomScript(-1, sCode); 143 | plugin.setDomDirty(-1, true); 144 | */ 145 | 146 | }else{ 147 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 148 | } 149 | }catch(e){ 150 | alert(e); 151 | } 152 | 153 | -------------------------------------------------------------------------------- /plugins/Open folder location.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Open folder location 4 | //sHint=Open folder location for the current shortcut 5 | //sCategory=MainMenu.Attachments; Context.Attachments 6 | //sCondition=CURDB; DBRW; OUTLINE; CURINFOITEM 7 | //sID=p.OpenFolderLocation 8 | //sAppVerMin=7.0 9 | //sShortcutKey= 10 | //sAuthor=wjjsoft 11 | 12 | ///////////////////////////////////////////////////////////////////// 13 | // Extension scripts for myBase Desktop v7.x 14 | // Copyright 2015 Wjj Software. All rights Reserved. 15 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 16 | ///////////////////////////////////////////////////////////////////// 17 | // This code is property of Wjj Software (WJJSOFT). You may not use it 18 | // for any commercial purpose without preceding consent from authors. 19 | ///////////////////////////////////////////////////////////////////// 20 | 21 | //17:44 9/18/2015 initial commit by wjj; 22 | //This plugin tries to open the folder location where the current shortcut file resides; 23 | //Usage: right-click on a 'shortcut' within the attachment pane, then select 'Open folder location' menu item; 24 | 25 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 26 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 27 | 28 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 29 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 30 | 31 | try{ 32 | 33 | var xNyf=new CNyfDb(-1); 34 | if(xNyf.isOpen()){ 35 | 36 | var _srcfn_of_shortcut=function(sSsgFn){ 37 | var sSrcFn='', sTxt=xNyf.loadText(sSsgFn)||''; 38 | var vLines=sTxt.split('\n'); 39 | for(var i in vLines){ 40 | var sLine=_trim(vLines[i]), sTag='url=file://'; 41 | if(sLine.toLowerCase().indexOf(sTag)==0){ 42 | var sSrc=sLine.substr(sTag.length); 43 | if(sSrc){ 44 | sSrcFn=sSrc; 45 | break; 46 | } 47 | } 48 | } 49 | return sSrcFn; 50 | }; 51 | 52 | var bFullPath=true, nLinks=0; 53 | var vFiles=plugin.getSelectedAttachments(-1, bFullPath); 54 | if(vFiles && vFiles.length>0){ 55 | for(var i in vFiles){ 56 | var sSsgFn=vFiles[i]; 57 | if(xNyf.isShortcut(sSsgFn)){ 58 | nLinks++; 59 | var sFn=_srcfn_of_shortcut(sSsgFn).replace(/^([\/\\]+)(?=[a-z]\:.+)/i, ''); 60 | if(sFn){ 61 | if(sFn[0]=='.'){ 62 | var sDirNyf=new CLocalFile(xNyf.getDbFile()).getDirectory(); 63 | sFn=new CLocalFile(sDirNyf, sFn).toString(); 64 | } 65 | var sDir=new CLocalFile(sFn).getDirectory(); 66 | if(sDir){ 67 | if(new CLocalDir(sDir).exists()){ 68 | new CLocalFile(sDir).launch(); //2015.9.18 may not work on Mac ??????????????? 69 | break; 70 | }else{ 71 | alert(_lc('Prompt.Failure.DirNotExisting', 'Directory does not exist.')+'\n\n'+sDir); 72 | } 73 | } 74 | } 75 | } 76 | } 77 | } 78 | 79 | if(nLinks<=0){ 80 | alert(_lc2('NoShortcutSel', 'No shortcut entry is currently selected.')); 81 | } 82 | 83 | }else{ 84 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 85 | } 86 | 87 | }catch(e){ 88 | alert(e); 89 | } 90 | -------------------------------------------------------------------------------- /plugins/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | This folder contains the plugins for myBase 7.x. 4 | 5 | **Usage:** 6 | 1. Closed the software 7 | 2. Copy the plugin .js file to .\plugins sub folder. 8 | 3. Run the software again. 9 | 4. Based on the setting of the plugins, you can find the new functions from different menus. 10 | 5. More details can be found in myBase website: [http://www.wjjsoft.com/mybase_jsapi.html#install](http://www.wjjsoft.com/mybase_jsapi.html#install) 11 | 12 | # Plugins Provided by WJJ 13 | ## 1. Syntax highlight.js ## 14 | The main contributor of this plugin is WJJ. This plugin supports Syntax highlight for C/C++, C/C++ with STL, Java, C#, Javascript, T-SQL, PHP, Google GO, GNU/R Language and Visual Basic, Perl, ActionScript, Delphi, Pascal, Python, BASH, Ruby, Objective-C, Swift... 15 | 16 | This function can be accessed by selecting the content and right click menu "Syntax highlight...". 17 | 18 | ## 2. Insert quick text.js ## 19 | This plugin is provided by WJJ. You can use this plug to add pre-defined text to the HTML edit area. The pre-defined text file (txt file) can be saved under program's install folder, or the script's folder './plugins', or the current database's folder, and or the special sub folder './quicktext' under the program's folder. The file naming format should follow *.q.txt. You can access to this function from right click menu -> Insert -> Insert quick text ... 20 | 21 | ## 3. Edit with fillable form.js ## 22 | This plugin can be used to insert and modify a list of fields [key=value] within a fillable form. You can access this function via right click menu "Edit with fillable form ...". When creating multiple 'New fields', you can use ; or , or | as separators. 23 | 24 | ## 4. Recover database.js 25 | This plugin simply invokes the ssg5recover command-line tool to recover corrupted .nyf databases. The required ssg5recover tool is included within the SSG5 command-line package, and can be downloaded from the website: [http://wjjsoft.com/tid_ssg#recover](http://wjjsoft.com/tid_ssg#recover). 26 | 27 | ## 5. Custom table style.js 28 | This plugin enables professional users manipulating the table style via CSS properties, the available CSS properties could be found [http://www.w3.org/TR/CSS21/propidx.html](http://www.w3.org/TR/CSS21/propidx.html) 29 | 30 | ## 6. Open folder location.js 31 | This plugin can be used to open the folder location where the current shortcut file resides. You can access to this function via right-click on a 'shortcut' within the attachment pane, then select 'Open folder location' menu item. 32 | 33 | ## 7. Custom page margin.js 34 | This plugin is used to set margin-left/right for element of the current HTML content. 35 | 36 | ## 8. custom search scope.js 37 | This plugin is used to run searches for words or RegExp with in a specified scope. 38 | 39 | ## 9. Export records to CSV file.js 40 | This plugin is created by peihaowang. It can be used to search the database/branch for a list of specified data records [key=value] and save results in a .csv file. 41 | 42 | # Self-developed Plugins (**Unofficial Plugin**) 43 | >All the **Self-developed Plugins** follow [The MIT License (MIT)](http://opensource.org/licenses/MIT "MIT License") schema. 44 | > 45 | > **Note:** 46 | > - These plugins are self-developed plugins. 47 | > - Use these plugins **at your own risks**. 48 | > - Please **fully test** before using to your productive data file. 49 | > - Please raise a issue if you have any problems using these plugins. 50 | > - These plugins are tested in win7 64bit system, and myBase 7.0 beta 22 only. If you want to use in MacOS or Linux environment, please fully test. 51 | 52 | ## 1. SetFontSize.js 53 | This plugin can be used to set the font size of current info item. 54 | Please note, this plugin will change all the font size of the current info item and **do not have a reverse function**, meaning you **can not use** `crtl+z` to reverse back, but you can use "Revision History" to reverse back to the previous version. Currently, the font size can be set between 5-40pt. You can find this function (**Set Font Size**) by right click in the HTML edit area. 55 | 56 | ## 2. Markdown related plugins 57 | > **Note:** Official myBase 7.x already supports view Markdown file attachment directly and edit .md file. 58 | > 59 | > **Dependency:** The below two markdown related plugins use the interface provided by **marked.js**. To run these two plugins, you need first to download the **marked.js** from the project page: [https://github.com/chjj/marked](https://github.com/chjj/marked) and put to myBase \plugins folder. 60 | 61 | ### 2.1 Markdown2html.js 62 | This Plugin can change the markdown syntax contents in info item to HTML. You can access to this function by selecting the contents and by right click menu -> Text Utilities -> mdText2html 63 | 64 | ### 2.2 Markdownattach.js 65 | This Plugin can display the .md attachment in the HTML info item. You can access to this function by right click the .md attachment menu -> .mdatt2InfoItem. 66 | 67 | ## 3. WordCount.js 68 | This plugin can be used to calculate the word count of the selected contents of the info item. You can access to this function by selecting the content and via right click menu -> Text Utilities -> Word Count. 69 | 70 | ## 4. Calculate.js 71 | > **Dependency:** This plugin uses the interface provided by **math.js**. To run this plugin, you need first to download the **math.js** from the project page: [https://github.com/josdejong/mathjs](https://github.com/josdejong/mathjs) and put to myBase \plugins folder together with Calculate.js. 72 | 73 | To access this function, you can highlight any math expression from the info item area and right click menu -> Text Utilities -> Calculate. 74 | 75 | **Example math expression:** `cos(20.9 deg) * 0.9342 / (3+9) * (2.3+5.87) / 11` 76 | 77 | ## 5. Save2QuickText.js 78 | This plugin can be used to save selected text to Quick text (*.q.txt) file and normal text (txt) file. You can access to this function by selecting the content and via right click menu -> Text Utilities -> Save to Quick Text. 79 | 80 | ## 6. SetBackgroundColor.js 81 | This plugin can be used to set the background color of the infoItem. 82 | 83 | ## 7. SetBackgroundImg.js 84 | This plugin can be used to set the background image of the infoItem. (**Need to put the desired image file in the attachment of info item first**) 85 | -------------------------------------------------------------------------------- /plugins/Recover database.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Recover database ... 4 | //sHint=Run the ssg5recover tool to recover corrupted .nyf databases 5 | //sCategory=MainMenu.Maintain 6 | //sPosition= 7 | //sCondition= 8 | //sID=p.ssg5recover 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=wjjsoft 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Wjj Software. All rights Reserved. 16 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 17 | ///////////////////////////////////////////////////////////////////// 18 | // This code is property of Wjj Software (WJJSOFT). You may not use it 19 | // for any commercial purpose without preceding consent from authors. 20 | ///////////////////////////////////////////////////////////////////// 21 | 22 | //21:01 7/12/2015 Initial commit by wjj; 23 | //This plugin simply invokes the ssg5recover command-line tool to recover corrupted .nyf databases; 24 | //The ssg5recover tool is included within the SSG5 command-line package, and can be downloaded from the website: http://wjjsoft.com/tid_ssg#recover 25 | 26 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 27 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 28 | 29 | try{ 30 | 31 | var sCfgKey1='ssg5recover.sFnExe', sCfgKey2='ssg5recover.sFnNyf'; 32 | var sFnExe=(platform.getOsType()=='Win32') ? 'ssg5recover.exe' : 'ssg5recover'; 33 | 34 | var sDescrExe=_lc2('FnExe', 'File path to %Ssg5Recover% (Downloadable from: http://wjjsoft.com/tid_ssg)').replace(/%Ssg5Recover%/g, sFnExe); 35 | var sDescrNyf=_lc2('FnNyf', 'File path to a corrupted .nyf database'); 36 | var sFilter='myBase databases (*.nyf);;All files(*.*)'; 37 | 38 | var vFields = [ 39 | {sField: 'file', sLabel: sDescrExe, sFilter: sFnExe, sTitle: plugin.getScriptTitle(), sInit: localStorage.getItem(sCfgKey1)||''} 40 | , {sField: 'file', sLabel: sDescrNyf, sTitle: plugin.getScriptTitle(), sFilter: sFilter, sInit: localStorage.getItem(sCfgKey2)||''} 41 | ]; 42 | 43 | var vRes=input(plugin.getScriptTitle(), vFields, {nMinSize: 560, vMargins: [6, 0, 30, 0], bVert: true}); 44 | if(vRes && vRes.length==2){ 45 | 46 | var sFnExe=vRes[0], sFnNyf=vRes[1]; 47 | if(sFnExe && sFnNyf){ 48 | 49 | localStorage.setItem(sCfgKey1, sFnExe); 50 | localStorage.setItem(sCfgKey2, sFnNyf); 51 | 52 | var xFnExe=new CLocalFile(sFnExe), xFnNyf=new CLocalFile(sFnNyf); 53 | if(xFnExe.exists() && xFnNyf.exists()){ 54 | if(xFnExe.exec([sFnNyf])){ 55 | var sPath=xFnNyf.getDirectory(false), sTitle=xFnNyf.getTitle(), sExt=xFnNyf.getSuffix(true); 56 | var xFnNew=new CLocalFile(sPath, sTitle+'_RECOVERED'+sExt); 57 | var sMsg=_lc2('Done', 'Successfully invoked the ssg5recover tool; During the process in Terminal, you may be asked for confirmation or database password if needed; And the new storage file will be generated if all goes OK. Please be patient...'); 58 | alert(sMsg+'\n\n'+xFnExe+'\n'+xFnNyf+'\n\n=> '+xFnNew); 59 | }else{ 60 | alert('Failed to invoke the ssg5recover tool.'+'\n\n'+xFnExe); 61 | } 62 | }else{ 63 | alert('File not found.'+'\n\n'+xFnExe+'\n'+xFnNyf); 64 | } 65 | 66 | }else{ 67 | alert('Bad input of file paths.'); 68 | } 69 | } 70 | 71 | }catch(e){ 72 | alert(e); 73 | } 74 | -------------------------------------------------------------------------------- /plugins/Save2QuickText.js: -------------------------------------------------------------------------------- 1 |  2 | //sValidation=nyfjs 3 | //sCaption=Save to Quick Text 4 | //sHint=Save selected Text to Quick Text 16062015 5 | //sCategory=MainMenu.TxtUtils 6 | //sPosition=XZ-255 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT; HTMLSELECTED 8 | //sID=p.gzhaha.SaveText2QuickTextFile 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=Xia Zhang 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Xia Zhang (MIT Licensed) 16 | ///////////////////////////////////////////////////////////////////// 17 | 18 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 19 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 20 | 21 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 22 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 23 | 24 | try{ 25 | var xNyf=new CNyfDb(-1); 26 | if(xNyf.isOpen()){ 27 | if(!xNyf.isReadonly()){ 28 | if(plugin.isContentEditable()){ 29 | //get selected text from info item edit area 30 | var sCon = plugin.getSelectedText(-1, false); 31 | 32 | try{ 33 | var sFn=platform.getSaveFileName({sTitle: 'Select Quick Text File', sFilter: 'Quick Text files(*.q.txt);;Text files(*.txt)'}); 34 | var f=new CLocalFile(sFn); 35 | var nBytes=f.saveUtf8(sCon); 36 | if(nBytes>=0){ 37 | alert('Saved Successfully!'); 38 | } 39 | } 40 | catch(e){ 41 | alert(e); 42 | } 43 | }else{ 44 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 45 | } 46 | }else{ 47 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 48 | } 49 | }else{ 50 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 51 | } 52 | }catch(e){ 53 | alert(e); 54 | } 55 | -------------------------------------------------------------------------------- /plugins/SetBackgroundColor.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Set Background Color 4 | //sHint=Set Font Background Color 08082015 5 | //sCategory=Context.HtmlEdit 6 | //sPosition=XZ-255 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT 8 | //sID=p.gzhaha.SetFontSize 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=Xia Zhang 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Xia Zhang (MIT Licensed) 16 | ///////////////////////////////////////////////////////////////////// 17 | 18 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 19 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 20 | 21 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 22 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 23 | 24 | try{ 25 | var xNyf=new CNyfDb(-1); 26 | if(xNyf.isOpen()){ 27 | if(!xNyf.isReadonly()){ 28 | if(plugin.isContentEditable()){ 29 | var sCfgKey='gzhaha.SetBGColor'; 30 | var vFields = [ 31 | {sField: "color", sLabel: 'Color: ', sInit: localStorage.getItem(sCfgKey)|| '#999999'} 32 | ]; 33 | var vRes=input(plugin.getScriptTitle(), vFields, {nMinSize: 400, nSpacing: 10, bVerticalLayout: false}); 34 | 35 | if(vRes && vRes.length === 1){ 36 | //get text 37 | var sCon = plugin.getTextContent(-1, true); 38 | uColor = vRes[0] 39 | localStorage.setItem(sCfgKey, uColor); 40 | var regx = //; 41 | var html = sCon.replace(regx, ''); 42 | 43 | plugin.commitCurrentChanges(); 44 | plugin.setTextContent(-1, html, true); 45 | plugin.setDomDirty(-1, true); 46 | } 47 | 48 | }else{ 49 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 50 | } 51 | }else{ 52 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 53 | } 54 | }else{ 55 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 56 | } 57 | }catch(e){ 58 | alert(e); 59 | } 60 | -------------------------------------------------------------------------------- /plugins/SetBackgroundImg.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Set Background Image 4 | //sHint=Set Font Background Image 30042016 5 | //sCategory=Context.HtmlEdit 6 | //sPosition=XZ-255 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT 8 | //sID=p.gzhaha.SetBgImg 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=Xia Zhang 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Xia Zhang (MIT Licensed) 16 | ///////////////////////////////////////////////////////////////////// 17 | 18 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 19 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 20 | 21 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 22 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 23 | 24 | try{ 25 | var xNyf=new CNyfDb(-1); 26 | if(xNyf.isOpen()){ 27 | if(!xNyf.isReadonly()){ 28 | if(plugin.isContentEditable()){ 29 | 30 | var sTxt=prompt('Background Img name:', '', 'Enter Background Img name'); 31 | 32 | if (sTxt){ 33 | var sCon = plugin.getTextContent(-1, true); 34 | var regx = //; 35 | var html = sCon.replace(regx, ''); 36 | 37 | plugin.setTextContent(-1, html, true); 38 | plugin.setDomDirty(-1, true); 39 | plugin.commitCurrentChanges(-1); 40 | } 41 | else{ 42 | alert("Please Provide Background Img name!"); 43 | } 44 | 45 | }else{ 46 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 47 | } 48 | }else{ 49 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 50 | } 51 | }else{ 52 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 53 | } 54 | }catch(e){ 55 | alert(e); 56 | } 57 | -------------------------------------------------------------------------------- /plugins/SetFontSize.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Set Font Size 4 | //sHint=Set Font Size 09072015 5 | //sCategory=Context.HtmlEdit 6 | //sPosition=XZ-255 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT 8 | //sID=p.gzhaha.SetFontSize 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=Xia Zhang 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Xia Zhang (MIT Licensed) 16 | ///////////////////////////////////////////////////////////////////// 17 | 18 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 19 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 20 | 21 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 22 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 23 | 24 | try{ 25 | var xNyf=new CNyfDb(-1); 26 | if(xNyf.isOpen()){ 27 | if(!xNyf.isReadonly()){ 28 | if(plugin.isContentEditable()){ 29 | var sCfgKey='gzhaha.SetFontSize'; 30 | 31 | //get text 32 | var sCon = plugin.getTextContent(-1, true); 33 | var sSiz = prompt('Input Font Size (5-40):', localStorage.getItem(sCfgKey)||'16', 'Input Font Size'); 34 | if (sSiz){ 35 | if (sSiz>=5 && sSiz<=40){ 36 | //save to ini file 37 | localStorage.setItem(sCfgKey, sSiz); 38 | 39 | //match px, pt, % 40 | var regx = /font-size:( |)\d{1,2}(|\.\d+)(| )pt|font-size:( |)\d{1,2}(|\.\d+)(| )px|font-size:( |)\d{1,3}(| )%/g; 41 | var html = sCon.replace(regx, 'font-size: '+ sSiz + 'pt'); 42 | 43 | //2015.6.12 'setHTML' clears DOM entirely including UNDO stack, so it'd be worth to first save current modifications as a history revision for UNDOable; 44 | plugin.commitCurrentChanges(); 45 | 46 | plugin.setTextContent(-1, html, true); 47 | plugin.setDomDirty(-1, true); 48 | } 49 | else{ 50 | alert("Font Size should be 5-40!"); 51 | } 52 | } 53 | }else{ 54 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 55 | } 56 | }else{ 57 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 58 | } 59 | }else{ 60 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 61 | } 62 | }catch(e){ 63 | alert(e); 64 | } 65 | -------------------------------------------------------------------------------- /plugins/Syntax highlight.js: -------------------------------------------------------------------------------- 1 | 2 | //sValidation=nyfjs 3 | //sCaption=Syntax highlight ... 4 | //sHint=Syntax highlight the whole or selected source code 5 | //sCategory=MainMenu.Edit; Context.HtmlEdit 6 | //sPosition= 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT; 8 | //sID=p.SyntaxHighlight 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=wjjsoft 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Wjj Software. All rights Reserved. 16 | // Website: www.wjjsoft.com Contact: info@wjjsoft.com 17 | ///////////////////////////////////////////////////////////////////// 18 | // This code is property of Wjj Software (WJJSOFT). You may not use it 19 | // for any commercial purpose without preceding consent from authors. 20 | ///////////////////////////////////////////////////////////////////// 21 | 22 | 23 | //2015.6.6 initial commit by wjj; 24 | //C/C++-like source code supported, such as C/C++, JS, PHP, Java, C#, etc. 25 | 26 | //2015.6.6 by gzhaha 27 | //added Python, Perl 28 | 29 | //2015.6.7 by gzhaha 30 | //updated R, added ActionScript, Ruby 31 | //efforts on dealing with # symbol within quotation marks: '...#...' or "...#..." 32 | 33 | //12:31 6/7/2015 34 | //efforts on dealing with if any html-tags (e.g.
, ) in source code
  35 | 
  36 | //17:47 6/7/2015
  37 | //bugfix with < > operators in source code
  38 | 
  39 | //2015.6.8 by gzhaha
  40 | //added Delphi, Pig Latin, Bash
  41 | 
  42 | //11:41 6/9/2015
  43 | //added Cpp/Qt
  44 | //deal with HTML entities in source code ( , &,  ,   ...)
  45 | 
  46 | //12:24 6/10/2015
  47 | //removed the 'HTMLSELECTED' requirement, so it can handle all content in HTML editor without having to first select all lines;
  48 | 
  49 | //2015.6.11 by gzhaha
  50 | //add js+myBase
  51 | 
  52 | //2015.6.12 by gzhaha
  53 | //add: substitute for $ character, the issue is related to parse '$' in source code
  54 | //add: substitute for the \ character, the issue is related to parse \\ in source code.
  55 | 
  56 | //2015.6.14 by gzhaha
  57 | //add: Pascal
  58 | 
  59 | //2015.6.15 by gzhaha
  60 | //add: support multi sets of symbols for block comment.
  61 | 
  62 | //16:46 6/15/2015
  63 | //updates: added the data structure {start: '', end: ''} to store pairs of block-level remark tags;
  64 | 
  65 | //18:28 6/16/2015
  66 | //support of objc & RegExp for reversed tags;
  67 | 
  68 | //12:00 6/18/2015
  69 | //added Apple Swift;
  70 | 
  71 | //17:34 6/29/2015
  72 | //custom font-family/size for 
;
  73 | 
  74 | //17:25 8/17/2015
  75 | //bugfix: The '<' operator not working in remark blocks;
  76 | //added a safe method to generate the special tags for '<>&...', in case that they could appear in source code, e.g. the script itself;
  77 | 
  78 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);};
  79 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);};
  80 | 
  81 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');};
  82 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');};
  83 | 
  84 | try{
  85 | 	var xNyf=new CNyfDb(-1);
  86 | 
  87 | 	if(xNyf.isOpen()){
  88 | 
  89 | 		if(!xNyf.isReadonly() && plugin.isContentEditable()){
  90 | 
  91 | 			var c_sFontSize='10pt';
  92 | 			var c_sFontName='Lucida Console, Courier New';
  93 | 
  94 | 			var c_sColorNormal='#000000';
  95 | 			var c_sColorRemarks='#008000';
  96 | 			var c_sColorStrings='#800080';
  97 | 			var c_sColorNumbers='#ff0000';
  98 | 
  99 | 			var c_sColorKeywords='#0000ff';
 100 | 
 101 | 			var c_sColorReservedTags1='#8000ff';
 102 | 			var c_sColorReservedTags2='#004080';
 103 | 			var c_sColorReservedTags3='#ff8000';
 104 | 			var c_sColorReservedTags4='#0080c0';
 105 | 			var c_sColorReservedTags5='#ff007f';
 106 | 			var c_sColorReservedTags6='#ff5500';
 107 | 			var c_sColorReservedTags7='#ff557f';
 108 | 
 109 | 			var sTags_Cpp=
 110 | 				//for C++ Macros
 111 | 				'include,defined,define,ifdef,endif,elif,pragma,null'
 112 | 
 113 | 				//for C (ISO/ANSI C90)
 114 | 				+ ',auto,break,case,char,const,continue,default,do,double,else,enum,extern'
 115 | 				+ ',float,for,goto,if,inline,int,long,register,restrict,return'
 116 | 				+ ',short,signed,sizeof,static,struct,switch,typedef'
 117 | 				+ ',union,unsigned,void,volatile,while'
 118 | 
 119 | 				//for C (ISO/ANSI C99 appendix)
 120 | 				+ ',_Bool,_Complex,_Imaginary'
 121 | 
 122 | 				//for C++
 123 | 				+ ',and,and_eq,asm,bitand,bitor,bool,catch,class,compl'
 124 | 				+ ',const_cast,delete,dynamic_cast,explicit,export,false,friend'
 125 | 				+ ',mutable,namespace,new,not,not_eq,operator,or,or_eq'
 126 | 				+ ',private,protected,public,reinterpret_cast,static_cast'
 127 | 				+ ',template,this,throw,true,try,typeid,typename,using'
 128 | 				+ ',wchar_t,virtual,xor,xor_eq'
 129 | 
 130 | 				//for C++0x
 131 | 				+ ',alignof,char16_t,char32_t,constexpr,decltype,noexcept,nullptr'
 132 | 				+ ',static_assert,thread_local'
 133 | 				;
 134 | 
 135 | 			var sTags_Stl=
 136 | 				'std,exception'
 137 | 				+ ',string,list,vector,stack,pair,map,set,multimap,multiset,queue,deque'
 138 | 				+ ',priority_queue,bitset,valarray'
 139 | 				+ ',cin,cout,cerr,clog,wcin,wcout,wcerr,wclog'
 140 | 				+ ',ios,fstream,wfstream,ifstream,wifstream,ofstream,wofstream'
 141 | 				+ ',istream,wistream,ostream,wostream,streambuf,wstreambuf'
 142 | 				+ ',stringstream,wstringstream,istringstream,wistringstream,ostringstream,wostringstream'
 143 | 				+ ',strstream,istrstream,wistrstream,ostrstream,wostrstream'
 144 | 				+ ',iterator,const_iterator,reverse_iterator,const_reverse_iterator'
 145 | 				+ ',back_insert_iterator,front_insert_iterator,insert_iterator'
 146 | 				+ ',istream_iterator,ostream_iterator,istreambuf_iterator,ostreambuf_iterator'
 147 | 				;
 148 | 
 149 | 			var sTags_Qt=
 150 | 				+ 'qint8|qint16|qint32|qint64|qlonglong|qptrdiff|qreal|quint8|quint16|quint32|quint64|quintptr|qulonglong|uchar|uint|ulong|ushort'
 151 | 				+ '|QT_\\w\+|Q_\\w\+' //global Macros
 152 | 				+ '|q[A-Z]\\w\+|qgetenv|qputenv|qrand|qsrand|qtTrId' //gloabl Functions
 153 | 				+ '|Q\\w\+' //Qt widgets/classes
 154 | 				;
 155 | 
 156 | 			var sTags_Java=
 157 | 				'abstract,boolean,break,byte,case,catch,char,class,continue,default'
 158 | 				+ ',do,double,else,enum,extends,false,final,finally,float,for'
 159 | 				+ ',if,implements,import,instanceof,int,interface,long,native,new,null'
 160 | 				+ ',package,private,protected,public,return,short,static,strictfp,super,switch'
 161 | 				+ ',synchronized,this,throw,throws,transient,true,try,void,volatile,while'
 162 | 				+ ',const,goto'
 163 | 				;
 164 | 
 165 | 			var sTags_CSharp=
 166 | 				'abstract,event,new,struct,as,explicit,null,switch,base,extern,object,this'
 167 | 				+ ',bool,false,operator,throw,break,finally,out,true,byte,fixed,override,try'
 168 | 				+ ',case,float,params,typeof,catch,for,private,uint,char,foreach,protected,ulong'
 169 | 				+ ',class,if,readonly,unsafe,const,implicit,ref,ushort,continue,in,return,using'
 170 | 				+ ',decimal,int,sbyte,virtual,default,interface,sealed,volatile,delegate,internal,short,void'
 171 | 				+ ',do,is,sizeof,while,double,lock,stackalloc,else,long,static,enum,namespace,string'
 172 | 				;
 173 | 
 174 | 			var sTags_JS=
 175 | 				//js keywords
 176 | 				'break,case,catch,continue,default,delete,do,else,finally,for,function'
 177 | 				+ ',if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with'
 178 | 
 179 | 				//js reserved
 180 | 				+ ',abstract,boolean,byte,char,class,const,debugger,double,enum,export'
 181 | 				+ ',extends,final,float,goto,implements,import,int,interface,long,native'
 182 | 				+ ',package,private,protected,public,short,static,super,synchronized'
 183 | 				+ ',throws,transient,volatile'
 184 | 
 185 | 				//js classes
 186 | 				+ ',Array,Boolean,Date,Math,Number,String,RegExp,Functions,Events'
 187 | 				;
 188 | 
 189 | 			var sTags_JSConst=
 190 | 				//JS window constants
 191 | 				'null,undefined,NaN,E,PI,SQRT2,SQRT1_2,LN2,LN10,LOG2E,LOG10E'
 192 | 
 193 | 			var sTags_JSDom=
 194 | 				//JS DOM objects
 195 | 				'window,self,document,navigator,screen,history,location,alert,confirm,prompt,Infinity,java,Packages'
 196 | 
 197 | 			var sTags_JSEvent=
 198 | 				//JS DOM events
 199 | 				'onabort,onblur,onchange,onclick,ondblclick,onerror,onfocus,onkeydown,onkeypress,onkeyup,onload'
 200 | 				+ ',onmousedown,onmousemove,onmouseout,onmouseover,onmouseup,onreset,onresize,onselect,onsubmit,onunload'
 201 | 
 202 | 			var sTags_HTML=
 203 | 				'!DOCTYPE,a,abbr,acronym,address,applet,area,b,base,basefont,bdo,big'
 204 | 				+ ',blockquote,body,br,button,caption,center,cite,code,col,colgroup,dd,del'
 205 | 				+ ',dir,div,dfn,dl,em,fieldset,font,form,frame,frameset,h1,h2,h3,h4,h5,h6,h7,h8'
 206 | 				+ ',head,hr,html,i,iframe,img,input,ins,isindex,kbd,label,legend,li,link,map'
 207 | 				+ ',menu,meta,noframes,noscript,object,ol,optgroup,option,p,param,pre,q,s'
 208 | 				+ ',samp,script,select,small,span,strike,strong,style,sub,sup,table,tbody'
 209 | 				+ ',td,textarea,tfoot,th,thead,title,tr,tt,u,ul,var,xmp'
 210 | 				;
 211 | 
 212 | 			var sTags_Sql=
 213 | 				'add,exit,primary'
 214 | 				+ ',all,fetch,print'
 215 | 				+ ',alter,file,privileges'
 216 | 				+ ',and,fillfactor,proc'
 217 | 				+ ',any,floppy,procedure'
 218 | 				+ ',as,for,processexit'
 219 | 				+ ',asc,foreign,public'
 220 | 				+ ',authorization,freetext,raiserror'
 221 | 				+ ',avg,freetexttable,read'
 222 | 				+ ',backup,from,readtext'
 223 | 				+ ',begin,full,reconfigure'
 224 | 				+ ',between,goto,references'
 225 | 				+ ',break,grant,repeatable'
 226 | 				+ ',browse,group,replication'
 227 | 				+ ',bulk,having,restore'
 228 | 				+ ',by,holdlock,restrict'
 229 | 				+ ',cascade,identity,return'
 230 | 				+ ',case,identity_insert,revoke'
 231 | 				+ ',check,identitycol,right'
 232 | 				+ ',checkpoint,if,rollback'
 233 | 				+ ',close,in,rowcount'
 234 | 				+ ',clustered,index,rowguidcol'
 235 | 				+ ',coalesce,inner,rule'
 236 | 				+ ',column,insert,save'
 237 | 				+ ',commit,intersect,schema'
 238 | 				+ ',committed,into,select'
 239 | 				+ ',compute,is,serializable'
 240 | 				+ ',confirm,isolation,session_user'
 241 | 				+ ',constraint,join,set'
 242 | 				+ ',contains,key,setuser'
 243 | 				+ ',containstable,kill,shutdown'
 244 | 				+ ',continue,left,some'
 245 | 				+ ',controlrow,level,statistics'
 246 | 				+ ',convert,like,sum'
 247 | 				+ ',count,lineno,system_user'
 248 | 				+ ',create,load,table'
 249 | 				+ ',cross,max,tape'
 250 | 				+ ',current,min,temp'
 251 | 				+ ',current_date,mirrorexit,temporary'
 252 | 				+ ',current_time,national,textsize'
 253 | 				+ ',current_timestamp,nocheck,then'
 254 | 				+ ',current_user,nonclustered,to'
 255 | 				+ ',cursor,not,top'
 256 | 				+ ',database,null,tran'
 257 | 				+ ',dbcc,nullif,transaction'
 258 | 				+ ',deallocate,of,trigger'
 259 | 				+ ',declare,off,truncate'
 260 | 				+ ',default,offsets,tsequal'
 261 | 				+ ',delete,on,uncommitted'
 262 | 				+ ',deny,once,union'
 263 | 				+ ',desc,only,unique'
 264 | 				+ ',disk,open,update'
 265 | 				+ ',distinct,opendatasource,updatetext'
 266 | 				+ ',distributed,openquery,use'
 267 | 				+ ',double,openrowset,user'
 268 | 				+ ',drop,option,values'
 269 | 				+ ',dummy,or,varying'
 270 | 				+ ',dump,order,view'
 271 | 				+ ',else,outer,waitfor'
 272 | 				+ ',end,over,when'
 273 | 				+ ',errlvl,percent,where'
 274 | 				+ ',errorexit,perm,while'
 275 | 				+ ',escape,permanent,with'
 276 | 				+ ',except,pipe,work'
 277 | 				+ ',exec,plan,writetext'
 278 | 				+ ',execute,precision'
 279 | 				+ ',exists,prepare'
 280 | 				;
 281 | 
 282 | 			var sTags_Php=
 283 | 				'and,or,xor,__FILE__,exception'
 284 | 				+ ',__LINE__,array,as,break,case'
 285 | 				+ ',class,const,continue,declare,default'
 286 | 				+ ',die,do,echo,else,elseif'
 287 | 				+ ',empty,enddeclar,endfor,endforeach,endif'
 288 | 				+ ',endswitch,endwhile,eval,exit,extends'
 289 | 				+ ',for,foreach,function,global,if'
 290 | 				+ ',include,include_once,isset,list,new'
 291 | 				+ ',print,require,require_once,return,static'
 292 | 				+ ',switch,unset,use,var,while'
 293 | 				+ ',__FUNCTION__,__CLASS__,__METHOD__,final,php_user_filter'
 294 | 				+ ',interface,implements,extends,public,private'
 295 | 				+ ',protected,abstract,clone,try,catch'
 296 | 				+ ',throw,cfunction,this'
 297 | 				;
 298 | 
 299 | 			//2012.7.19 added for R-language;
 300 | 			//2015.6.7 add more keywords by gzhaha
 301 | 			var sTags_R=
 302 | 				'break,else,for,function,if,TRUE,in'
 303 | 				+ ',next,repeat,return,while,FALSE,switch'
 304 | 				+ ',NULL,NA,NaN,NA_integer_,NA_real_,NA_complex_,NA_character_'
 305 | 				;
 306 | 
 307 | 			//2012.7.19  added for Google GO
 308 | 			//https://golang-china.googlecode.com/svn/trunk/Chinese/golang.org/index.html
 309 | 			var sTags_Go=
 310 | 				'package,import,func,const,var,for'
 311 | 				+ ',if,else,switch,case,default,select,return,break,continue'
 312 | 				+ ',range,map,type,struct,interface,new,go,defer'
 313 | 				+ ',byte,int,string,uint32,uint64,float32,float64'
 314 | 				+ ',nil,true,false'
 315 | 				;
 316 | 
 317 | 			//2012.7.27 added for Visual Basic;
 318 | 			//http://msdn.microsoft.com/en-us/library/ksh7h19t%28v=vs.80%29.aspx
 319 | 			var sTags_VB_Reserved=
 320 | 				'AddHandler,AddressOf,Alias,And,AndAlso,As,Boolean,ByRef,Byte,ByVal'
 321 | 				+ ',Call,Case,Catch,CBool,CByte,CChar,CDate,CDec,CDbl,Char,CInt,Class'
 322 | 				+ ',CLng,CObj,Const,Continue,CSByte,CShort,CSng,CStr,CType,CUInt,CULng'
 323 | 				+ ',CUShort,Date,Decimal,Declare,Default,Delegate,Dim,DirectCast,Do'
 324 | 				+ ',Double,Each,Else,ElseIf,End,EndIf,Enum,Erase,Error,Event,Exit,False'
 325 | 				+ ',Finally,For,Friend,Function,Get,GetType,Global,GoSub,GoTo,Handles,If'
 326 | 				+ ',Implements,Imports,In,Inherits,Integer,Interface,Is,IsNot,Let,Lib,Like'
 327 | 				+ ',Long,Loop,Me,Mod,Module,MustInherit,MustOverride,MyBase,MyClass,Namespace'
 328 | 				+ ',Narrowing,New,Next,Not,Nothing,NotInheritable,NotOverridable,Object,Of,On'
 329 | 				+ ',Operator,Option,Optional,Or,OrElse,Overloads,Overridable,Overrides,ParamArray'
 330 | 				+ ',Partial,Private,Property,Protected,Public,RaiseEvent,ReadOnly,ReDim,REM,RemoveHandler'
 331 | 				+ ',Resume,Return,SByte,Select,Set,Shadows,Shared,Short,Single,Static,Step,Stop'
 332 | 				+ ',String,Structure,Sub,SyncLock,Then,Throw,To,True,Try,TryCast,TypeOf,Variant'
 333 | 				+ ',Wend,UInteger,ULong,UShort,Using,When,While,Widening,With,WithEvents,WriteOnly'
 334 | 				+ ',Xor,#Const,#Else,#ElseIf,#End,#If'
 335 | 				;
 336 | 
 337 | 			var sTags_VB_Unreserved=
 338 | 				'Ansi,Assembly,Auto,Binary,Compare,Custom,Explicit,IsFalse,IsTrue,Mid,Off'
 339 | 				+ ',Preserve,Strict,Text,Unicode,Until,#ExternalSource,#Region'
 340 | 				;
 341 | 
 342 | 			//2015.6.6 added for Python by gzhaha;
 343 | 			//https://docs.python.org/2/library/functions.html
 344 | 			var sTags_Python=
 345 | 				'abs,all,any,apply,basestring,bin,bool,buffer,callable'
 346 | 				+ ',chr,classmethod,cmp,coerce,compile,complex,delattr,dict,dir'
 347 | 				+ ',divmod,enumerate,eval,execfile,file,filter,float,format,frozenset'
 348 | 				+ ',getattr,globals,hasattr,hash,help,hex,id,input,int,intern'
 349 | 				+ ',isinstance,issubclass,iter,len,list,locals,long,map,max,min,next'
 350 | 				+ ',object,oct,open,ord,pow,print,property,range,raw_input,reduce'
 351 | 				+ ',reload,repr,reversed,round,set,setattr,slice,sorted,staticmethod'
 352 | 				+ ',str,sum,super,tuple,type,type,unichr,unicode,vars,xrange,zip,__import__'
 353 | 				;
 354 | 
 355 | 			//2015.6.6 added for Python by gzhaha;
 356 | 			var sTags_Pythonkw=
 357 | 				'and,as,assert,break,class,continue,def,del,elif,else'
 358 | 				+ ',except,exec,finally,for,from,global,if,import,in,is'
 359 | 				+ ',lambda,not,or,pass,print,raise,return,try,while,with,yield'
 360 | 				;
 361 | 
 362 | 			//2015.6.6 added for Perl by gzhaha;
 363 | 			//http://perldoc.perl.org/index-functions.html
 364 | 			var sTags_Perl=
 365 | 				'abs,accept,alarm,atan2,bind,binmode,chdir,chmod,chomp,chop,chown,chr'
 366 | 				+ ',chroot,close,closedir,connect,cos,crypt,defined,delete,each,endgrent'
 367 | 				+ ',endhostent,endnetent,endprotoent,endpwent,endservent,eof,exec,exists'
 368 | 				+ ',exp,fcntl,fileno,flock,fork,format,formline,getc,getgrent,getgrgid'
 369 | 				+ ',getgrnam,gethostbyaddr,gethostbyname,gethostent,getlogin,getnetbyaddr'
 370 | 				+ ',getnetbyname,getnetent,getpeername,getpgrp,getppid,getpriority'
 371 | 				+ ',getprotobyname,getprotobynumber,getprotoent,getpwent,getpwnam,getpwuid'
 372 | 				+ ',getservbyname,getservbyport,getservent,getsockname,getsockopt,glob'
 373 | 				+ ',gmtime,grep,hex,index,int,ioctl,join,keys,kill,lc,lcfirst,length,link'
 374 | 				+ ',listen,localtime,lock,log,lstat,map,mkdir,msgctl,msgget,msgrcv,msgsnd'
 375 | 				+ ',oct,open,opendir,ord,pack,pipe,pop,pos,print,printf,prototype,push'
 376 | 				+ ',quotemeta,rand,read,readdir,readline,readlink,readpipe,recv,rename'
 377 | 				+ ',reset,reverse,rewinddir,rindex,rmdir,scalar,seek,seekdir,select,semctl'
 378 | 				+ ',semget,semop,send,setgrent,sethostent,setnetent,setpgrp,setpriority'
 379 | 				+ ',setprotoent,setpwent,setservent,setsockopt,shift,shmctl,shmget,shmread'
 380 | 				+ ',shmwrite,shutdown,sin,sleep,socket,socketpair,sort,splice,split,sprintf'
 381 | 				+ ',sqrt,srand,stat,study,substr,symlink,syscall,sysopen,sysread,sysseek'
 382 | 				+ ',system,syswrite,tell,telldir,time,times,tr,truncate,uc,ucfirst,umask'
 383 | 				+ ',undef,unlink,unpack,unshift,utime,values,vec,wait,waitpid,warn,write'
 384 | 				;
 385 | 
 386 | 			var sTags_Perlkw=
 387 | 				'bless,caller,continue,dbmclose,dbmopen,die,do,dump,else,elsif,eval,exit'
 388 | 				+ ',for,foreach,goto,if,import,last,local,my,next,no,our,package,redo,ref'
 389 | 				+ ',require,return,sub,tie,tied,unless,untie,until,use,wantarray,while'
 390 | 				;
 391 | 
 392 | 			//2015.6.7 added for ActionScript by gzhaha;
 393 | 			//http://help.adobe.com/zh_CN/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f9b.html
 394 | 			var sTags_ActionScript=
 395 | 				'as,break,case,catch,class,const,default,delete,do,else,extends,finally'
 396 | 				+ ',for,function,if,implements,import,in,instanceof,interface,internal,is'
 397 | 				+ ',native,new,null,package,private,protected,public,return,super,switch,this'
 398 | 				+ ',throw,try,typeof,use,var,void,while,with,dynamic,each,final,get,include'
 399 | 				+ ',namespace,native,override,set,static'
 400 | 				;
 401 | 
 402 | 			//2015.6.7 added for Ruby by gzhaha;
 403 | 			var sTags_Ruby=
 404 | 				'alias,and,BEGIN,begin,break,case,class,def,define_method,defined,do,each,else,elsif'
 405 | 				+ ',END,end,ensure,false,for,if,in,module,new,next,nil,not,or,raise,redo,rescue,retry,return'
 406 | 				+ ',self,super,then,throw,true,undef,unless,until,when,while,yield'
 407 | 				;
 408 | 
 409 | 			var sTags_RubyBI=
 410 | 				'Array,Bignum,Binding,Class,Continuation,Dir,Exception,FalseClass,File::Stat,File,Fixnum,Fload'
 411 | 				+',Hash,Integer,IO,MatchData,Method,Module,NilClass,Numeric,Object,Proc,Range,Regexp,String,Struct::TMS,Symbol'
 412 | 				+',ThreadGroup,Thread,Time,TrueClass'
 413 | 				;
 414 | 
 415 | 			//2015.6.8 added for Delphi by gzhaha;
 416 | 			var sTags_Delphi=
 417 | 				'abs,addr,and,ansichar,ansistring,array,as,asm,begin,boolean,byte,cardinal'
 418 | 				+',case,char,class,comp,const,constructor,currency,destructor,div,do,double'
 419 | 				+',downto,else,end,except,exports,extended,false,file,finalization,finally'
 420 | 				+',for,function,goto,if,implementation,in,inherited,int64,initialization'
 421 | 				+',integer,interface,is,label,library,longint,longword,mod,nil,not,object'
 422 | 				+',of,on,or,packed,pansichar,pansistring,pchar,pcurrency,pdatetime,pextended'
 423 | 				+',pint64,pointer,private,procedure,program,property,pshortstring,pstring'
 424 | 				+',pvariant,pwidechar,pwidestring,protected,public,published,raise,real,real48'
 425 | 				+',record,repeat,set,shl,shortint,shortstring,shr,single,smallint,string,then'
 426 | 				+',threadvar,to,true,try,type,unit,until,uses,val,var,varirnt,while,widechar'
 427 | 				+',widestring,with,word,write,writeln,xor'
 428 | 				;
 429 | 
 430 | 			//2015.6.8 added for Pig Latin by gzhaha;
 431 | 			var sTags_PigLatin=
 432 | 				'ABS,ACOS,ARITY,ASIN,ATAN,AVG,BAGSIZE,BINSTORAGE,BLOOM,BUILDBLOOM,CBRT,CEIL'
 433 | 				+ ',CONCAT,COR,COS,COSH,COUNT,COUNT_STAR,COV,CONSTANTSIZE,CUBEDIMENSIONS,DIFF,DISTINCT,DOUBLEABS'
 434 | 				+ ',DOUBLEAVG,DOUBLEBASE,DOUBLEMAX,DOUBLEMIN,DOUBLEROUND,DOUBLESUM,EXP,FLOOR,FLOATABS,FLOATAVG'
 435 | 				+ ',FLOATMAX,FLOATMIN,FLOATROUND,FLOATSUM,GENERICINVOKER,INDEXOF,INTABS,INTAVG,INTMAX,INTMIN'
 436 | 				+ ',INTSUM,INVOKEFORDOUBLE,INVOKEFORFLOAT,INVOKEFORINT,INVOKEFORLONG,INVOKEFORSTRING,INVOKER'
 437 | 				+ ',ISEMPTY,JSONLOADER,JSONMETADATA,JSONSTORAGE,LAST_INDEX_OF,LCFIRST,LOG,LOG10,LOWER,LONGABS'
 438 | 				+ ',LONGAVG,LONGMAX,LONGMIN,LONGSUM,MAX,MIN,MAPSIZE,MONITOREDUDF,NONDETERMINISTIC,OUTPUTSCHEMA'
 439 | 				+ ',PIGSTORAGE,PIGSTREAMING,RANDOM,REGEX_EXTRACT,REGEX_EXTRACT_ALL,REPLACE,ROUND,SIN,SINH,SIZE'
 440 | 				+ ',SQRT,STRSPLIT,SUBSTRING,SUM,STRINGCONCAT,STRINGMAX,STRINGMIN,STRINGSIZE,TAN,TANH,TOBAG'
 441 | 				+ ',TOKENIZE,TOMAP,TOP,TOTUPLE,TRIM,TEXTLOADER,TUPLESIZE,UCFIRST,UPPER,UTF8STORAGECONVERTER'
 442 | 				;
 443 | 
 444 | 			var sTags_PigLatinKW=
 445 | 				'VOID,IMPORT,RETURNS,DEFINE,LOAD,FILTER,FOREACH,ORDER,CUBE,DISTINCT,COGROUP'
 446 | 				+ ',JOIN,CROSS,UNION,SPLIT,INTO,IF,OTHERWISE,ALL,AS,BY,USING,INNER,OUTER,ONSCHEMA,PARALLEL'
 447 | 				+ ',PARTITION,GROUP,AND,OR,NOT,GENERATE,FLATTEN,ASC,DESC,IS,STREAM,THROUGH,STORE,MAPREDUCE'
 448 | 				+ ',SHIP,CACHE,INPUT,OUTPUT,STDERROR,STDIN,STDOUT,LIMIT,SAMPLE,LEFT,RIGHT,FULL,EQ,GT,LT,GTE,LTE'
 449 | 				+ ',NEQ,MATCHES,TRUE,FALSE,DUMP'
 450 | 				;
 451 | 
 452 | 			//2015.6.8 added for Bash by gzhaha;
 453 | 			var sTags_BASH=
 454 | 				'if,fi,then,elif,else,for,do,done,until,while,break,continue,case,function,return,in,eq,ne,ge,le'
 455 | 				;
 456 | 
 457 | 			var sTags_BASHBI=
 458 | 				'alias,apropos,awk,basename,bash,bc,bg,builtin,bzip2,cal,cat,cd,cfdisk,chgrp,chmod,chown,chroot'
 459 | 				+',cksum,clear,cmp,comm,command,cp,cron,crontab,csplit,cut,date,dc,dd,ddrescue,declare,df'
 460 | 				+',diff,diff3,dig,dir,dircolors,dirname,dirs,du,echo,egrep,eject,enable,env,ethtool,eval'
 461 | 				+',exec,exit,expand,export,expr,false,fdformat,fdisk,fg,fgrep,file,find,fmt,fold,format'
 462 | 				+',free,fsck,ftp,gawk,getopts,grep,groups,gzip,hash,head,history,hostname,id,ifconfig'
 463 | 				+',import,install,join,kill,less,let,ln,local,locate,logname,logout,look,lpc,lpr,lprint'
 464 | 				+',lprintd,lprintq,lprm,ls,lsof,make,man,mkdir,mkfifo,mkisofs,mknod,more,mount,mtools'
 465 | 				+',mv,netstat,nice,nl,nohup,nslookup,open,op,passwd,paste,pathchk,ping,popd,pr,printcap'
 466 | 				+',printenv,printf,ps,pushd,pwd,quota,quotacheck,quotactl,ram,rcp,read,readonly,renice'
 467 | 				+',remsync,rm,rmdir,rsync,screen,scp,sdiff,sed,select,seq,set,sftp,shift,shopt,shutdown'
 468 | 				+',sleep,sort,source,split,ssh,strace,su,sudo,sum,symlink,sync,tail,tar,tee,test,time'
 469 | 				+',times,touch,top,traceroute,trap,tr,true,tsort,tty,type,ulimit,umask,umount,unalias'
 470 | 				+',uname,unexpand,uniq,units,unset,unshar,useradd,usermod,users,uuencode,uudecode,v,vdir'
 471 | 				+',vi,watch,wc,whereis,which,who,whoami,Wget,xargs,yes'
 472 | 				;
 473 | 
 474 | 			//2015.6.11 added for myBase by gzhaha;
 475 | 			var sTags_myBase=
 476 | 				'about|alert|confirm|prompt|dropdown|textbox|input|beep|sleep|_gc'
 477 | 
 478 | 				//+ '|platform.getOpenFileName|platform.getOpenFileNames|platform.getSaveFileName|platform.browseForFolder'
 479 | 				//+ '|platform.getTempFile|platform.getTempPath|platform.getHomePath|platform.getCurrentPath|platform.deferDeleteFile'
 480 | 				//+ '|platform.extractTextFromRtf|platform.extractTextFromHtml|platform.parseFile|platform.tokenizeText'
 481 | 				//+ '|plugin.getAppWorkingDir|plugin.getAppExeFile|plugin.getPluginID|plugin.getScriptFile|plugin.getScriptTitle'
 482 | 				//+ '|plugin.getShortcutFile|plugin.getLanguageFile|plugin.getPathToLangFiles|plugin.getDefRootContainer'
 483 | 				//+ '|plugin.getDefNoteFn|plugin.refreshDocViews|plugin.refreshOutline|plugin.refreshLabelTree|plugin.refreshCalendar'
 484 | 				//+ '|plugin.refreshOverview|plugin.getLocaleMsg|plugin.getDbCount|plugin.getDbIndex|plugin.getCurDbIndex'
 485 | 				//+ '|plugin.getCurNavigationTab|plugin.getCurDocFile|plugin.getCurDocPath|plugin.getCurInfoItem|plugin.getCurLabelItem'
 486 | 				//+ '|plugin.getSelectedInfoItems|plugin.getSelectedText|plugin.getTextContent|plugin.setTextContent'
 487 | 				//+ '|plugin.replaceSelectedText|plugin.getQueryResults|plugin.runQuery|plugin.appendToResults'
 488 | 				//+ '|plugin.setResultsPaneTitle|plugin.showResultsPane|plugin.initProgressRange|plugin.showProgressMsg'
 489 | 				//+ '|plugin.ctrlProgressBar|plugin.destroyProgressBar|plugin.commitCurrentChanges|plugin.isContentEditable'
 490 | 				//+ '|plugin.runDomScript|plugin.setDomDirty|plugin.setDomReadonly|plugin.getItemIDByPath|plugin.getPathByItemID'
 491 | 				//+ '|localStorage.getItem|localStorage.setItem|localStorage.removeItem|localStorage.clear'
 492 | 
 493 | 				//2015.6.12 @gzhaha :) Nice to have an item for mybase jsapi in the language list;
 494 | 				//Revised by wjj; 
 495 | 				//The API lists may vary in future releases; so RegExp patterns are recommended for better flexibility;
 496 | 				//It is somewhat easy to highlight the global objects/functions and classes by the hard-coded names; 
 497 | 				//however; it seemed hard to recognize member functions of objects created from the classes (eg. xNyf.isOpen(...);)
 498 | 
 499 | 				+ '|plugin\.\\w+' //or use '|plugin(?=\.)' for global objects only; without memeber functions highlighted;
 500 | 				+ '|platform\.\\w+'
 501 | 				+ '|localStorage\.\\w+'
 502 | 				+ '|CNyfDb|CDbItem|CLocalFile|CLocalDir|CByteArray'
 503 | 				+ '|CXmlDocument|CAppWord|CAppExcel|CAppOutlook'
 504 | 				;
 505 | 
 506 | 			//2015.6.14 added for Pascal by gzhaha;
 507 | 			var sTags_Pascal=
 508 | 				'absolute,abstract,and,array,as,asm,assembler,at,automated,begin,case,cdecl,class,const,constructor,contains'
 509 | 				+ ',default,destructor,dispid,dispinterface,div,do,downto,dynamic,else,end,except,export,exports,external,far'
 510 | 				+ ',file,finalization,finally,for,forward,function,goto,if,implementation,implements,in,index,inherited'
 511 | 				+ ',initialization,inline,interface,is,label,library,message,mod,name,near,nil,nodefault,not,object,of,on,or'
 512 | 				+ ',out,overload,override,package,packed,pascal,private,procedure,program,property,protected,public,published'
 513 | 				+ ',raise,read,readonly,record,register,reintroduce,repeat,requires,resident,resourcestring,safecall,set,shl'
 514 | 				+ ',shr,stdcall,stored,string,then,threadvar,to,try,type,unit,until,uses,var,virtual,while,with,write,writeonly,xor'
 515 | 				;
 516 | 
 517 | 			//2015.6.16 added for Objective-C by wjj;
 518 | 			//http://www.binpress.com/tutorial/objective-c-reserved-keywords/43
 519 | 			//http://www.learn-cocos2d.com/2011/10/complete-list-objectivec-20-compiler-directives/
 520 | 			var sTags_ObjC=
 521 | 				'auto,break,case,char,const,continue,default,do,double,else,enum,extern,float,for,goto,if,inline,int,long,register'
 522 | 				+ ',restrict,return,short,signed,sizeof,static,struct,switch,typedef,union,unsinged,void,volatile,while,__Bool,__Complex'
 523 | 				+ ',BOOL,Class,bycopy,byref,id,IMP,in,inout,nil,NO,NULL,oneway,out,Protocol,SEL,self,super,YES'
 524 | 				+ ',@interface,@end,@implementation,@protocol,@class,@public,@protected,@private,@property,@try,@throw,@catch,@finally,@synthesize,@dynamic,@selector,atomic,nonatomic,retain'
 525 | 				+ ',@defs,@required,@optional,@end,@package,@end,@synchronized,@autoreleasepool,@selector,@encode,@compatibility_alias'
 526 | 				;
 527 | 
 528 | 			//https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/ObjC_classic/index.html
 529 | 			var sTags_ObjC_Cocoa=
 530 | 				'NS[A-Z][a-zA-Z]{2,64}'
 531 | 				;
 532 | 
 533 | 			//2015.6.18 added for Swift by wjj;
 534 | 			https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html
 535 | 			var sTags_Swift=
 536 | 				'class,deinit,enum,extension,func,import,init,internal,let,operator,private,protocol,public,static,struct,subscript,typealias,var'
 537 | 				+ ',break,case,continue,default,do,else,fallthrough,for,if,in,return,switch,where,while'
 538 | 				+ ',as,dynamicType,false,is,nil,self,Self,super,true,__COLUMN__,__FILE__,__FUNCTION__,__LINE__'
 539 | 				+ ',associativity,convenience,dynamic,didSet,final,get,infix,inout,lazy,left,mutating,none,nonmutating,optional,override,postfix,precedence,prefix,Protocol,required,right,set,Type,unowned,weak,willSet'
 540 | 				;
 541 | 
 542 | 			//https://developer.apple.com/library/ios/navigation/
 543 | 			var sTags_Swift_Lib=
 544 | 				'NS[A-Z][a-zA-Z]{2,64}'
 545 | 				+ '|UI[A-Z][a-zA-Z]{2,64}'
 546 | 				+ '|CI[A-Z][a-zA-Z]{2,64}'
 547 | 				+ '|CK[A-Z][a-zA-Z]{2,64}'
 548 | 				+ '|CF[A-Z][a-zA-Z]{2,64}'
 549 | 				+ '|AV[A-Z][a-zA-Z]{2,64}'
 550 | 				+ '|AU[A-Z][a-zA-Z]{2,64}'
 551 | 				+ '|MK[A-Z][a-zA-Z]{2,64}'
 552 | 				+ '|MT[A-Z][a-zA-Z]{2,64}'
 553 | 				+ '|SC[A-Z][a-zA-Z]{2,64}'
 554 | 				+ '|GC[A-Z][a-zA-Z]{2,64}'
 555 | 				//...
 556 | 				;
 557 | 
 558 | 			//Array objects to save strings/remarks substituted with internal tags;
 559 | 			var vRem=[]; //for remarks (blocks & lines);
 560 | 			var vStr=[]; //for Strings;
 561 | 			var nRefID=0; //ID of remarks/strings;
 562 | 
 563 | 			//2012.1.31 The tags are used to temporarily substitute for strings/remarks;
 564 | 			//The ref-tags must be absolutely strange to any programming languages;
 565 | 			var sRefTag1='!`', sRefTag2='`!';
 566 | 
 567 | 			var _ref_tag=function(){return sRefTag1+(nRefID++)+sRefTag2;};
 568 | 
 569 | 			var _parse_remark_blocks=function(sSrc, vRemBlockTag){
 570 | 
 571 | 				//2015.6.18 Apple Swift supports nested comments, but for now not supported by this plugin;
 572 | 				//https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html
 573 | 				//To-do: trace into the multiline comments and track the nested comment tags by counting deepness or running a recursive function;
 574 | 
 575 | 				//To substitute internal tags for /*...*/ remark blocks;
 576 | 				if(vRemBlockTag.constructor === Array){
 577 | 
 578 | 					//2015.6.15 Pascal has three ways to perform comment, //XXXX, (*XXXX*) and {XXXX};
 579 | 					//added codes to deal with multiple set of the symbols for block comment;
 580 | 
 581 | 					for(var i in vRemBlockTag){
 582 | 						var sRemBlockStart=vRemBlockTag[i].start, sRemBlockEnd=vRemBlockTag[i].end;
 583 | 						var s2=sSrc; sSrc='';
 584 | 						while(s2){
 585 | 							var p1=s2.indexOf(sRemBlockStart);
 586 | 							if(p1>=0){
 587 | 								var p2=s2.indexOf(sRemBlockEnd, p1+sRemBlockStart.length);
 588 | 								if(p2<0) p2=s2.length; else p2+=sRemBlockEnd.length;
 589 | 								//if(p2>0)
 590 | 								{
 591 | 									var left=s2.substr(0, p1), sRem=s2.substring(p1, p2), right=s2.substr(p2);
 592 | 									var sTag=_ref_tag();
 593 | 									sSrc+=(left+sTag);
 594 | 									s2=right;
 595 | 									vRem[vRem.length]={sTag: sTag, sVal: sRem};
 596 | 								}
 597 | 							}else{
 598 | 								sSrc+=s2;
 599 | 								s2='';
 600 | 							}
 601 | 						}
 602 | 					}
 603 | 				}
 604 | 
 605 | 				return sSrc;
 606 | 			};
 607 | 
 608 | 			var _parse_remark_line=function(sLine, vRemLineTag){
 609 | 
 610 | 				var _replace=function(sLine, sRemLineTag){
 611 | 					if(sLine && sRemLineTag){
 612 | 						//2015.6.7 efforts on dealing with # symbol within quotation marks: '...#...' or "...#..."
 613 | 						//2015.6.12 no need for this changes now.
 614 | 						//if (sLine.search(/\".*\#.*\"/) < 0 && sLine.search(/\'.*\#.*\'/) <0){
 615 | 
 616 | 							var xRE=new RegExp(sRemLineTag+'(.*)$', '');
 617 | 							sLine=sLine.replace(xRE, function(w){
 618 | 								var sTag=_ref_tag();
 619 | 								vRem[vRem.length]={sTag: sTag, sVal: w};
 620 | 								return sTag;
 621 | 							});
 622 | 
 623 | 						//}
 624 | 					}
 625 | 					return sLine;
 626 | 				};
 627 | 
 628 | 				//substitute internal tags for the remark lines;
 629 | 				for(var i in vRemLineTag){
 630 | 					sLine=_replace(sLine, vRemLineTag[i]);
 631 | 				}
 632 | 				return sLine;
 633 | 			};
 634 | 
 635 | 			var _parse_strings=function(sLine, sQuotationMark){
 636 | 
 637 | 				//substitute for constants of C-string/HTML-value, like "...";
 638 | 				//substitute for constants of JS-string/HTML-value/C-char, like '...';
 639 | 
 640 | 				var _pos_of_quotationmark=function(s, iStart){
 641 | 					var p;
 642 | 					while( (p=s.indexOf(sQuotationMark, iStart)) >0 ){
 643 | 						if(s.charAt(p-1)=='\\'){
 644 | 							iStart=p+sQuotationMark.length;
 645 | 						}else{
 646 | 							break;
 647 | 						}
 648 | 					}
 649 | 					return p;
 650 | 				};
 651 | 
 652 | 				var s=sLine; sLine='';
 653 | 				while(s){
 654 | 					var p1=_pos_of_quotationmark(s, 0);
 655 | 					if(p1>=0){
 656 | 						var p2=_pos_of_quotationmark(s, p1+sQuotationMark.length);
 657 | 						if(p2<0) p2=s.length; else p2+=sQuotationMark.length;
 658 | 						//if(p2>0)
 659 | 						{
 660 | 							var left=s.substr(0, p1), sStr=s.substring(p1, p2), right=s.substr(p2);
 661 | 							var sTag=_ref_tag();
 662 | 							sLine+=(left+sTag);
 663 | 							s=right;
 664 | 							vStr[vStr.length]={sTag: sTag, sVal: sStr};
 665 | 						}
 666 | 					}else{
 667 | 						sLine+=s;
 668 | 						s='';
 669 | 					}
 670 | 				}
 671 | 				return sLine;
 672 | 			};
 673 | 
 674 | 			var _restore_strings=function(s){
 675 | 				//restore String contants;
 676 | 				for(var j=vStr.length-1; j>=0; --j){
 677 | 					var sTag=vStr[j].sTag, sVal=vStr[j].sVal;
 678 | 					var r=''.replace(/%COLOR%/g, c_sColorStrings)+sVal+'';
 679 | 					s=s.replace(sTag, r);
 680 | 				}
 681 | 				return s;
 682 | 			};
 683 | 
 684 | 			var _restore_remarks=function(s){
 685 | 				//restore remark blocks and lines;
 686 | 				for(var j=vRem.length-1; j>=0; --j){
 687 | 					var sTag=vRem[j].sTag, sVal=vRem[j].sVal;
 688 | 					var v=sVal.split('\n'), r='';
 689 | 					for(var i in v){
 690 | 						if(r) r+='\n';
 691 | 						r+=''.replace(/%COLOR%/g, c_sColorRemarks)+v[i]+'';
 692 | 					}
 693 | 					s=s.replace(sTag, r);
 694 | 				}
 695 | 				return s;
 696 | 			};
 697 | 
 698 | 			var _syntax_cpplike=function(s, vTags, vRemBlockTag, vRemLineTag){
 699 | 
 700 | 				s=s.replace(/\r\n/g, '\n')
 701 | 					.replace(/\r/g, '\n')
 702 | 					//.replace(/\\/g, '\\\\')
 703 | 					;
 704 | 
 705 | 				var _highlight_numbers=function(sLine, sColor){
 706 | 					if(sLine){
 707 | 						var sFmt=''.replace(/%COLOR%/g, sColor);
 708 | 
 709 | 						//Hexadecimal, Decimal/Float;
 710 | 						var xRE=new RegExp( '(\\W+)((?:0x[0-9a-f]+)|(?:[0-9.]+))(?=\\W?)', 'ig');
 711 | 						sLine=sLine.replace(xRE, function(w, s1, s2){
 712 | 							//first check to see if it is a tag for strings/remarks;
 713 | 							var p=s1.indexOf(sRefTag1);
 714 | 							if(p>=0 && p==s1.length-sRefTag1.length){
 715 | 								return w; //avoid replacing temporary tags of strings/remarks;
 716 | 							}else{
 717 | 								return s1+sFmt+s2+'';
 718 | 							}
 719 | 						});
 720 | 					}
 721 | 					return sLine;
 722 | 				};
 723 | 
 724 | 				var _highlight_tags=function(sLine, sTags, bRegExp, bNoCase, sColor){
 725 | 
 726 | 					if(!bRegExp) sTags=sTags.replace(/,/g, '|').replace(/\s/g, ''); //make into RegExp pattern;
 727 | 					
 728 | 					if(sLine && sTags){
 729 | 
 730 | 						var sFmt=''.replace(/%COLOR%/g, sColor);
 731 | 
 732 | 						//This RegExp tests but not save/consume trailing characters;
 733 | 						var xRE=new RegExp( '(\\W+|^)(' + sTags + ')(?=\\W|$)', 'g'+(bNoCase?'i':''));
 734 | 						sLine=sLine.replace(xRE, function(w, s1, s2){
 735 | 							return s1+sFmt+s2+'';
 736 | 						});
 737 | 					}
 738 | 					return sLine;
 739 | 				};
 740 | 
 741 | 
 742 | 				//2015.6.7 the operators (<, &, >) in source code may cause confusion to webkit on parsing them as HTML without pre-transformation;
 743 | 				//tried a solution of precedingly transforming < and > operators into HTML entities,
 744 | 				//and assumed that 'lt,gt' are not listed as keywords for any languages;
 745 | 				//s=s.replace(//g, '>');
 746 | 				//Unfortunately, both lt and gt could be in use as keywords in some languages e.g. Perl, Bash;
 747 | 				//Another solution: substitute special tags for < and > operators before syntax highlighting, 
 748 | 				//and finally replace the tags with the appropriate HTML entities after all done;
 749 | 				//2015.6.9 also need to substitute for the & character, so HTML entities can be preserved in resulting HTML.
 750 | 				//2015.6.12 also need to substitute for the $ character, the issue is related to parse '$' in source code.
 751 | 				//2015.6.12 also need to substitute for the \ character, the issue is related to parse \\ in source code.
 752 | 
 753 | 				//2015.8.17 a safe method to generate the special tags for '<>&...', in case that they could appear in source code, e.g. the script itself;
 754 | 				var _make_special=function(s){
 755 | 					if(s){
 756 | 						var r='';
 757 | 						for(var i=0; i/g, sTagGT).replace(/&/g, sTagAND).replace(/\$/g, sTagDL).replace(/\\/g, sTagBS);
 769 | 
 770 | 				//2015.8.17 Remark blocks may contain the above special characters such as < >;
 771 | 				s=_parse_remark_blocks(s, vRemBlockTag);
 772 | 
 773 | 				var vLines=s.split('\n');
 774 | 
 775 | 				plugin.initProgressRange(plugin.getScriptTitle(), vLines.length);
 776 | 
 777 | 				for(var k in vLines){
 778 | 
 779 | 					//2015.6.7 the opertotors < and > in source code may cause confusion to webkit without transformation;
 780 | 					//tried to precedingly transform < and > operators into HTML entities;
 781 | 					//and assumed that 'lt,gt' are not listed as keywords for any languages;
 782 | 					//var sLine=vLines[k].replace(//g, '>');
 783 | 
 784 | 					//Unfortunately, both lt and gt are used as keywords in Perl;
 785 | 					//Workaround: substitute special tags for < and > operators, and restore them after all done;
 786 | 					var sLine=vLines[k];
 787 | 
 788 | 					var sTitle=_trim(sLine), nMaxLen=32; if(sTitle.length>nMaxLen) sTitle=sTitle.substr(0,nMaxLen);
 789 | 					var bContinue=plugin.ctrlProgressBar(sTitle, 1, true);
 790 | 					if(!bContinue) return '';
 791 | 
 792 | 					sLine=_parse_remark_line(sLine, vRemLineTag); //cpp-like comment lines;
 793 | 					sLine=_parse_strings(sLine, '\''); //js-like strings;
 794 | 					sLine=_parse_strings(sLine, '\"'); //cpp-like strings;
 795 | 
 796 | 					sLine=_highlight_numbers(sLine, c_sColorNumbers);
 797 | 
 798 | 					for(var j in vTags){
 799 | 						var d=vTags[j];
 800 | 						var sTags=d.sTags, sColor=d.sColor, bNoCase=d.bNoCase, bRegExp=d.bRegExp;
 801 | 						sLine=_highlight_tags(sLine, sTags, bRegExp, bNoCase, sColor);
 802 | 					}
 803 | 
 804 | 					vLines[k]=sLine;
 805 | 				}
 806 | 
 807 | 				s='';
 808 | 				for(var j in vLines){
 809 | 					if(s) s+='\n';
 810 | 					s+=vLines[j];
 811 | 				}
 812 | 
 813 | 				s=_restore_strings(s);
 814 | 				s=_restore_remarks(s);
 815 | 
 816 | 				s=s.replace(xReLT, '<').replace(xReGT, '>').replace(xReAND, '&').replace(xReDL, '$').replace(xReBS, '\\');
 817 | 
 818 | 				return s;
 819 | 			};
 820 | 
 821 | 			var sSrc=plugin.getSelectedText(-1, false), bWhole=false;
 822 | 			if(!sSrc){
 823 | 				bWhole=true;
 824 | 				sSrc=plugin.getTextContent(-1, false);
 825 | 			}
 826 | 
 827 | 			if(sSrc){
 828 | 
 829 | 				var xLang={
 830 | 					  'cpp': 'C/C++'
 831 | 					, 'cppstl': 'C/C++ with STL'
 832 | 					, 'cppstlqt': 'C/C++ with STL/Qt'
 833 | 					, 'java': 'Java'
 834 | 					, 'cs': 'C#'
 835 | 					, 'js': 'Javascript'
 836 | 					, 'jsmybase': 'Javascript with myBase Plugin APIs'
 837 | 					, 'sql': 'T-SQL'
 838 | 					, 'php': 'PHP'
 839 | 					, 'go': 'Google GO'
 840 | 					, 'gnur': 'GNU/R Language'
 841 | 					, 'vb': 'Visual Basic'
 842 | 					, 'py': 'Python'
 843 | 					, 'pl': 'Perl'
 844 | 					, 'as': 'ActionScript'
 845 | 					, 'ruby': 'Ruby'
 846 | 					, 'delphi': 'Delphi'
 847 | 					, 'pigla': 'Pig Latin'
 848 | 					, 'bash': 'Bash'
 849 | 					, 'pascal': 'Pascal'
 850 | 					, 'objc': 'Objective-C'
 851 | 					, 'swift': 'Swift'
 852 | 				};
 853 | 
 854 | 				var vIDs=[], vLangs=[];
 855 | 				for(var i in xLang){
 856 | 					vIDs[vIDs.length]=i;
 857 | 					vLangs[vLangs.length]=xLang[i];
 858 | 				}
 859 | 
 860 | 				//2015.6.29 a list of fixed fonts;
 861 | 				//http://stackoverflow.com/questions/3995022/pre-tag-and-css-font-family
 862 | 				//http://www.w3schools.com/cssref/css_websafe_fonts.asp
 863 | 				var vFonts=[
 864 | 					'|'+_lc('p.Common.Default', 'Default')
 865 | 					, 'Lucida Console', 'Courier New', 'Consolas', 'serif'
 866 | 					, 'Menlo', 'Monaco', 'monospace', 'Liberation Mono'
 867 | 					, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono'
 868 | 					];
 869 | 
 870 | 				var vSizes=['|'+_lc('p.Common.Default', 'Default')];
 871 | 				for(var i=8; i<=72; ++i){
 872 | 					vSizes.push(i+'pt');
 873 | 					if(i>=20) i+=3;
 874 | 				}
 875 | 
 876 | 				var sCfgKey0='SyntaxHighlight.nUses', nUses=parseInt(localStorage.getItem(sCfgKey0)||'');
 877 | 				var sCfgKey1='SyntaxHighlight.iLang', sCfgKey2='SyntaxHighlight.sFontName', sCfgKey3='SyntaxHighlight.sFontSize';
 878 | 				var vFields = [
 879 | 					{sField: 'combolist', sLabel: _lc2('Language', 'Language'), vItems: vLangs, sInit: localStorage.getItem(sCfgKey1)||''}
 880 | 					, {sField: 'comboedit', sLabel: _lc2('FontName', 'Font name'), vItems: vFonts, sInit: localStorage.getItem(sCfgKey2)||(nUses==0 ? c_sFontName : ''), bReq: false}
 881 | 					, {sField: 'comboedit', sLabel: _lc2('FontSize', 'Font size'), vItems: vSizes, sInit: localStorage.getItem(sCfgKey3)||(nUses==0 ? c_sFontSizee : ''), bReq: false}
 882 | 					];
 883 | 				var vRes=input(plugin.getScriptTitle(), vFields, {nMinSize: 450, vMargins: [6, 0, 30, 0], bVert: false});
 884 | 				if(vRes && vRes.length==3){
 885 | 
 886 | 					var iLang=vRes[0], sFontName=vRes[1], sFontSize=vRes[2];
 887 | 
 888 | 					localStorage.setItem(sCfgKey0, ++nUses);
 889 | 					localStorage.setItem(sCfgKey1, iLang);
 890 | 					localStorage.setItem(sCfgKey2, sFontName);
 891 | 					localStorage.setItem(sCfgKey3, sFontSize);
 892 | 
 893 | 					//sSrc='\n'+sSrc;
 894 | 
 895 | 					var sID=vIDs[iLang];
 896 | 
 897 | 					//2015.6.15 For more info about comments in programming languages;
 898 | 					//http://www.gavilan.edu/csis/languages/comments.html
 899 | 					//http://stackoverflow.com/questions/3842443/comments-in-pascal
 900 | 
 901 | 					var vTags=[], vRemBlockTag=[{start: '/*', end: '*/'}], vRemLineTag=['//'], sGenre='cpp';
 902 | 					switch(sID){
 903 | 						case 'cpp':
 904 | 							vTags=[{sTags: sTags_Cpp, sColor: c_sColorKeywords}];
 905 | 							break;
 906 | 						case 'cppstl':
 907 | 							vTags=[
 908 | 								{sTags: sTags_Cpp, sColor: c_sColorKeywords}
 909 | 								, {sTags: sTags_Stl, sColor: c_sColorReservedTags1}
 910 | 							];
 911 | 							break;
 912 | 						case 'cppstlqt':
 913 | 							vTags=[
 914 | 								{sTags: sTags_Cpp, sColor: c_sColorKeywords}
 915 | 								, {sTags: sTags_Stl, sColor: c_sColorReservedTags1}
 916 | 								, {sTags: sTags_Qt, sColor: c_sColorReservedTags5, bNoCase: false, bRegExp: true}
 917 | 							];
 918 | 							break;
 919 | 						case 'java':
 920 | 							vTags=[{sTags: sTags_Java, sColor: c_sColorKeywords}];
 921 | 							break;
 922 | 						case 'cs':
 923 | 							vTags=[{sTags: sTags_CSharp, sColor: c_sColorKeywords}];
 924 | 							break;
 925 | 						case 'js':
 926 | 							vTags=[
 927 | 								{sTags: sTags_JS, sColor: c_sColorKeywords}
 928 | 								, {sTags: sTags_JSConst, sColor: c_sColorNumbers}
 929 | 								, {sTags: sTags_JSDom, sColor: c_sColorReservedTags1}
 930 | 								, {sTags: sTags_JSEvent, sColor: c_sColorReservedTags3}
 931 | 							];
 932 | 							break;
 933 | 						case 'jsmybase':
 934 | 							vTags=[
 935 | 								{sTags: sTags_JS, sColor: c_sColorKeywords}
 936 | 								, {sTags: sTags_JSConst, sColor: c_sColorNumbers}
 937 | 								//, {sTags: sTags_JSDom, sColor: c_sColorReservedTags1}
 938 | 								//, {sTags: sTags_JSEvent, sColor: c_sColorReservedTags3}
 939 | 								, {sTags: sTags_myBase, sColor: c_sColorReservedTags6, bRegExp: true}
 940 | 							];
 941 | 							break;
 942 | 						case 'sql':
 943 | 							vTags=[{sTags: sTags_Sql, sColor: c_sColorKeywords, bNoCase: true}];
 944 | 							vRemLineTag=['--'];
 945 | 							break;
 946 | 						case 'php':
 947 | 							vTags=[{sTags: sTags_Php, sColor: c_sColorKeywords}];
 948 | 							break;
 949 | 						case 'gnur':
 950 | 							vTags=[{sTags: sTags_R, sColor: c_sColorKeywords}];
 951 | 							vRemBlockTag=[];
 952 | 							vRemLineTag=['#'];
 953 | 							break;
 954 | 						case 'go':
 955 | 							vTags=[{sTags: sTags_Go, sColor: c_sColorKeywords}];
 956 | 							break;
 957 | 						case 'vb':
 958 | 							vTags=[
 959 | 								{sTags: sTags_VB_Reserved, sColor: c_sColorKeywords, bNoCase: true}
 960 | 								, {sTags: sTags_VB_Unreserved, sColor: c_sColorReservedTags1, bNoCase: true}
 961 | 							];
 962 | 							vRemBlockTag=[];
 963 | 							vRemLineTag=['REM', '\''];
 964 | 							break;
 965 | 						case 'py':
 966 | 							vTags=[
 967 | 								{sTags: sTags_Pythonkw, sColor: c_sColorKeywords}
 968 | 								, {sTags: sTags_Python, sColor: c_sColorReservedTags3}
 969 | 							];
 970 | 							vRemBlockTag=[{start: "'''", end: "'''"}];
 971 | 							vRemLineTag=['#'];
 972 | 							break;
 973 | 						case 'pl':
 974 | 							vTags=[
 975 | 								{sTags: sTags_Perlkw, sColor: c_sColorKeywords}
 976 | 								, {sTags: sTags_Perl, sColor: c_sColorReservedTags3}
 977 | 							];
 978 | 							vRemBlockTag=[{start: '=pod', end: '=cut'}];
 979 | 							vRemLineTag=['#'];
 980 | 							break;
 981 | 						case 'as':
 982 | 							vTags=[
 983 | 								{sTags: sTags_ActionScript, sColor: c_sColorKeywords}
 984 | 							];
 985 | 							break;
 986 | 						case 'ruby':
 987 | 							vTags=[
 988 | 								{sTags: sTags_Ruby, sColor: c_sColorKeywords}
 989 | 								, {sTags: sTags_RubyBI, sColor: c_sColorReservedTags3}
 990 | 							];
 991 | 							vRemBlockTag=[{start: '=begin', end: '=end'}];
 992 | 							vRemLineTag=['#'];
 993 | 							break;
 994 | 						case 'pigla':
 995 | 							vTags=[
 996 | 								{sTags: sTags_PigLatinKW, sColor: c_sColorKeywords}
 997 | 								, {sTags: sTags_PigLatin, sColor: c_sColorReservedTags3}
 998 | 							];
 999 | 							vRemLineTag=['--'];
1000 | 							break;
1001 | 						case 'bash':
1002 | 							vTags=[
1003 | 								{sTags: sTags_BASH, sColor: c_sColorKeywords}
1004 | 								, {sTags: sTags_BASHBI, sColor: c_sColorReservedTags3}
1005 | 							];
1006 | 							vRemBlockTag=[];
1007 | 							vRemLineTag=['#'];
1008 | 							break;
1009 | 						case 'delphi':
1010 | 							vTags=[
1011 | 								{sTags: sTags_Delphi, sColor: c_sColorKeywords}
1012 | 							];
1013 | 							//vRemBlockTag=[{start: '{', end: '}'}];
1014 | 							vRemBlockTag=[{start: '(*', end: '*)'}, {start: '{', end: '}'}];
1015 | 							break;
1016 | 						case 'pascal':
1017 | 							vTags=[
1018 | 								{sTags: sTags_Pascal, sColor: c_sColorKeywords}
1019 | 							];
1020 | 							//2015.6.15 Pascal has three ways to perform comment, //XXXX, (*XXXX*) and {XXXX};
1021 | 							//Below two lines using array to define two sets of the start and end symbols;
1022 | 							vRemBlockTag=[{start: '(*', end: '*)'}, {start: '{', end: '}'}];
1023 | 							break;
1024 | 						case 'objc':
1025 | 							vTags=[
1026 | 								{sTags: sTags_ObjC, sColor: c_sColorKeywords}
1027 | 								, {sTags: sTags_ObjC_Cocoa, sColor: c_sColorReservedTags3, bRegExp: true}
1028 | 							];
1029 | 							break;
1030 | 						case 'swift':
1031 | 							vTags=[
1032 | 								{sTags: sTags_Swift, sColor: c_sColorKeywords}
1033 | 								, {sTags: sTags_Swift_Lib, sColor: c_sColorReservedTags3, bRegExp: true}
1034 | 							];
1035 | 							break;
1036 | 					}
1037 | 
1038 | 					var sHtml;
1039 | 					{
1040 | 						if(sGenre=='cpp'){
1041 | 							sHtml=_syntax_cpplike(sSrc, vTags, vRemBlockTag, vRemLineTag);
1042 | 						}else if(sGenre=='html'){
1043 | 							//todo ......
1044 | 						}
1045 | 
1046 | 						//2015.6.16 "word-wrap: normal" for source code;
1047 | 						//http://www.w3schools.com/cssref/pr_text_white-space.asp
1048 | 						//http://www.w3schools.com/cssref/css3_pr_word-wrap.asp
1049 | 
1050 | 						var s='';
1051 | 						{
1052 | 							if(sFontName){
1053 | 								if(s) s+=' ';
1054 | 								s+='font-family: '+sFontName+'; ';
1055 | 							}
1056 | 							if(sFontSize){
1057 | 								if(s) s+=' ';
1058 | 								s+='font-size: '+sFontSize+'; ';
1059 | 							}
1060 | 						}
1061 | 
1062 | 						sHtml='
'.replace(/%FONTATTR%/g, s)
1063 | 							+ sHtml
1064 | 							+ '
' 1065 | ; 1066 | } 1067 | 1068 | if(sHtml){ 1069 | if(bWhole){ 1070 | 1071 | if(plugin.selectAllText){ //2015.6.10 requires latest build b-20; 1072 | 1073 | plugin.selectAllText(); 1074 | plugin.replaceSelectedText(-1, sHtml, true); 1075 | 1076 | }else{ 1077 | 1078 | //2015.6.10 setHTML clears the entire DOM including UNDO stack, so it needs to first save if any changes as a history revision for Undoable; 1079 | if(plugin.isContentEditable()) plugin.commitCurrentChanges(); 1080 | 1081 | plugin.setTextContent(-1, sHtml, true); 1082 | plugin.setDomDirty(-1, true); 1083 | 1084 | } 1085 | 1086 | }else{ 1087 | 1088 | plugin.replaceSelectedText(-1, sHtml, true); 1089 | 1090 | } 1091 | } 1092 | } 1093 | 1094 | }else{ 1095 | alert(_lc('Prompt.Warn.NoTextSelected', 'No text is currently selected.')); 1096 | } 1097 | 1098 | }else{ 1099 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 1100 | } 1101 | 1102 | }else{ 1103 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 1104 | } 1105 | }catch(e){ 1106 | alert(e); 1107 | } 1108 | -------------------------------------------------------------------------------- /plugins/WordCount.js: -------------------------------------------------------------------------------- 1 |  2 | //sValidation=nyfjs 3 | //sCaption=Word Count 4 | //sHint=Word Count 02062015 5 | //sCategory=MainMenu.TxtUtils 6 | //sPosition=XZ-255 7 | //sCondition=CURDB; DBRW; CURINFOITEM; HTMLEDIT; HTMLSELECTED 8 | //sID=p.gzhaha.WordCount 9 | //sAppVerMin=7.0 10 | //sShortcutKey= 11 | //sAuthor=Xia Zhang 12 | 13 | ///////////////////////////////////////////////////////////////////// 14 | // Extension scripts for myBase Desktop v7.x 15 | // Copyright 2015 Xia Zhang (MIT Licensed) 16 | ///////////////////////////////////////////////////////////////////// 17 | 18 | var _lc=function(sTag, sDef){return plugin.getLocaleMsg(sTag, sDef);}; 19 | var _lc2=function(sTag, sDef){return _lc(plugin.getLocaleID()+'.'+sTag, sDef);}; 20 | 21 | var _trim=function(s){return (s||'').replace(/^\s+|\s+$/g, '');}; 22 | var _trim_cr=function(s){return (s||'').replace(/\r+$/g, '');}; 23 | 24 | try{ 25 | var xNyf=new CNyfDb(-1); 26 | if(xNyf.isOpen()){ 27 | if(!xNyf.isReadonly()){ 28 | if(plugin.isContentEditable()){ 29 | //get selected text 30 | var sCon = plugin.getSelectedText(-1, false); 31 | 32 | //run function 33 | var html = fnWordCount(sCon); 34 | 35 | alert('Words Count:' + html + ' words') 36 | }else{ 37 | alert(_lc('Prompt.Warn.ReadonlyContent', 'Cannot modify the content opened as Readonly.')); 38 | } 39 | }else{ 40 | alert(_lc('Prompt.Warn.ReadonlyDb', 'Cannot modify the database opened as Readonly.')); 41 | } 42 | }else{ 43 | alert(_lc('Prompt.Warn.NoDbOpened', 'No database is currently opened.')); 44 | } 45 | }catch(e){ 46 | alert(e); 47 | } 48 | 49 | //Words Count: 50 | //http://blog.csdn.net/gavid0124/article/details/38117381 51 | function fnWordCount(str){ 52 | sLen = 0; 53 | try{ 54 | str = str.replace(/(\r\n+|\s+| +)/g,"龘"); 55 | str = str.replace(/[\x00-\xff]/g,"m"); 56 | str = str.replace(/m+/g,"*"); 57 | str = str.replace(/龘+/g,""); 58 | sLen = str.length; 59 | }catch(e){ 60 | 61 | } 62 | return sLen; 63 | } 64 | --------------------------------------------------------------------------------