From 88407e6882fcb21efa1a491b443fb4186f199318 Mon Sep 17 00:00:00 2001 From: jesselau76 Date: Wed, 9 Jan 2019 13:17:23 +1300 Subject: go highlight --- layouts/_default/baseof.html | 15 +++++++++++---- static/js/w3codecolor-min.js | 2 +- static/js/w3codecolor.js | 45 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 763dcea..232fac1 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -70,6 +70,12 @@ var x = document.getElementsByTagName("BODY")[0]; function checkCookie() { var user=getCookie("cookiebardisplayed"); if (user == "") { + setCookie("cookiebardisplayed","0",365);} + + user=getCookie("cookiebardisplayed"); + if (user =="0") + { + var x =document.getElementById("cookiebar"); x.style.display = "block"; var h = document.getElementById('cookiebar').clientHeight; @@ -78,6 +84,7 @@ function checkCookie() { x.style.paddingTop = h+"px"; setCookie("cookiebardisplayed","1",365); } + } function setCookie(cname,cvalue,exdays) { var d = new Date(); @@ -101,11 +108,10 @@ function getCookie(cname) { } return ""; } - document.addEventListener('DOMContentLoaded', function() { - checkCookie(); -}, false); - + checkCookie(); +}, false); + {{ end }} @@ -200,6 +206,7 @@ function scrollFunction() { x.style.display = "none"; var x = document.getElementsByTagName("BODY")[0]; x.style.paddingTop = "0px"; + } {{ end }} diff --git a/static/js/w3codecolor-min.js b/static/js/w3codecolor-min.js index 7f295a2..c46f57d 100644 --- a/static/js/w3codecolor-min.js +++ b/static/js/w3codecolor-min.js @@ -1 +1 @@ -function w3CodeColor(){var x,i,j,k,l,modes = ["html","js","java","css","sql","python","bash"];if (!document.getElementsByClassName){return}k = modes.length;for (j = 0;j < k;j++){x = document.getElementsByClassName(modes[j] + "High");l = x.length;for (i = 0;i < l;i++){x[i].innerHTML = w3CodeColorize(x[i].innerHTML,modes[j])}}}function w3CodeColorize(x,lang){var tagcolor = "mediumblue";var tagnamecolor = "brown";var attributecolor = "red";var attributevaluecolor = "mediumblue";var commentcolor = "green";var cssselectorcolor = "brown";var csspropertycolor = "red";var csspropertyvaluecolor = "mediumblue";var cssdelimitercolor = "black";var cssimportantcolor = "red";var jscolor = "black";var jskeywordcolor = "mediumblue";var jsstringcolor = "brown";var jsnumbercolor = "red";var jspropertycolor = "black";var javacolor = "black";var javakeywordcolor = "mediumblue";var javastringcolor = "brown";var javanumbercolor = "red";var javapropertycolor = "black";var phptagcolor = "red";var phpcolor = "black";var phpkeywordcolor = "mediumblue";var phpglobalcolor = "goldenrod";var phpstringcolor = "brown";var phpnumbercolor = "red";var pythoncolor = "black";var pythonkeywordcolor = "mediumblue";var pythonstringcolor = "brown";var pythonnumbercolor = "red";var angularstatementcolor = "red";var sqlcolor = "black";var sqlkeywordcolor = "mediumblue";var sqlstringcolor = "brown";var sqlnumbercolor = "";var bashcolor = "black";var bashkeywordcolor = "mediumblue";var bashstringcolor = "brown";var bashnumbercolor = "red";if (!lang){lang = "html"}if (lang == "html"){return htmlMode(x)}if (lang == "css"){return cssMode(x)}if (lang == "js"){return jsMode(x)}if (lang == "java"){return javaMode(x)}if (lang == "php"){return phpMode(x)}if (lang == "sql"){return sqlMode(x)}if (lang == "python"){return pythonMode(x)}if (lang == "bash"){return bashMode(x)}return x;function extract(str,start,end,func,repl){var s,e,d = "",a = [];while (str.search(start) > -1){s = str.search(start);e = str.indexOf(end,s);if (e == -1){e = str.length}if (repl){a.push(func(str.substring(s,e + (end.length))));str = str.substring(0,s) + repl + str.substr(e + (end.length))}else{d += str.substring(0,s);d += func(str.substring(s,e + (end.length)));str = str.substr(e + (end.length))}}this.rest = d + str;this.arr = a}function htmlMode(txt){var rest = txt,done = "",php,comment,angular,startpos,endpos,note,i;php = new extract(rest,"<\\?php","?>",phpMode,"W3PHPPOS");rest = php.rest;comment = new extract(rest,"<!--","-->",commentMode,"W3HTMLCOMMENTPOS");rest = comment.rest;while (rest.indexOf("<") > -1){note = "";startpos = rest.indexOf("<");if (rest.substr(startpos,9).toUpperCase() == "<STYLE"){note = "css"}if (rest.substr(startpos,10).toUpperCase() == "<SCRIPT"){note = "javascript"}endpos = rest.indexOf(">",startpos);if (endpos == -1){endpos = rest.length}done += rest.substring(0,startpos);done += tagMode(rest.substring(startpos,endpos + 4));rest = rest.substr(endpos + 4);if (note == "css"){endpos = rest.indexOf("</style>");if (endpos > -1){done += cssMode(rest.substring(0,endpos));rest = rest.substr(endpos)}}if (note == "javascript"){endpos = rest.indexOf("</script>");if (endpos > -1){done += jsMode(rest.substring(0,endpos));rest = rest.substr(endpos)}}}rest = done + rest;angular = new extract(rest,"{{","}}",angularMode);rest = angular.rest;for (i = 0;i < comment.arr.length;i++){rest = rest.replace("W3HTMLCOMMENTPOS",comment.arr[i])}for (i = 0;i < php.arr.length;i++){rest = rest.replace("W3PHPPOS",php.arr[i])}return rest}function tagMode(txt){var rest = txt,done = "",startpos,endpos,result;while (rest.search(/(\s|
)/) > -1){startpos = rest.search(/(\s|
)/);endpos = rest.indexOf(">");if (endpos == -1){endpos = rest.length}done += rest.substring(0,startpos);done += attributeMode(rest.substring(startpos,endpos));rest = rest.substr(endpos)}result = done + rest;result = "<" + result.substring(4);if (result.substr(result.length - 4,4) == ">"){result = result.substring(0,result.length - 4) + ">"}return "" + result + ""}function attributeMode(txt){var rest = txt,done = "",startpos,endpos,singlefnuttpos,doublefnuttpos,spacepos;while (rest.indexOf("=") > -1){endpos = -1;startpos = rest.indexOf("=");singlefnuttpos = rest.indexOf("'",startpos);doublefnuttpos = rest.indexOf('"',startpos);spacepos = rest.indexOf(" ",startpos + 2);if (spacepos > -1 && (spacepos < singlefnuttpos || singlefnuttpos == -1) && (spacepos < doublefnuttpos || doublefnuttpos == -1)){endpos = rest.indexOf(" ",startpos)}else if (doublefnuttpos > -1 && (doublefnuttpos < singlefnuttpos || singlefnuttpos == -1) && (doublefnuttpos < spacepos || spacepos == -1)){endpos = rest.indexOf('"',rest.indexOf('"',startpos) + 1)}else if (singlefnuttpos > -1 && (singlefnuttpos < doublefnuttpos || doublefnuttpos == -1) && (singlefnuttpos < spacepos || spacepos == -1)){endpos = rest.indexOf("'",rest.indexOf("'",startpos) + 1)}if (!endpos || endpos == -1 || endpos < startpos){endpos = rest.length}done += rest.substring(0,startpos);done += attributeValueMode(rest.substring(startpos,endpos + 1));rest = rest.substr(endpos + 1)}return "" + done + rest + ""}function attributeValueMode(txt){return "" + txt + ""}function angularMode(txt){return "" + txt + ""}function commentMode(txt){return "" + txt + ""}function cssMode(txt){var rest = txt,done = "",s,e,comment,i,midz,c,cc;comment = new extract(rest,/\/\*/,"*/",commentMode,"W3CSSCOMMENTPOS");rest = comment.rest;while (rest.search("{") > -1){s = rest.search("{");midz = rest.substr(s + 1);cc = 1;c = 0;for (i = 0;i < midz.length;i++){if (midz.substr(i,1) == "{"){cc++;c++}if (midz.substr(i,1) == "}"){cc--}if (cc == 0){break}}if (cc != 0){c = 0}e = s;for (i = 0;i <= c;i++){e = rest.indexOf("}",e + 1)}if (e == -1){e = rest.length}done += rest.substring(0,s + 1);done += cssPropertyMode(rest.substring(s + 1,e));rest = rest.substr(e)}rest = done + rest;rest = rest.replace(/{/g,"{");rest = rest.replace(/}/g,"}");for (i = 0;i < comment.arr.length;i++){rest = rest.replace("W3CSSCOMMENTPOS",comment.arr[i])}return "" + rest + ""}function cssPropertyMode(txt){var rest = txt,done = "",s,e,n,loop;if (rest.indexOf("{") > -1 ){return cssMode(rest)}while (rest.search(":") > -1){s = rest.search(":");loop = true;n = s;while (loop == true){loop = false;e = rest.indexOf(";",n);if (rest.substring(e - 5,e + 1) == " "){loop = true;n = e + 1}}if (e == -1){e = rest.length}done += rest.substring(0,s);done += cssPropertyValueMode(rest.substring(s,e + 1));rest = rest.substr(e + 1)}return "" + done + rest + ""}function cssPropertyValueMode(txt){var rest = txt,done = "",s;rest = ":" + rest.substring(1);while (rest.search(/!important/i) > -1){s = rest.search(/!important/i);done += rest.substring(0,s);done += cssImportantMode(rest.substring(s,s + 10));rest = rest.substr(s + 10)}result = done + rest;if (result.substr(result.length - 1,1) == ";" && result.substr(result.length - 6,6) != " " && result.substr(result.length - 4,4) != "<" && result.substr(result.length - 4,4) != ">" && result.substr(result.length - 5,5) != "&"){result = result.substring(0,result.length - 1) + ";"}return "" + result + ""}function cssImportantMode(txt){return "" + txt + ""}function jsMode(txt){var rest = txt,done = "",esc = [],i,cc,tt = "",sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,numpos,mypos,dotpos,y;for (i = 0;i < rest.length;i++){cc = rest.substr(i,1);if (cc == "\\"){esc.push(rest.substr(i,2));cc = "W3JSESCAPE";i++}tt += cc}rest = tt;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",jsStringMode);dfnuttpos = getPos(rest,'"','"',jsStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);numpos = getNumPos(rest,jsNumberMode);keywordpos = getKeywordPos("js",rest,jsKeywordMode);dotpos = getDotPos(rest,jsPropertyMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],keywordpos[0],dotpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,dotpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;for (i = 0;i < esc.length;i++){rest = rest.replace("W3JSESCAPE",esc[i])}return "" + rest + ""}function jsStringMode(txt){return "" + txt + ""}function jsKeywordMode(txt){return "" + txt + ""}function jsNumberMode(txt){return "" + txt + ""}function jsPropertyMode(txt){return "" + txt + ""}function getDotPos(txt,func){var x,i,j,s,e,arr = [".","<"," ",";","(","+",")","[","]",",","&",":","{","}","/","-","*","|","%"];s = txt.indexOf(".");if (s > -1){x = txt.substr(s + 1);for (j = 0;j < x.length;j++){cc = x[j];for (i = 0;i < arr.length;i++){if (cc.indexOf(arr[i]) > -1){e = j;return [s + 1,e + s + 1,func]}}}}return [-1,-1,func]}function getMinPos(){var i,arr = [];for (i = 0;i < arguments.length;i++){if (arguments[i][0] > -1){if (arr.length == 0 || arguments[i][0] < arr[0]){arr = arguments[i]}}}if (arr.length == 0){arr = arguments[i]}return arr}function javaMode(txt){var rest = txt,done = "",esc = [],i,cc,tt = "",sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,numpos,mypos,dotpos,y;for (i = 0;i < rest.length;i++){cc = rest.substr(i,1);if (cc == "\\"){esc.push(rest.substr(i,2));cc = "W3JSESCAPE";i++}tt += cc}rest = tt;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",javaStringMode);dfnuttpos = getPos(rest,'"','"',javaStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);numpos = getNumPos(rest,javaNumberMode);keywordpos = getKeywordPos("java",rest,javaKeywordMode);dotpos = getDotPos(rest,javaPropertyMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],keywordpos[0],dotpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,dotpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;for (i = 0;i < esc.length;i++){rest = rest.replace("W3JSESCAPE",esc[i])}return "" + rest + ""}function javaStringMode(txt){return "" + txt + ""}function javaKeywordMode(txt){return "" + txt + ""}function javaNumberMode(txt){return "" + txt + ""}function javaPropertyMode(txt){return "" + txt + ""}function sqlMode(txt){var rest = txt,y,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,numpos,mypos;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",sqlStringMode);dfnuttpos = getPos(rest,'"','"',sqlStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/--/,"
",commentMode);numpos = getNumPos(rest,sqlNumberMode);keywordpos = getKeywordPos("sql",rest,sqlKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function sqlStringMode(txt){return "" + txt + ""}function sqlKeywordMode(txt){return "" + txt + ""}function sqlNumberMode(txt){return "" + txt + ""}function phpMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",phpStringMode);dfnuttpos = getPos(rest,'"','"',phpStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,phpNumberMode);keywordpos = getKeywordPos("php",rest,phpKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;rest = "<" + rest.substr(4,4) + "" + rest.substring(8);if (rest.substr(rest.length - 5,5) == "?>"){rest = rest.substring(0,rest.length - 5) + "?>"}return "" + rest + ""}function phpStringMode(txt){return "" + txt + ""}function phpNumberMode(txt){return "" + txt + ""}function phpKeywordMode(txt){var glb = ["$GLOBALS","$_SERVER","$_REQUEST","$_POST","$_GET","$_FILES","$_ENV","$_COOKIE","$_SESSION"];if (glb.indexOf(txt.toUpperCase()) > -1){if (glb.indexOf(txt) > -1){return "" + txt + ""}else{return txt}}else{return "" + txt + ""}}function pythonMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",pythonStringMode);dfnuttpos = getPos(rest,'"','"',pythonStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,pythonNumberMode);keywordpos = getKeywordPos("python",rest,pythonKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function pythonStringMode(txt){return "" + txt + ""}function pythonNumberMode(txt){return "" + txt + ""}function pythonKeywordMode(txt){return "" + txt + ""}function bashMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",bashStringMode);dfnuttpos = getPos(rest,'"','"',bashStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,bashNumberMode);keywordpos = getKeywordPos("bash",rest,bashKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function bashStringMode(txt){return "" + txt + ""}function bashNumberMode(txt){return "" + txt + ""}function bashKeywordMode(txt){return "" + txt + ""}function getKeywordPos(typ,txt,func){var words,i,pos,rpos = -1,rpos2 = -1,patt;if (typ == "js"){words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","eval","event","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]}else if (typ == "java"){words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","eval","event","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield","String"]}else if (typ == "php"){words = ["$GLOBALS","$_SERVER","$_REQUEST","$_POST","$_GET","$_FILES","$_ENV","$_COOKIE","$_SESSION","__halt_compiler","abstract","and","array","as","break","callable","case","catch","class","clone","const","continue","declare","default","die","do","echo","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","eval","exit","extends","final","for","foreach","function","global","goto","if","implements","include","include_once","instanceof","insteadof","interface","isset","list","namespace","new","or","print","private","protected","public","require","require_once","return","static","switch","throw","trait","try","unset","use","var","while","xor"]}else if (typ == "sql"){words = ["ADD","EXTERNAL","PROCEDURE","ALL","FETCH","PUBLIC","ALTER","FILE","RAISERROR","AND","FILLFACTOR","READ","ANY","READTEXT","AS","FOREIGN","RECONFIGURE","ASC","FREETEXT","REFERENCES","AUTHORIZATION","FREETEXTTABLE","REPLICATION","BACKUP","FROM","RESTORE","BEGIN","FULL","RESTRICT","BETWEEN","FUNCTION","RETURN","BREAK","GOTO","REVERT","BROWSE","GRANT","REVOKE","BULK","GROUP","RIGHT","BY","HAVING","ROLLBACK","CASCADE","HOLDLOCK","ROWCOUNT","CASE","IDENTITY","ROWGUIDCOL","CHECK","IDENTITY_INSERT","RULE","CHECKPOINT","IDENTITYCOL","SAVE","CLOSE","IF","SCHEMA","CLUSTERED","IN","SECURITYAUDIT","COALESCE","INDEX","SELECT","COLLATE","INNER","SEMANTICKEYPHRASETABLE","COLUMN","INSERT","SEMANTICSIMILARITYDETAILSTABLE","COMMIT","INTERSECT","SEMANTICSIMILARITYTABLE","COMPUTE","INTO","SESSION_USER","CONSTRAINT","IS","SET","CONTAINS","JOIN","SETUSER","CONTAINSTABLE","KEY","SHUTDOWN","CONTINUE","KILL","SOME","CONVERT","LEFT","STATISTICS","CREATE","LIKE","SYSTEM_USER","CROSS","LINENO","TABLE","CURRENT","LOAD","TABLESAMPLE","CURRENT_DATE","MERGE","TEXTSIZE","CURRENT_TIME","NATIONAL","THEN","CURRENT_TIMESTAMP","NOCHECK","TO","CURRENT_USER","NONCLUSTERED","TOP","CURSOR","NOT","TRAN","DATABASE","NULL","TRANSACTION","DBCC","NULLIF","TRIGGER","DEALLOCATE","OF","TRUNCATE","DECLARE","OFF","TRY_CONVERT","DEFAULT","OFFSETS","TSEQUAL","DELETE","ON","UNION","DENY","OPEN","UNIQUE","DESC","OPENDATASOURCE","UNPIVOT","DISK","OPENQUERY","UPDATE","DISTINCT","OPENROWSET","UPDATETEXT","DISTRIBUTED","OPENXML","USE","DOUBLE","OPTION","USER","DROP","OR","VALUES","DUMP","ORDER","VARYING","ELSE","OUTER","VIEW","END","OVER","WAITFOR","ERRLVL","PERCENT","WHEN","ESCAPE","PIVOT","WHERE","EXCEPT","PLAN","WHILE","EXEC","PRECISION","WITH","EXECUTE","PRIMARY","WITHIN GROUP","EXISTS","PRINT","WRITETEXT","EXIT","PROC","LIMIT","MODIFY","COUNT","REPLACE"]}else if (typ == "python"){words = ["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield","in","abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"]}else if (typ == "bash"){words = ["sudo","git","hugo","cd","rm","mkdir","delete","find","ssh","scp","nano","server","root","nginx","rsync","bash","chmod","echo","print","apt-get","ls","which","touch","python","go","php","chown","du","dhclient","journalctl","systemctl","service","tar","zip","unzip","cp","mv","curl","wget","dpkg","pip","install","pip3","mysql"];}for (i = 0;i < words.length;i++){if (typ == "php" || typ == "sql"){pos = txt.toLowerCase().indexOf(words[i].toLowerCase())}else{pos = txt.indexOf(words[i])}if (pos > -1){patt = /\W/g;if (txt.substr(pos + words[i].length,1).match(patt) && txt.substr(pos - 1,1).match(patt)){if (pos > -1 && (rpos == -1 || pos < rpos)){rpos = pos;rpos2 = rpos + words[i].length}}}}return [rpos,rpos2,func]}function getPos(txt,start,end,func){var s,e;s = txt.search(start);e = txt.indexOf(end,s + (end.length));if (e == -1){e = txt.length}return [s,e + (end.length),func]}function getNumPos(txt,func){var arr = ["
"," ",";","(","+",")","[","]",",","&",":","{","}","/","-","*","|","%","="],i,j,c,startpos = 0,endpos,word;for (i = 0;i < txt.length;i++){for (j = 0;j < arr.length;j++){c = txt.substr(i,arr[j].length);if (c == arr[j]){if (c == "-" && (txt.substr(i - 1,1) == "e" || txt.substr(i - 1,1) == "E")){continue}endpos = i;if (startpos < endpos){word = txt.substring(startpos,endpos);if (!isNaN(word)){return [startpos,endpos,func]}}i += arr[j].length;startpos = i;i -= 1;break}}}return [-1,-1,func]}} \ No newline at end of file +function w3CodeColor(){var x,i,j,k,l,modes = ["html","js","java","css","sql","python","bash","go"];if (!document.getElementsByClassName){return}k = modes.length;for (j = 0;j < k;j++){x = document.getElementsByClassName(modes[j] + "High");l = x.length;for (i = 0;i < l;i++){x[i].innerHTML = w3CodeColorize(x[i].innerHTML,modes[j])}}}function w3CodeColorize(x,lang){var tagcolor = "mediumblue";var tagnamecolor = "brown";var attributecolor = "red";var attributevaluecolor = "mediumblue";var commentcolor = "green";var cssselectorcolor = "brown";var csspropertycolor = "red";var csspropertyvaluecolor = "mediumblue";var cssdelimitercolor = "black";var cssimportantcolor = "red";var jscolor = "black";var jskeywordcolor = "mediumblue";var jsstringcolor = "brown";var jsnumbercolor = "red";var jspropertycolor = "black";var javacolor = "black";var javakeywordcolor = "mediumblue";var javastringcolor = "brown";var javanumbercolor = "red";var javapropertycolor = "black";var phptagcolor = "red";var phpcolor = "black";var phpkeywordcolor = "mediumblue";var phpglobalcolor = "goldenrod";var phpstringcolor = "brown";var phpnumbercolor = "red";var pythoncolor = "black";var pythonkeywordcolor = "mediumblue";var pythonstringcolor = "brown";var pythonnumbercolor = "red";var angularstatementcolor = "red";var sqlcolor = "black";var sqlkeywordcolor = "mediumblue";var sqlstringcolor = "brown";var sqlnumbercolor = "";var bashcolor = "black";var bashkeywordcolor = "mediumblue";var bashstringcolor = "brown";var bashnumbercolor = "red";var gocolor = "black";var gokeywordcolor = "mediumblue";var gostringcolor = "brown";var gonumbercolor = "red";if (!lang){lang = "html"}if (lang == "html"){return htmlMode(x)}if (lang == "css"){return cssMode(x)}if (lang == "js"){return jsMode(x)}if (lang == "java"){return javaMode(x)}if (lang == "php"){return phpMode(x)}if (lang == "sql"){return sqlMode(x)}if (lang == "python"){return pythonMode(x)}if (lang == "bash"){return bashMode(x)}if (lang == "go"){return goMode(x)}return x;function extract(str,start,end,func,repl){var s,e,d = "",a = [];while (str.search(start) > -1){s = str.search(start);e = str.indexOf(end,s);if (e == -1){e = str.length}if (repl){a.push(func(str.substring(s,e + (end.length))));str = str.substring(0,s) + repl + str.substr(e + (end.length))}else{d += str.substring(0,s);d += func(str.substring(s,e + (end.length)));str = str.substr(e + (end.length))}}this.rest = d + str;this.arr = a}function htmlMode(txt){var rest = txt,done = "",php,comment,angular,startpos,endpos,note,i;php = new extract(rest,"<\\?php","?>",phpMode,"W3PHPPOS");rest = php.rest;comment = new extract(rest,"<!--","-->",commentMode,"W3HTMLCOMMENTPOS");rest = comment.rest;while (rest.indexOf("<") > -1){note = "";startpos = rest.indexOf("<");if (rest.substr(startpos,9).toUpperCase() == "<STYLE"){note = "css"}if (rest.substr(startpos,10).toUpperCase() == "<SCRIPT"){note = "javascript"}endpos = rest.indexOf(">",startpos);if (endpos == -1){endpos = rest.length}done += rest.substring(0,startpos);done += tagMode(rest.substring(startpos,endpos + 4));rest = rest.substr(endpos + 4);if (note == "css"){endpos = rest.indexOf("</style>");if (endpos > -1){done += cssMode(rest.substring(0,endpos));rest = rest.substr(endpos)}}if (note == "javascript"){endpos = rest.indexOf("</script>");if (endpos > -1){done += jsMode(rest.substring(0,endpos));rest = rest.substr(endpos)}}}rest = done + rest;angular = new extract(rest,"{{","}}",angularMode);rest = angular.rest;for (i = 0;i < comment.arr.length;i++){rest = rest.replace("W3HTMLCOMMENTPOS",comment.arr[i])}for (i = 0;i < php.arr.length;i++){rest = rest.replace("W3PHPPOS",php.arr[i])}return rest}function tagMode(txt){var rest = txt,done = "",startpos,endpos,result;while (rest.search(/(\s|
)/) > -1){startpos = rest.search(/(\s|
)/);endpos = rest.indexOf(">");if (endpos == -1){endpos = rest.length}done += rest.substring(0,startpos);done += attributeMode(rest.substring(startpos,endpos));rest = rest.substr(endpos)}result = done + rest;result = "<" + result.substring(4);if (result.substr(result.length - 4,4) == ">"){result = result.substring(0,result.length - 4) + ">"}return "" + result + ""}function attributeMode(txt){var rest = txt,done = "",startpos,endpos,singlefnuttpos,doublefnuttpos,spacepos;while (rest.indexOf("=") > -1){endpos = -1;startpos = rest.indexOf("=");singlefnuttpos = rest.indexOf("'",startpos);doublefnuttpos = rest.indexOf('"',startpos);spacepos = rest.indexOf(" ",startpos + 2);if (spacepos > -1 && (spacepos < singlefnuttpos || singlefnuttpos == -1) && (spacepos < doublefnuttpos || doublefnuttpos == -1)){endpos = rest.indexOf(" ",startpos)}else if (doublefnuttpos > -1 && (doublefnuttpos < singlefnuttpos || singlefnuttpos == -1) && (doublefnuttpos < spacepos || spacepos == -1)){endpos = rest.indexOf('"',rest.indexOf('"',startpos) + 1)}else if (singlefnuttpos > -1 && (singlefnuttpos < doublefnuttpos || doublefnuttpos == -1) && (singlefnuttpos < spacepos || spacepos == -1)){endpos = rest.indexOf("'",rest.indexOf("'",startpos) + 1)}if (!endpos || endpos == -1 || endpos < startpos){endpos = rest.length}done += rest.substring(0,startpos);done += attributeValueMode(rest.substring(startpos,endpos + 1));rest = rest.substr(endpos + 1)}return "" + done + rest + ""}function attributeValueMode(txt){return "" + txt + ""}function angularMode(txt){return "" + txt + ""}function commentMode(txt){return "" + txt + ""}function cssMode(txt){var rest = txt,done = "",s,e,comment,i,midz,c,cc;comment = new extract(rest,/\/\*/,"*/",commentMode,"W3CSSCOMMENTPOS");rest = comment.rest;while (rest.search("{") > -1){s = rest.search("{");midz = rest.substr(s + 1);cc = 1;c = 0;for (i = 0;i < midz.length;i++){if (midz.substr(i,1) == "{"){cc++;c++}if (midz.substr(i,1) == "}"){cc--}if (cc == 0){break}}if (cc != 0){c = 0}e = s;for (i = 0;i <= c;i++){e = rest.indexOf("}",e + 1)}if (e == -1){e = rest.length}done += rest.substring(0,s + 1);done += cssPropertyMode(rest.substring(s + 1,e));rest = rest.substr(e)}rest = done + rest;rest = rest.replace(/{/g,"{");rest = rest.replace(/}/g,"}");for (i = 0;i < comment.arr.length;i++){rest = rest.replace("W3CSSCOMMENTPOS",comment.arr[i])}return "" + rest + ""}function cssPropertyMode(txt){var rest = txt,done = "",s,e,n,loop;if (rest.indexOf("{") > -1 ){return cssMode(rest)}while (rest.search(":") > -1){s = rest.search(":");loop = true;n = s;while (loop == true){loop = false;e = rest.indexOf(";",n);if (rest.substring(e - 5,e + 1) == " "){loop = true;n = e + 1}}if (e == -1){e = rest.length}done += rest.substring(0,s);done += cssPropertyValueMode(rest.substring(s,e + 1));rest = rest.substr(e + 1)}return "" + done + rest + ""}function cssPropertyValueMode(txt){var rest = txt,done = "",s;rest = ":" + rest.substring(1);while (rest.search(/!important/i) > -1){s = rest.search(/!important/i);done += rest.substring(0,s);done += cssImportantMode(rest.substring(s,s + 10));rest = rest.substr(s + 10)}result = done + rest;if (result.substr(result.length - 1,1) == ";" && result.substr(result.length - 6,6) != " " && result.substr(result.length - 4,4) != "<" && result.substr(result.length - 4,4) != ">" && result.substr(result.length - 5,5) != "&"){result = result.substring(0,result.length - 1) + ";"}return "" + result + ""}function cssImportantMode(txt){return "" + txt + ""}function jsMode(txt){var rest = txt,done = "",esc = [],i,cc,tt = "",sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,numpos,mypos,dotpos,y;for (i = 0;i < rest.length;i++){cc = rest.substr(i,1);if (cc == "\\"){esc.push(rest.substr(i,2));cc = "W3JSESCAPE";i++}tt += cc}rest = tt;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",jsStringMode);dfnuttpos = getPos(rest,'"','"',jsStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);numpos = getNumPos(rest,jsNumberMode);keywordpos = getKeywordPos("js",rest,jsKeywordMode);dotpos = getDotPos(rest,jsPropertyMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],keywordpos[0],dotpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,dotpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;for (i = 0;i < esc.length;i++){rest = rest.replace("W3JSESCAPE",esc[i])}return "" + rest + ""}function jsStringMode(txt){return "" + txt + ""}function jsKeywordMode(txt){return "" + txt + ""}function jsNumberMode(txt){return "" + txt + ""}function jsPropertyMode(txt){return "" + txt + ""}function getDotPos(txt,func){var x,i,j,s,e,arr = [".","<"," ",";","(","+",")","[","]",",","&",":","{","}","/","-","*","|","%"];s = txt.indexOf(".");if (s > -1){x = txt.substr(s + 1);for (j = 0;j < x.length;j++){cc = x[j];for (i = 0;i < arr.length;i++){if (cc.indexOf(arr[i]) > -1){e = j;return [s + 1,e + s + 1,func]}}}}return [-1,-1,func]}function getMinPos(){var i,arr = [];for (i = 0;i < arguments.length;i++){if (arguments[i][0] > -1){if (arr.length == 0 || arguments[i][0] < arr[0]){arr = arguments[i]}}}if (arr.length == 0){arr = arguments[i]}return arr}function javaMode(txt){var rest = txt,done = "",esc = [],i,cc,tt = "",sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,numpos,mypos,dotpos,y;for (i = 0;i < rest.length;i++){cc = rest.substr(i,1);if (cc == "\\"){esc.push(rest.substr(i,2));cc = "W3JSESCAPE";i++}tt += cc}rest = tt;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",javaStringMode);dfnuttpos = getPos(rest,'"','"',javaStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);numpos = getNumPos(rest,javaNumberMode);keywordpos = getKeywordPos("java",rest,javaKeywordMode);dotpos = getDotPos(rest,javaPropertyMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],keywordpos[0],dotpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,dotpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;for (i = 0;i < esc.length;i++){rest = rest.replace("W3JSESCAPE",esc[i])}return "" + rest + ""}function javaStringMode(txt){return "" + txt + ""}function javaKeywordMode(txt){return "" + txt + ""}function javaNumberMode(txt){return "" + txt + ""}function javaPropertyMode(txt){return "" + txt + ""}function sqlMode(txt){var rest = txt,y,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos,numpos,mypos;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",sqlStringMode);dfnuttpos = getPos(rest,'"','"',sqlStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/--/,"
",commentMode);numpos = getNumPos(rest,sqlNumberMode);keywordpos = getKeywordPos("sql",rest,sqlKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function sqlStringMode(txt){return "" + txt + ""}function sqlKeywordMode(txt){return "" + txt + ""}function sqlNumberMode(txt){return "" + txt + ""}function phpMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",phpStringMode);dfnuttpos = getPos(rest,'"','"',phpStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,phpNumberMode);keywordpos = getKeywordPos("php",rest,phpKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;rest = "<" + rest.substr(4,4) + "" + rest.substring(8);if (rest.substr(rest.length - 5,5) == "?>"){rest = rest.substring(0,rest.length - 5) + "?>"}return "" + rest + ""}function phpStringMode(txt){return "" + txt + ""}function phpNumberMode(txt){return "" + txt + ""}function phpKeywordMode(txt){var glb = ["$GLOBALS","$_SERVER","$_REQUEST","$_POST","$_GET","$_FILES","$_ENV","$_COOKIE","$_SESSION"];if (glb.indexOf(txt.toUpperCase()) > -1){if (glb.indexOf(txt) > -1){return "" + txt + ""}else{return txt}}else{return "" + txt + ""}}function pythonMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",pythonStringMode);dfnuttpos = getPos(rest,'"','"',pythonStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,pythonNumberMode);keywordpos = getKeywordPos("python",rest,pythonKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function pythonStringMode(txt){return "" + txt + ""}function pythonNumberMode(txt){return "" + txt + ""}function pythonKeywordMode(txt){return "" + txt + ""}function bashMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",bashStringMode);dfnuttpos = getPos(rest,'"','"',bashStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,bashNumberMode);keywordpos = getKeywordPos("bash",rest,bashKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function bashStringMode(txt){return "" + txt + ""}function bashNumberMode(txt){return "" + txt + ""}function bashKeywordMode(txt){return "" + txt + ""}function goMode(txt){var rest = txt,done = "",sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos,mypos,y;y = 1;while (y == 1){sfnuttpos = getPos(rest,"'","'",goStringMode);dfnuttpos = getPos(rest,'"','"',goStringMode);compos = getPos(rest,/\/\*/,"*/",commentMode);comlinepos = getPos(rest,/\/\//,"
",commentMode);comhashpos = getPos(rest,"#","
",commentMode);numpos = getNumPos(rest,goNumberMode);keywordpos = getKeywordPos("go",rest,goKeywordMode);if (Math.max(numpos[0],sfnuttpos[0],dfnuttpos[0],compos[0],comlinepos[0],comhashpos[0],keywordpos[0]) == -1){break}mypos = getMinPos(numpos,sfnuttpos,dfnuttpos,compos,comlinepos,comhashpos,keywordpos);if (mypos[0] == -1){break}if (mypos[0] > -1){done += rest.substring(0,mypos[0]);done += mypos[2](rest.substring(mypos[0],mypos[1]));rest = rest.substr(mypos[1])}}rest = done + rest;return "" + rest + ""}function goStringMode(txt){return "" + txt + ""}function goNumberMode(txt){return "" + txt + ""}function goKeywordMode(txt){return "" + txt + ""}function getKeywordPos(typ,txt,func){var words,i,pos,rpos = -1,rpos2 = -1,patt;if (typ == "js"){words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","eval","event","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]}else if (typ == "java"){words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","eval","event","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield","String"]}else if (typ == "php"){words = ["$GLOBALS","$_SERVER","$_REQUEST","$_POST","$_GET","$_FILES","$_ENV","$_COOKIE","$_SESSION","__halt_compiler","abstract","and","array","as","break","callable","case","catch","class","clone","const","continue","declare","default","die","do","echo","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","eval","exit","extends","final","for","foreach","function","global","goto","if","implements","include","include_once","instanceof","insteadof","interface","isset","list","namespace","new","or","print","private","protected","public","require","require_once","return","static","switch","throw","trait","try","unset","use","var","while","xor"]}else if (typ == "sql"){words = ["ADD","EXTERNAL","PROCEDURE","ALL","FETCH","PUBLIC","ALTER","FILE","RAISERROR","AND","FILLFACTOR","READ","ANY","READTEXT","AS","FOREIGN","RECONFIGURE","ASC","FREETEXT","REFERENCES","AUTHORIZATION","FREETEXTTABLE","REPLICATION","BACKUP","FROM","RESTORE","BEGIN","FULL","RESTRICT","BETWEEN","FUNCTION","RETURN","BREAK","GOTO","REVERT","BROWSE","GRANT","REVOKE","BULK","GROUP","RIGHT","BY","HAVING","ROLLBACK","CASCADE","HOLDLOCK","ROWCOUNT","CASE","IDENTITY","ROWGUIDCOL","CHECK","IDENTITY_INSERT","RULE","CHECKPOINT","IDENTITYCOL","SAVE","CLOSE","IF","SCHEMA","CLUSTERED","IN","SECURITYAUDIT","COALESCE","INDEX","SELECT","COLLATE","INNER","SEMANTICKEYPHRASETABLE","COLUMN","INSERT","SEMANTICSIMILARITYDETAILSTABLE","COMMIT","INTERSECT","SEMANTICSIMILARITYTABLE","COMPUTE","INTO","SESSION_USER","CONSTRAINT","IS","SET","CONTAINS","JOIN","SETUSER","CONTAINSTABLE","KEY","SHUTDOWN","CONTINUE","KILL","SOME","CONVERT","LEFT","STATISTICS","CREATE","LIKE","SYSTEM_USER","CROSS","LINENO","TABLE","CURRENT","LOAD","TABLESAMPLE","CURRENT_DATE","MERGE","TEXTSIZE","CURRENT_TIME","NATIONAL","THEN","CURRENT_TIMESTAMP","NOCHECK","TO","CURRENT_USER","NONCLUSTERED","TOP","CURSOR","NOT","TRAN","DATABASE","NULL","TRANSACTION","DBCC","NULLIF","TRIGGER","DEALLOCATE","OF","TRUNCATE","DECLARE","OFF","TRY_CONVERT","DEFAULT","OFFSETS","TSEQUAL","DELETE","ON","UNION","DENY","OPEN","UNIQUE","DESC","OPENDATASOURCE","UNPIVOT","DISK","OPENQUERY","UPDATE","DISTINCT","OPENROWSET","UPDATETEXT","DISTRIBUTED","OPENXML","USE","DOUBLE","OPTION","USER","DROP","OR","VALUES","DUMP","ORDER","VARYING","ELSE","OUTER","VIEW","END","OVER","WAITFOR","ERRLVL","PERCENT","WHEN","ESCAPE","PIVOT","WHERE","EXCEPT","PLAN","WHILE","EXEC","PRECISION","WITH","EXECUTE","PRIMARY","WITHIN GROUP","EXISTS","PRINT","WRITETEXT","EXIT","PROC","LIMIT","MODIFY","COUNT","REPLACE"]}else if (typ == "python"){words = ["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield","in","abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"]}else if (typ == "bash"){words = ["sudo","git","hugo","cd","rm","mkdir","delete","find","ssh","scp","nano","server","root","nginx","rsync","bash","chmod","echo","print","apt-get","ls","which","touch","python","go","php","chown","du","dhclient","journalctl","systemctl","service","tar","zip","unzip","cp","mv","curl","wget","dpkg","pip","install","pip3","mysql"]}else if (typ == "go"){words = ["package","import","var","const","defer","go","goto","return","break","continue","fallthrough","if","else","switch","select","case","default","for","range","chan","map","bool","string","error","int","int8","int16","int32","int64","rune","byte","uint","uint8","uint16","uint32","uint64","uintptr","float32","float64","complex64","complex128","append","cap","close","complex","copy","delete","imag","len","make","new","panic","print","println","real","recover","true","false","nil","iota","func"]}for (i = 0;i < words.length;i++){if (typ == "php" || typ == "sql"){pos = txt.toLowerCase().indexOf(words[i].toLowerCase())}else{pos = txt.indexOf(words[i])}if (pos > -1){patt = /\W/g;if (txt.substr(pos + words[i].length,1).match(patt) && txt.substr(pos - 1,1).match(patt)){if (pos > -1 && (rpos == -1 || pos < rpos)){rpos = pos;rpos2 = rpos + words[i].length}}}}return [rpos,rpos2,func]}function getPos(txt,start,end,func){var s,e;s = txt.search(start);e = txt.indexOf(end,s + (end.length));if (e == -1){e = txt.length}return [s,e + (end.length),func]}function getNumPos(txt,func){var arr = ["
"," ",";","(","+",")","[","]",",","&",":","{","}","/","-","*","|","%","="],i,j,c,startpos = 0,endpos,word;for (i = 0;i < txt.length;i++){for (j = 0;j < arr.length;j++){c = txt.substr(i,arr[j].length);if (c == arr[j]){if (c == "-" && (txt.substr(i - 1,1) == "e" || txt.substr(i - 1,1) == "E")){continue}endpos = i;if (startpos < endpos){word = txt.substring(startpos,endpos);if (!isNaN(word)){return [startpos,endpos,func]}}i += arr[j].length;startpos = i;i -= 1;break}}}return [-1,-1,func]}} \ No newline at end of file diff --git a/static/js/w3codecolor.js b/static/js/w3codecolor.js index 2c54f31..3f28d16 100644 --- a/static/js/w3codecolor.js +++ b/static/js/w3codecolor.js @@ -1,7 +1,7 @@ /* w3codecolor ver 1.31 by w3schools.com */ /* add bash script color by jesselau.com*/ function w3CodeColor() { - var x, i, j, k, l, modes = ["html", "js", "java", "css", "sql", "python", "bash"]; + var x, i, j, k, l, modes = ["html", "js", "java", "css", "sql", "python", "bash", "go"]; if (!document.getElementsByClassName) {return;} k = modes.length; for (j = 0; j < k; j++) { @@ -52,6 +52,10 @@ function w3CodeColorize(x, lang) { var bashkeywordcolor = "mediumblue"; var bashstringcolor = "brown"; var bashnumbercolor = "red"; + var gocolor = "black"; + var gokeywordcolor = "mediumblue"; + var gostringcolor = "brown"; + var gonumbercolor = "red"; if (!lang) {lang = "html"; } if (lang == "html") {return htmlMode(x);} if (lang == "css") {return cssMode(x);} @@ -61,6 +65,7 @@ function w3CodeColorize(x, lang) { if (lang == "sql") {return sqlMode(x);} if (lang == "python") {return pythonMode(x);} if (lang == "bash") {return bashMode(x);} + if (lang == "go") {return goMode(x);} return x; function extract(str, start, end, func, repl) { var s, e, d = "", a = []; @@ -505,6 +510,39 @@ function w3CodeColorize(x, lang) { function bashKeywordMode(txt) { return "" + txt + ""; } + + function goMode(txt) { + var rest = txt, done = "", sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos, mypos, y; + y = 1; + while (y == 1) { + sfnuttpos = getPos(rest, "'", "'", goStringMode); + dfnuttpos = getPos(rest, '"', '"', goStringMode); + compos = getPos(rest, /\/\*/, "*/", commentMode); + comlinepos = getPos(rest, /\/\//, "
", commentMode); + comhashpos = getPos(rest, "#", "
", commentMode); + numpos = getNumPos(rest, goNumberMode); + keywordpos = getKeywordPos("go", rest, goKeywordMode); + if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], comhashpos[0], keywordpos[0]) == -1) {break;} + mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos); + if (mypos[0] == -1) {break;} + if (mypos[0] > -1) { + done += rest.substring(0, mypos[0]); + done += mypos[2](rest.substring(mypos[0], mypos[1])); + rest = rest.substr(mypos[1]); + } + } + rest = done + rest; + return "" + rest + ""; + } + function goStringMode(txt) { + return "" + txt + ""; + } + function goNumberMode(txt) { + return "" + txt + ""; + } + function goKeywordMode(txt) { + return "" + txt + ""; + } function getKeywordPos(typ, txt, func) { var words, i, pos, rpos = -1, rpos2 = -1, patt; if (typ == "js") { @@ -549,6 +587,11 @@ function w3CodeColorize(x, lang) { words = ["sudo", "git", "hugo", "cd", "rm", "mkdir", "delete", "find", "ssh", "scp", "nano", "server", "root", "nginx", "rsync", "bash", "chmod", "echo", "print", "apt-get", "ls", "which", "touch", "python", "go", "php", "chown", "du", "dhclient", "journalctl", "systemctl", "service", "tar", "zip", "unzip", "cp", "mv", "curl", "wget", "dpkg", "pip", "install", "pip3", "mysql"]; + } else if (typ == "go") { + words = ["package", "import", "var", "const", "defer", "go", "goto", "return", "break", "continue", "fallthrough", "if", "else", "switch", "select", "case", + "default", "for", "range", "chan", "map", "bool", "string", "error", "int", "int8", "int16", "int32", "int64", "rune", "byte", "uint", "uint8", + "uint16", "uint32", "uint64", "uintptr", "float32", "float64", "complex64", "complex128", "append", "cap", "close", "complex", "copy", "delete", + "imag", "len", "make", "new", "panic", "print", "println", "real", "recover", "true", "false", "nil", "iota","func"]; } for (i = 0; i < words.length; i++) { if (typ == "php" || typ == "sql") { -- cgit v1.2.3