whisper.cat/weboasis/text/js/convert-case.js
2023-10-05 23:28:32 +11:00

1 line
6.8 KiB
JavaScript

var _$_f8a2=["\x23\x69\x6E\x70\x75\x74\x5F\x6F\x75\x74\x70\x75\x74","\x74\x61\x5F\x65\x78\x61\x6D\x70\x6C\x65\x73","\x74\x48\x45\x20\x71\x75\x49\x63\x6B\x20\x42\x72\x6F\x57\x4E\x20\x46\x4F\x78\x20\x6A\x55\x6D\x70\x53\x20\x6F\x76\x65\x52\x20\x54\x68\x45\x20\x6C\x61\x7A\x59\x20\x44\x6F\x67","\x0A","\x23\x73\x65\x74\x74\x69\x6E\x67\x73","\x55\x70\x70\x65\x72\x63\x61\x73\x65","\x55\x70\x70\x65\x72\x63\x61\x73\x65\x20\x61\x70\x70\x6C\x69\x65\x64","\x4C\x6F\x77\x65\x72\x63\x61\x73\x65","\x4C\x6F\x77\x65\x72\x63\x61\x73\x65\x20\x61\x70\x70\x6C\x69\x65\x64","\x54\x69\x74\x6C\x65\x20\x43\x61\x73\x65","\x74\x69\x74\x6C\x65\x5F\x63\x61\x73\x65","\x54\x69\x74\x6C\x65\x20\x63\x61\x73\x65\x20\x61\x70\x70\x6C\x69\x65\x64","\x41\x50\x20\x54\x69\x74\x6C\x65\x20\x43\x61\x73\x65","\x61\x70\x5F\x63\x61\x73\x65","\x41\x50\x20\x74\x69\x74\x6C\x65\x20\x63\x61\x73\x65\x20\x61\x70\x70\x6C\x69\x65\x64","\x45\x61\x63\x68\x20\x57\x6F\x72\x64","\x45\x61\x63\x68\x20\x77\x6F\x72\x64\x20\x63\x61\x70\x69\x74\x61\x6C\x69\x7A\x65\x64","\x53\x65\x6E\x74\x65\x6E\x63\x65","\x53\x65\x6E\x74\x65\x6E\x63\x65\x20\x63\x61\x73\x65\x20\x61\x70\x70\x6C\x69\x65\x64","\x53\x68\x75\x66\x66\x6C\x65","","\x53\x68\x75\x66\x66\x6C\x65\x64","\x23\x61\x70\x70\x6C\x79\x43\x61\x73\x65","\x3A","\x2D","\x20","\x2E\x63\x6C\x69\x70\x62\x6F\x61\x72\x64","\x23\x63\x6C\x65\x61\x72\x41\x6C\x6C\x2C\x20\x23\x65\x64\x69\x74\x5F\x64\x65\x6C\x65\x74\x65\x2C\x20\x23\x66\x69\x6C\x65\x5F\x6E\x65\x77","\x63\x68\x61\x6E\x67\x65","\x23\x66\x69\x6C\x65\x5F\x75\x70\x6C\x6F\x61\x64","\x23\x66\x69\x6C\x65\x5F\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x23\x66\x69\x6C\x65\x5F\x70\x72\x69\x6E\x74","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x23\x65\x64\x69\x74\x5F\x75\x6E\x64\x6F","\x23\x65\x64\x69\x74\x5F\x72\x65\x64\x6F","\x23\x65\x64\x69\x74\x5F\x63\x6F\x70\x79","\x23\x65\x64\x69\x74\x5F\x73\x65\x6C\x65\x63\x74","\x67\x65\x74","\x55\x54\x46\x2D\x38","\x4E\x6F\x20\x62\x6C\x6F\x62\x73\x20\x6F\x6E\x20\x49\x45\x20\x76\x65\x72\x3C\x31\x30","\x69\x6E\x70\x75\x74\x5F\x6F\x75\x74\x70\x75\x74","\x0D\x0A","\x74\x65\x78\x74\x2F\x70\x6C\x61\x69\x6E","\x46\x69\x6C\x65\x20\x6E\x61\x6D\x65\x3A","\x4E\x65\x77\x20\x44\x6F\x63\x75\x6D\x65\x6E\x74","\x2E\x74\x78\x74","\x6E\x75\x6C\x6C\x2E\x74\x78\x74","\x61","\x6E\x6F\x6E\x65","\x63\x68\x69\x6C\x64\x57\x69\x6E\x64\x6F\x77","\x6C\x6F\x63\x61\x74\x69\x6F\x6E\x3D\x79\x65\x73\x2C\x20\x6D\x65\x6E\x75\x62\x61\x72\x3D\x79\x65\x73\x2C\x20\x74\x6F\x6F\x6C\x62\x61\x72\x3D\x79\x65\x73","\x3C\x68\x74\x6D\x6C\x3E\x3C\x68\x65\x61\x64\x3E\x3C\x2F\x68\x65\x61\x64\x3E\x3C\x62\x6F\x64\x79\x3E","\x3C\x62\x72\x3E","\x3C\x2F\x62\x6F\x64\x79\x3E\x3C\x2F\x68\x74\x6D\x6C\x3E"];var area=$(_$_f8a2[0]);var examples=JSON.parse(localStorage.getItem(_$_f8a2[1]));if(examples== true){area.val(_$_f8a2[2])};$(_$_f8a2[22]).click(function(){Remember();var d=area.val().replace(/\r\n|\r|\n/gm,_$_f8a2[3]);var c=$(_$_f8a2[4]).val();if(c== _$_f8a2[5]){d= d.toUpperCase();Toast(_$_f8a2[6])}else {if(c== _$_f8a2[7]){d= d.toLowerCase();Toast(_$_f8a2[8])}else {if(c== _$_f8a2[9]){d= wordCase(d);d= toTitleCase(d,_$_f8a2[10]);Toast(_$_f8a2[11])}else {if(c== _$_f8a2[12]){d= wordCase(d);d= toTitleCase(d,_$_f8a2[13]);Toast(_$_f8a2[14])}else {if(c== _$_f8a2[15]){d= wordCase(d);Toast(_$_f8a2[16])}else {if(c== _$_f8a2[17]){d= d.toLowerCase();let b=/(^|[.!?]\s+)([a-z])/g;d= d.replace(b,(m,$1,$2)=>$1+ $2.toUpperCase());Toast(_$_f8a2[18])}else {if(c== _$_f8a2[19]){d= d.split(_$_f8a2[20]);var a=0;for(a= 0;a< d.length;a++){if(d[a]){r= Math.floor(Math.random()* 2)+ 1;if(r== 1){d[a]= d[a].toUpperCase()}else {if(r== 2){d[a]= d[a].toLowerCase()}}}};d= d.join(_$_f8a2[20]);Toast(_$_f8a2[21])}}}}}}};area.val(d);Remember()});function toTitleCase(s,o){var u,z;if(o=== _$_f8a2[13]){var w=/^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i}else {if(o=== _$_f8a2[10]){var w=/^(a|abaft|about|above|afore|after|along|amid|among|an|and|apud|as|aside|at|atop|below|but|by|circa|down|for|from|given|in|into|lest|like|mid|midst|minus|near|next|nor|of|off|on|onto|or|out|over|pace|past|per|plus|pro|qua|round|sans|save|since|so|than|the|thru|till|times|to|under|until|unto|up|upon|via|vice|with|worth|yet)$/i}};return s.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g,function(h,j,q){if(j> 0&& j+ h.length!== q.length&& h.search(w)> -1&& q.charAt(j- 2)!== _$_f8a2[23]&& (q.charAt(j+ h.length)!== _$_f8a2[24]|| q.charAt(j- 1)=== _$_f8a2[24])&& q.charAt(j- 1).search(/[^\s-]/)< 0){return h.toLowerCase()};if(h.substr(1).search(/[A-Z]|\../)> -1){return h};return h.charAt(0).toUpperCase()+ h.substr(1)})}function wordCase(B){var o=B.split(_$_f8a2[25]),A=_$_f8a2[20];for(i= 0;i< o.length;i++){lowerWord= o[i].toLowerCase(),lowerWord= lowerWord.trim(),capitalizedWord= lowerWord.slice(0,1).toUpperCase()+ lowerWord.slice(1),A+= capitalizedWord,i!= o.length- 1&& (A+= _$_f8a2[25])};return A[A.length- 1]= _$_f8a2[20],A}$(_$_f8a2[26]).click(function(){Clipboard(area)});$(_$_f8a2[27]).click(function(){area.val(_$_f8a2[20]);Remember()});$(_$_f8a2[29]).on(_$_f8a2[28],function(){loadText()});$(_$_f8a2[30]).click(function(){saveText()});$(_$_f8a2[31]).click(function(){printTextArea()});$(_$_f8a2[33]).click(function(){var h=History.undo();if( typeof h!== _$_f8a2[32]){area.val(h)}});$(_$_f8a2[34]).click(function(){var h=History.redo();if( typeof h!== _$_f8a2[32]){area.val(h)}});$(_$_f8a2[35]).click(function(){Clipboard(area)});$(_$_f8a2[36]).click(function(){area.select().focus()});function loadText(){var o=$(_$_f8a2[29])[_$_f8a2[37]](0).files[0],p= new FileReader;p.onload= function(o){var p=o.target.result;area.val(p)},p.readAsText(o,_$_f8a2[38])}function saveText(h,j){var q=navigator.userAgent.match(/MSIE\s([\d.]+)/),s=navigator.userAgent.match(/Trident\/7.0/)&& navigator.userAgent.match(/rv:11/),o=navigator.userAgent.match(/Edge/g),u=q?q[1]:s?11:o?12:-1;if(q&& u< 10){return void(console.log(_$_f8a2[39]))};var j=document.getElementById(_$_f8a2[40]).value,j=j.replace(/\r?\n/g,_$_f8a2[41]),w= new Blob([j],{type:_$_f8a2[42]}),h=prompt(_$_f8a2[43],_$_f8a2[44])+ _$_f8a2[45];if(h!= _$_f8a2[46]){if(u> -1){window.navigator.msSaveBlob(w,h)}else {var y=document.createElement(_$_f8a2[47]);y.download= h,y.href= window.URL.createObjectURL(w),y.onclick= function(h){document.body.removeChild(h.target)},y.style.display= _$_f8a2[48],document.body.appendChild(y),y.click()}}}function printTextArea(){childWindow= window.open(_$_f8a2[20],_$_f8a2[49],_$_f8a2[50]);childWindow.document.open();childWindow.document.write(_$_f8a2[51]);childWindow.document.write(document.getElementById(_$_f8a2[40]).value.replace(/\n/gi,_$_f8a2[52]));childWindow.document.write(_$_f8a2[53]);childWindow.print();childWindow.document.close();childWindow.close()}var History=function(){var j=[],n=0,k=10,l={remember:function(h){if(j[n- 1]!== h){j.splice(n,k);j.push(h);j.splice(0,j.length- k);n= j.length}},undo:function(){if(n> 1){--n;return j[n- 1]}},redo:function(){if(n< j.length){return j[n++]}}};return l}();function Remember(){var h=area.val();History.remember(h)}Remember()