Changeset 2103703
- Timestamp:
- 06/11/2019 06:03:43 AM (7 years ago)
- Location:
- metric-converter/trunk
- Files:
-
- 3 edited
-
Readme.txt (modified) (3 diffs)
-
assets/js/tinymce_buttons.min.js (modified) (1 diff)
-
metric-converter.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
metric-converter/trunk/Readme.txt
r2098714 r2103703 5 5 Requires at least: 4.7 6 6 Tested up to: 5.2 7 Stable tag: 1.5. 27 Stable tag: 1.5.3 8 8 Requires PHP: 5.6 9 9 License: MIT License/X11 … … 73 73 74 74 == Changelog == 75 = 1.5.3 = 76 Clearing images from unnecessary data added 75 77 = 1.5.2 = 76 78 Deletion of align, id, class inside tags added … … 84 86 This is the initial release version of the plugin. 85 87 == Upgrade Notice == 88 = 1.5.3 = 89 This version features clearing images from unnecessary data 86 90 = 1.5.2 = 87 91 This version features deletion of align, id, class inside tags -
metric-converter/trunk/assets/js/tinymce_buttons.min.js
r2098714 r2103703 1 (function(){Element.prototype.remove=function(){this.parentElement.removeChild(this)};NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var a=this.length-1;a>=0;a--){if(this[a]&&this[a].parentElement){this[a].parentElement.removeChild(this[a])}}};tinymce.PluginManager.add("converter",function(g,d){function e(i){var j=i.getContent({format:"html"});if(j.length===0){alert("Content is empty.");return false}return j}function h(i){var j=i.selection.getContent({format:"html"});if(j.length===0){alert("Please select some text.");return false}return j}function f(j,i,k){return j+" / "+i+" "+k}function b(i){try{i=parseFloat(i)}catch(j){return false}return i}function c(l){var k=h(g);if(!k){return}var j=b(k);if(!j){return}var m={mm:{format:"inch",value:0.0393701,rnd:2},mmim:{format:"inch",value:0.0393701,rnd:2},mmit:{format:"",value:0.0393701,rnd:2},mmbold:{format:"",value:0.0393701,style:"bold",rnd:2},cm:{format:"inch",value:0.393701,rnd:2},cmbold:{format:"",value:0.393701,style:"bold",rnd:2},cmim:{format:"inch",value:0.393701,rnd:2},cmit:{format:"",value:0.393701,rnd:2},m:{format:"inch",value:39.3701,rnd:2},f:{format:"feet",value:3.280841,rnd:2},imm:{format:"mm",value:25.4,rnd:2},icm:{format:"cm",value:2.54,rnd:2},im:{format:"m",value:0.0254,rnd:2},fm:{format:"m",value:0.3048,rnd:2},ml:{format:"oz",value:0.033814,rnd:2},l:{format:"oz",value:33.814,rnd:2},oml:{format:"ml",value:29.5735,rnd:2},ol:{format:"l",value:0.0295735,rnd:2},g:{format:"lbs",value:0.00220462,rnd:2},kg:{format:"lbs",value:2.20462,rnd:2},lg:{format:"g",value:453.592,rnd:2},lkg:{format:"kg",value:0.453592,rnd:2}};if(m.hasOwnProperty(l)){var i,n=[];if(l==="cmim"){j=k.split("x");j.forEach(function(q,p){var o=Math.round((parseFloat(q)*m[l].value)*100)/100;n.push(o.toFixed(m[l].rnd))});i=n.join(" x ");k=k.trim()+" / "+i+" "+m[l].format;g.execCommand("mceReplaceContent",false,k);return}else{if(l==="mmim"){j=k.split("x");j.forEach(function(q,p){var o=Math.round((parseFloat(q)*m[l].value)*100)/100;n.push(o.toFixed(m[l].rnd))});i=n.join(" x ");k=k.trim()+" / "+i+" "+m[l].format;g.execCommand("mceReplaceContent",false,k);return}else{if(l==="cmit"){j=k.split("-");j.forEach(function(q,p){var o=Math.round((parseFloat(q)*m[l].value)*100)/100;n.push(o.toFixed(m[l].rnd))});i=n.join("-");k=k.trim()+" / <strong>"+i+"</strong>";g.execCommand("mceReplaceContent",false,k);return}else{if(l==="mmit"){j=k.split("-");j.forEach(function(q,p){var o=Math.round((parseFloat(q)*m[l].value)*100)/100;n.push(o.toFixed(m[l].rnd))});i=n.join("-");k=k.trim()+" / <strong>"+i+"</strong>";g.execCommand("mceReplaceContent",false,k);return}else{i=m[l].value*j}}}}i=Math.round(i*100)/100;i=i.toFixed(m[l].rnd);if(m[l].hasOwnProperty("style")){if(m[l].style==="bold"){i="<strong>"+i+"</strong>"}}g.execCommand("mceReplaceContent",false,f(k,i,m[l].format))}return true}function a(){var i=e(g);if(!i){return}var j=document.createElement("div");j.innerHTML=i;j.querySelectorAll('[style*="max-width:"]').forEach(function(k){k.remove()});i=j.innerHTML;i=i.replace(/<\/?(span|div|a|hr)[^>]*>/g,"");i=i.replace(/(style)=".*?"/igm,"");i=i.replace(/(data-.*?)=".*?"/igm,"");i=i.replace(/(width|height|border|align|class|id)=".*?"/igm,"");i=i.replace(/.jpg?[^>]*"/igm,'.jpg"');i=i.replace(/.jpeg?[^>]*"/igm,'.jpeg"');g.setContent(i);return true}g.addButton("cleaner-content",{icon:"icon clean-icon",tooltip:"Clean tags from Main Editor",onclick:a});g.addButton("metric-length",{type:"menubutton",text:"Lengths",icon:"icon length-icon",menu:[{text:"mm to inch",onclick:function(){c("mm")}},{text:"cm to inch",onclick:function(){c("cm")}},{text:"m to inch",onclick:function(){c("m")}},{text:"m to feet",onclick:function(){c("f")}},{text:"inch to mm ",onclick:function(){c("imm")}},{text:"inch to cm",onclick:function(){c("icm")}},{text:"inch to m",onclick:function(){c("im")}},{text:"feet to m",onclick:function(){c("fm")}}]});g.addButton("metric-volume",{type:"menubutton",text:"Volume",icon:"icon volume-icon",menu:[{text:"ml to oz",onclick:function(){c("ml")}},{text:"l to oz",onclick:function(){c("l")}},{text:"oz to ml",onclick:function(){c("oml")}},{text:"oz to l",onclick:function(){c("ol")}}]});g.addButton("metric-weight",{type:"menubutton",text:"Weight",icon:"icon weight-icon",menu:[{text:"grams to lbs",onclick:function(){c("g")}},{text:"kg to lbs",onclick:function(){c("kg")}},{text:"lbs to grams",onclick:function(){c("lg")}},{text:"lbs to kg ",onclick:function(){c("lkg")}}]});g.shortcuts.add("alt+1","** mm / ** inch",function(){c("mm")});g.shortcuts.add("alt+2","** сm / ** inch",function(){c("cm")});g.shortcuts.add("alt+q","** x ** x ** mm / ** x ** x ** inch",function(){c("mmim")});g.shortcuts.add("alt+w","** x ** x ** cm / ** x ** x ** inch",function(){c("cmim")});g.shortcuts.add("alt+a","** (mm, regular font) / ** (inch, bold font)",function(){c("mmbold")});g.shortcuts.add("alt+s","** (cm, regular font) / ** (inch, bold font)",function(){c("cmbold")});g.shortcuts.add("alt+z","**-** (mm, regular font) / **-** (inch, bold font)",function(){c("mmit")});g.shortcuts.add("alt+x","**-** (cm, regular font) / **-** (inch, bold font)",function(){c("cmit")});g.shortcuts.add("alt+i","** g / ** lbs",function(){c("g")});g.shortcuts.add("alt+o","** kg / ** lbs",function(){c("kg")});g.shortcuts.add("alt+k","** ml / ** oz",function(){c("ml")});g.shortcuts.add("alt+l","** l / ** oz",function(){c("l")})})})();1 Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(let t=this.length-1;t>=0;t--)this[t]&&this[t].parentElement&&this[t].parentElement.removeChild(this[t])},tinymce.PluginManager.add("converter",function(t,n){function o(n){let o=function(t){let n=t.selection.getContent({format:"html"});return 0===n.length?(alert("Please select some text."),!1):n}(t);if(!o)return;let e=function(t){try{t=parseFloat(t)}catch(t){return!1}return t}(o);if(!e)return;let c={mm:{format:"inch",value:.0393701,rnd:2},mmim:{format:"inch",value:.0393701,rnd:2},mmit:{format:"",value:.0393701,rnd:2},mmbold:{format:"",value:.0393701,style:"bold",rnd:2},cm:{format:"inch",value:.393701,rnd:2},cmbold:{format:"",value:.393701,style:"bold",rnd:2},cmim:{format:"inch",value:.393701,rnd:2},cmit:{format:"",value:.393701,rnd:2},m:{format:"inch",value:39.3701,rnd:2},f:{format:"feet",value:3.280841,rnd:2},imm:{format:"mm",value:25.4,rnd:2},icm:{format:"cm",value:2.54,rnd:2},im:{format:"m",value:.0254,rnd:2},fm:{format:"m",value:.3048,rnd:2},ml:{format:"oz",value:.033814,rnd:2},l:{format:"oz",value:33.814,rnd:2},oml:{format:"ml",value:29.5735,rnd:2},ol:{format:"l",value:.0295735,rnd:2},g:{format:"lbs",value:.00220462,rnd:2},kg:{format:"lbs",value:2.20462,rnd:2},lg:{format:"g",value:453.592,rnd:2},lkg:{format:"kg",value:.453592,rnd:2}};if(c.hasOwnProperty(n)){let i,l=[];if("cmim"===n)return(e=o.split("x")).forEach(function(t,o){let e=Math.round(parseFloat(t)*c[n].value*100)/100;l.push(e.toFixed(c[n].rnd))}),i=l.join(" x "),o=o.trim()+" / "+i+" "+c[n].format,void t.execCommand("mceReplaceContent",!1,o);if("mmim"===n)return(e=o.split("x")).forEach(function(t,o){let e=Math.round(parseFloat(t)*c[n].value*100)/100;l.push(e.toFixed(c[n].rnd))}),i=l.join(" x "),o=o.trim()+" / "+i+" "+c[n].format,void t.execCommand("mceReplaceContent",!1,o);if("cmit"===n)return(e=o.split("-")).forEach(function(t,o){let e=Math.round(parseFloat(t)*c[n].value*100)/100;l.push(e.toFixed(c[n].rnd))}),i=l.join("-"),o=o.trim()+" / <strong>"+i+"</strong>",void t.execCommand("mceReplaceContent",!1,o);if("mmit"===n)return(e=o.split("-")).forEach(function(t,o){let e=Math.round(parseFloat(t)*c[n].value*100)/100;l.push(e.toFixed(c[n].rnd))}),i=l.join("-"),o=o.trim()+" / <strong>"+i+"</strong>",void t.execCommand("mceReplaceContent",!1,o);i=c[n].value*e,i=(i=Math.round(100*i)/100).toFixed(c[n].rnd),c[n].hasOwnProperty("style")&&"bold"===c[n].style&&(i="<strong>"+i+"</strong>"),t.execCommand("mceReplaceContent",!1,function(t,n,o){return t+" / "+n+" "+o}(o,i,c[n].format))}return!0}t.addButton("cleaner-content",{icon:"icon clean-icon",tooltip:"Clean tags from Main Editor",onclick:function(){let n=function(t){let n=t.getContent({format:"html"});return 0===n.length?(alert("Content is empty."),!1):n}(t);if(!n)return;let o=document.createElement("div");return o.innerHTML=n,o.querySelectorAll('[style*="max-width:"]').forEach(function(t){t.remove()}),n=(n=(n=(n=(n=(n=(n=o.innerHTML).replace(/<\/?(span|div|a|hr)[^>]*>/g,"")).replace(/(style)=".*?"/gim,"")).replace(/(data-.*?)=".*?"/gim,"")).replace(/(width|height|border|align|class|id)=".*?"/gim,"")).replace(/.(jpg)[^>]*"/gim,'.jpg"')).replace(/.(jpeg)[^>]*"/gim,'.jpeg"'),t.setContent(n),!0}}),t.addButton("metric-length",{type:"menubutton",text:"Lengths",icon:"icon length-icon",menu:[{text:"mm to inch",onclick:function(){o("mm")}},{text:"cm to inch",onclick:function(){o("cm")}},{text:"m to inch",onclick:function(){o("m")}},{text:"m to feet",onclick:function(){o("f")}},{text:"inch to mm ",onclick:function(){o("imm")}},{text:"inch to cm",onclick:function(){o("icm")}},{text:"inch to m",onclick:function(){o("im")}},{text:"feet to m",onclick:function(){o("fm")}}]}),t.addButton("metric-volume",{type:"menubutton",text:"Volume",icon:"icon volume-icon",menu:[{text:"ml to oz",onclick:function(){o("ml")}},{text:"l to oz",onclick:function(){o("l")}},{text:"oz to ml",onclick:function(){o("oml")}},{text:"oz to l",onclick:function(){o("ol")}}]}),t.addButton("metric-weight",{type:"menubutton",text:"Weight",icon:"icon weight-icon",menu:[{text:"grams to lbs",onclick:function(){o("g")}},{text:"kg to lbs",onclick:function(){o("kg")}},{text:"lbs to grams",onclick:function(){o("lg")}},{text:"lbs to kg ",onclick:function(){o("lkg")}}]}),t.shortcuts.add("alt+1","** mm / ** inch",function(){o("mm")}),t.shortcuts.add("alt+2","** сm / ** inch",function(){o("cm")}),t.shortcuts.add("alt+q","** x ** x ** mm / ** x ** x ** inch",function(){o("mmim")}),t.shortcuts.add("alt+w","** x ** x ** cm / ** x ** x ** inch",function(){o("cmim")}),t.shortcuts.add("alt+a","** (mm, regular font) / ** (inch, bold font)",function(){o("mmbold")}),t.shortcuts.add("alt+s","** (cm, regular font) / ** (inch, bold font)",function(){o("cmbold")}),t.shortcuts.add("alt+z","**-** (mm, regular font) / **-** (inch, bold font)",function(){o("mmit")}),t.shortcuts.add("alt+x","**-** (cm, regular font) / **-** (inch, bold font)",function(){o("cmit")}),t.shortcuts.add("alt+i","** g / ** lbs",function(){o("g")}),t.shortcuts.add("alt+o","** kg / ** lbs",function(){o("kg")}),t.shortcuts.add("alt+k","** ml / ** oz",function(){o("ml")}),t.shortcuts.add("alt+l","** l / ** oz",function(){o("l")})}); -
metric-converter/trunk/metric-converter.php
r2098714 r2103703 5 5 * Description: Extension for the visual editor. Conversion of metric units to American linear measures (inch, oz, lbs) 6 6 * Author: Vitaly Kukin 7 * Version: 1.5. 27 * Version: 1.5.3 8 8 * Author URI: https://yellowduck.me/ 9 9 * License: MIT … … 11 11 */ 12 12 13 if ( ! defined( 'YDMC_VERSION' ) ) define( 'YDMC_VERSION', '1.5. 2' );13 if ( ! defined( 'YDMC_VERSION' ) ) define( 'YDMC_VERSION', '1.5.3' ); 14 14 if ( ! defined( 'YDMC_URL' ) ) define( 'YDMC_URL', str_replace( [ 'https:', 'http:' ], '', plugins_url('metric-converter') ) ); 15 15
Note: See TracChangeset
for help on using the changeset viewer.