remove depreciated files
This commit is contained in:
parent
5e57291a16
commit
39ada9daf9
Binary file not shown.
Before Width: | Height: | Size: 720 B |
Binary file not shown.
Before Width: | Height: | Size: 737 B |
Binary file not shown.
Before Width: | Height: | Size: 736 B |
Binary file not shown.
Before Width: | Height: | Size: 745 B |
@ -1,187 +0,0 @@
|
||||
$(function(){
|
||||
sensorArray(false);
|
||||
eventArray();
|
||||
|
||||
//bind Clear button to clearEvents function
|
||||
$("#btnClearEvents").bind("click", clearEvents);
|
||||
|
||||
//advanced view switch
|
||||
$('.advancedview').switchButton({
|
||||
labels_placement: "left",
|
||||
on_label: 'Advanced View',
|
||||
off_label: 'Basic View',
|
||||
checked: $.cookie('ipmitool_sensor_mode') == 'advanced'
|
||||
});
|
||||
|
||||
//set cookie and toggle advanced columns
|
||||
$('.advancedview').change(function () {
|
||||
$('.advanced').toggle('slow');
|
||||
$.cookie('ipmitool_sensor_mode', $('.advancedview').prop('checked') ? 'advanced' : 'basic', { expires: 3650 });
|
||||
});
|
||||
|
||||
// select all packages switch
|
||||
$('#allEvents')
|
||||
.switchButton({
|
||||
labels_placement: "right",
|
||||
on_label: 'Select All',
|
||||
off_label: 'Select All',
|
||||
checked: false
|
||||
})
|
||||
.change(function() { //on change
|
||||
if(this.checked) { // check select status
|
||||
$('.checkEvent').each(function() { //loop through each checkbox
|
||||
$(this).switchButton({checked: true});
|
||||
});
|
||||
}else{
|
||||
$('.checkEvent').each(function() { //loop through each checkbox
|
||||
$(this).switchButton({checked: false});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#tblSensor').tablesorter({headers:{0:{sorter:false}}});
|
||||
$('#tblEvent').tablesorter({headers:{5:{sorter:false}}});
|
||||
sensorRefresh();
|
||||
});
|
||||
|
||||
function clearEvents() {
|
||||
//if all events checked clear all
|
||||
if($('#allEvents').prop('checked')) {
|
||||
$('#allEvents').switchButton({checked: false});
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/plugins/ipmitool-plugin/include/delete_event.php",
|
||||
data : {options: "clear" + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
$("#tblEvent tbody").empty();
|
||||
},
|
||||
error : function() { }
|
||||
});
|
||||
} else {
|
||||
// clear only checked events
|
||||
$(':checkbox:checked').each(function(){
|
||||
var EventId = $(this).val(); //get event id
|
||||
var par = $(this).parent().parent(); //get table row
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/plugins/ipmitool-plugin/include/delete_event.php",
|
||||
data : {options: "delete " + EventId + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
par.remove(); //remove table row
|
||||
},
|
||||
error : function() { }
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//sensor refresh
|
||||
(function sensorRefresh() {
|
||||
sensorArray(true);
|
||||
setTimeout(sensorRefresh, 30000);
|
||||
}());
|
||||
|
||||
//load ipmi sensor table
|
||||
function sensorArray(Refresh){
|
||||
var Display = 'none';
|
||||
|
||||
if ($.cookie('ipmitool_sensor_mode') == 'advanced') {
|
||||
$('.advanced').show();
|
||||
Display = 'table-cell';
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "/plugins/ipmitool-plugin/include/ipmitool_array.php",
|
||||
data : {options: "-vc sdr" + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
$.each(data, function (i, val) {
|
||||
if (data[i][3] != "ns") {
|
||||
var Reading = data[i][1];
|
||||
var LowerNonRec = data[i][13];
|
||||
var LowerCritical = data[i][14];
|
||||
var LowerNonCrit = data[i][15];
|
||||
var UpperNonCrit = data[i][12];
|
||||
var UpperCritical = data[i][11];
|
||||
var UpperNonRec = data[i][10];
|
||||
var Color = "green";
|
||||
var Name = data[i][0].replace('+', 'plus_').replace('-', 'minus_').replace(' ', '_').replace('.', '_');
|
||||
|
||||
if (data[i][6]=="Voltage"){
|
||||
if (parseFloat(Reading) > parseFloat(LowerNonRec) && parseFloat(Reading) < parseFloat(UpperNonRec))
|
||||
Color = "red";
|
||||
if (parseFloat(Reading) > parseFloat(LowerCritical) && parseFloat(Reading) < parseFloat(UpperCritical))
|
||||
Color = "yellow";
|
||||
if (parseFloat(Reading) > parseFloat(LowerNonCrit) && parseFloat(Reading) < parseFloat(UpperNonCrit))
|
||||
Color = "green";
|
||||
} else if (data[i][6]=="Fan"){
|
||||
if (parseInt(Reading) < parseInt(LowerNonCrit))
|
||||
Color = "red";
|
||||
} else if (data[i][6]=="Temperature"){
|
||||
if (parseInt(Reading) > parseInt(UpperNonCrit))
|
||||
Color = "red";
|
||||
}
|
||||
|
||||
if (Refresh) {
|
||||
$("#" + Name + " td.reading").html("<font color='" + Color + "'>" + Reading + "</font>");
|
||||
} else {
|
||||
$("#tblSensor tbody").append(
|
||||
"<tr id='"+Name+"'>"+
|
||||
"<td title='"+data[i][3]+"'><img src='/plugins/ipmitool-plugin/images/green-on.png'/></td>"+ //status
|
||||
"<td>"+data[i][0]+"</td>"+ //sensor name
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + LowerNonRec + "</td>"+
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + LowerCritical + "</td>"+
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + LowerNonCrit + "</td>"+
|
||||
"<td class='reading'>" + "<font color='" + Color + "'>" + Reading + "</font>" + "</td>"+ //sensor reading
|
||||
"<td>"+data[i][2]+"</td>"+ //sensor units
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + UpperNonCrit + "</td>"+
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + UpperCritical + "</td>"+
|
||||
"<td class='advanced' style='display:" + Display + ";'>" + UpperNonRec + "</td>"+
|
||||
"</tr>");
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#tblSensor").trigger("update"); //update sensor table for tablesorter
|
||||
},
|
||||
error : function() {},
|
||||
cache: false
|
||||
});
|
||||
};
|
||||
|
||||
//load ipmi event table
|
||||
function eventArray(){
|
||||
$("#tblEvent tbody").empty();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
url: "/plugins/ipmitool-plugin/include/ipmitool_array.php",
|
||||
data : {options: "-c sel elist" + Options + atob(Password)},
|
||||
success: function(data) {
|
||||
$.each(data, function (i, val) {
|
||||
var Status = (data[i][5] == 'Asserted') ? 'red' : 'green';
|
||||
$("#tblEvent tbody").append(
|
||||
"<tr>"+
|
||||
"<td title='"+data[i][5]+"'><img src='/plugins/ipmitool-plugin/images/" + Status + "-on.png'/></td>"+ //status
|
||||
"<td>" + data[i][0] + "</td>"+ //event id
|
||||
"<td>" + data[i][1] + " "+data[i][2]+"</td>"+ //time stamp
|
||||
"<td>" + data[i][3] + "</td>"+ //sensor name
|
||||
"<td>" + data[i][4] +"</td>"+ //subject
|
||||
"<td> <input class='checkEvent' type='checkbox' value=" + data[i][0] + "></td>"+ //checkbox
|
||||
"</tr>");
|
||||
$("#tblEvent").trigger("update"); //update table for tablesorter
|
||||
});
|
||||
},
|
||||
complete: function () {
|
||||
$(".checkEvent")
|
||||
.switchButton({
|
||||
labels_placement: 'right',
|
||||
on_label: 'On',
|
||||
off_label: 'Off',
|
||||
checked: false
|
||||
});
|
||||
|
||||
},
|
||||
error : function() {}
|
||||
});
|
||||
};
|
@ -1,482 +0,0 @@
|
||||
/**
|
||||
* jquery.mask.js
|
||||
* @version: v1.11.3
|
||||
* @author: Igor Escobar
|
||||
*
|
||||
* Created by Igor Escobar on 2012-03-10. Please report any bug at http://blog.igorescobar.com
|
||||
*
|
||||
* Copyright (c) 2012 Igor Escobar http://blog.igorescobar.com
|
||||
*
|
||||
* The MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
/*jshint laxbreak: true */
|
||||
/* global define */
|
||||
|
||||
// UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
|
||||
// https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(["jquery"], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(window.jQuery || window.Zepto);
|
||||
}
|
||||
}(function ($) {
|
||||
"use strict";
|
||||
var Mask = function (el, mask, options) {
|
||||
el = $(el);
|
||||
|
||||
var jMask = this, old_value = el.val(), regexMask;
|
||||
|
||||
mask = typeof mask === "function" ? mask(el.val(), undefined, el, options) : mask;
|
||||
|
||||
var p = {
|
||||
invalid: [],
|
||||
getCaret: function () {
|
||||
try {
|
||||
var sel,
|
||||
pos = 0,
|
||||
ctrl = el.get(0),
|
||||
dSel = document.selection,
|
||||
cSelStart = ctrl.selectionStart;
|
||||
|
||||
// IE Support
|
||||
if (dSel && navigator.appVersion.indexOf("MSIE 10") === -1) {
|
||||
sel = dSel.createRange();
|
||||
sel.moveStart('character', el.is("input") ? -el.val().length : -el.text().length);
|
||||
pos = sel.text.length;
|
||||
}
|
||||
// Firefox support
|
||||
else if (cSelStart || cSelStart === '0') {
|
||||
pos = cSelStart;
|
||||
}
|
||||
|
||||
return pos;
|
||||
} catch (e) {}
|
||||
},
|
||||
setCaret: function(pos) {
|
||||
try {
|
||||
if (el.is(":focus")) {
|
||||
var range, ctrl = el.get(0);
|
||||
|
||||
if (ctrl.setSelectionRange) {
|
||||
ctrl.setSelectionRange(pos,pos);
|
||||
} else if (ctrl.createTextRange) {
|
||||
range = ctrl.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', pos);
|
||||
range.moveStart('character', pos);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
},
|
||||
events: function() {
|
||||
el
|
||||
.on('keyup.mask', p.behaviour)
|
||||
.on("paste.mask drop.mask", function() {
|
||||
setTimeout(function() {
|
||||
el.keydown().keyup();
|
||||
}, 100);
|
||||
})
|
||||
.on('change.mask', function(){
|
||||
el.data('changed', true);
|
||||
})
|
||||
.on("blur.mask", function(){
|
||||
if (old_value !== el.val() && !el.data('changed')) {
|
||||
el.trigger("change");
|
||||
}
|
||||
el.data('changed', false);
|
||||
})
|
||||
// it's very important that this callback remains in this position
|
||||
// otherwhise old_value it's going to work buggy
|
||||
.on('keydown.mask, blur.mask', function() {
|
||||
old_value = el.val();
|
||||
})
|
||||
// select all text on focus
|
||||
.on('focus.mask', function (e) {
|
||||
if (options.selectOnFocus === true) {
|
||||
$(e.target).select();
|
||||
}
|
||||
})
|
||||
// clear the value if it not complete the mask
|
||||
.on("focusout.mask", function() {
|
||||
if (options.clearIfNotMatch && !regexMask.test(p.val())) {
|
||||
p.val('');
|
||||
}
|
||||
});
|
||||
},
|
||||
getRegexMask: function() {
|
||||
var maskChunks = [], translation, pattern, optional, recursive, oRecursive, r;
|
||||
|
||||
for (var i = 0; i < mask.length; i++) {
|
||||
translation = jMask.translation[mask.charAt(i)];
|
||||
|
||||
if (translation) {
|
||||
|
||||
pattern = translation.pattern.toString().replace(/.{1}$|^.{1}/g, "");
|
||||
optional = translation.optional;
|
||||
recursive = translation.recursive;
|
||||
|
||||
if (recursive) {
|
||||
maskChunks.push(mask.charAt(i));
|
||||
oRecursive = {digit: mask.charAt(i), pattern: pattern};
|
||||
} else {
|
||||
maskChunks.push(!optional && !recursive ? pattern : (pattern + "?"));
|
||||
}
|
||||
|
||||
} else {
|
||||
maskChunks.push(mask.charAt(i).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
|
||||
}
|
||||
}
|
||||
|
||||
r = maskChunks.join("");
|
||||
|
||||
if (oRecursive) {
|
||||
r = r.replace(new RegExp("(" + oRecursive.digit + "(.*" + oRecursive.digit + ")?)"), "($1)?")
|
||||
.replace(new RegExp(oRecursive.digit, "g"), oRecursive.pattern);
|
||||
}
|
||||
|
||||
return new RegExp(r);
|
||||
},
|
||||
destroyEvents: function() {
|
||||
el.off(['keydown', 'keyup', 'paste', 'drop', 'blur', 'focusout', ''].join('.mask '));
|
||||
},
|
||||
val: function(v) {
|
||||
var isInput = el.is('input'),
|
||||
method = isInput ? 'val' : 'text',
|
||||
r;
|
||||
|
||||
if (arguments.length > 0) {
|
||||
if (el[method]() !== v) {
|
||||
el[method](v);
|
||||
}
|
||||
r = el;
|
||||
} else {
|
||||
r = el[method]();
|
||||
}
|
||||
|
||||
return r;
|
||||
},
|
||||
getMCharsBeforeCount: function(index, onCleanVal) {
|
||||
for (var count = 0, i = 0, maskL = mask.length; i < maskL && i < index; i++) {
|
||||
if (!jMask.translation[mask.charAt(i)]) {
|
||||
index = onCleanVal ? index + 1 : index;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
caretPos: function (originalCaretPos, oldLength, newLength, maskDif) {
|
||||
var translation = jMask.translation[mask.charAt(Math.min(originalCaretPos - 1, mask.length - 1))];
|
||||
|
||||
return !translation ? p.caretPos(originalCaretPos + 1, oldLength, newLength, maskDif)
|
||||
: Math.min(originalCaretPos + newLength - oldLength - maskDif, newLength);
|
||||
},
|
||||
behaviour: function(e) {
|
||||
e = e || window.event;
|
||||
p.invalid = [];
|
||||
var keyCode = e.keyCode || e.which;
|
||||
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
|
||||
|
||||
var caretPos = p.getCaret(),
|
||||
currVal = p.val(),
|
||||
currValL = currVal.length,
|
||||
changeCaret = caretPos < currValL,
|
||||
newVal = p.getMasked(),
|
||||
newValL = newVal.length,
|
||||
maskDif = p.getMCharsBeforeCount(newValL - 1) - p.getMCharsBeforeCount(currValL - 1);
|
||||
|
||||
p.val(newVal);
|
||||
|
||||
// change caret but avoid CTRL+A
|
||||
if (changeCaret && !(keyCode === 65 && e.ctrlKey)) {
|
||||
// Avoid adjusting caret on backspace or delete
|
||||
if (!(keyCode === 8 || keyCode === 46)) {
|
||||
caretPos = p.caretPos(caretPos, currValL, newValL, maskDif);
|
||||
}
|
||||
p.setCaret(caretPos);
|
||||
}
|
||||
|
||||
return p.callbacks(e);
|
||||
}
|
||||
},
|
||||
getMasked: function (skipMaskChars) {
|
||||
var buf = [],
|
||||
value = p.val(),
|
||||
m = 0, maskLen = mask.length,
|
||||
v = 0, valLen = value.length,
|
||||
offset = 1, addMethod = "push",
|
||||
resetPos = -1,
|
||||
lastMaskChar,
|
||||
check;
|
||||
|
||||
if (options.reverse) {
|
||||
addMethod = "unshift";
|
||||
offset = -1;
|
||||
lastMaskChar = 0;
|
||||
m = maskLen - 1;
|
||||
v = valLen - 1;
|
||||
check = function () {
|
||||
return m > -1 && v > -1;
|
||||
};
|
||||
} else {
|
||||
lastMaskChar = maskLen - 1;
|
||||
check = function () {
|
||||
return m < maskLen && v < valLen;
|
||||
};
|
||||
}
|
||||
|
||||
while (check()) {
|
||||
var maskDigit = mask.charAt(m),
|
||||
valDigit = value.charAt(v),
|
||||
translation = jMask.translation[maskDigit];
|
||||
|
||||
if (translation) {
|
||||
if (valDigit.match(translation.pattern)) {
|
||||
buf[addMethod](valDigit);
|
||||
if (translation.recursive) {
|
||||
if (resetPos === -1) {
|
||||
resetPos = m;
|
||||
} else if (m === lastMaskChar) {
|
||||
m = resetPos - offset;
|
||||
}
|
||||
|
||||
if (lastMaskChar === resetPos) {
|
||||
m -= offset;
|
||||
}
|
||||
}
|
||||
m += offset;
|
||||
} else if (translation.optional) {
|
||||
m += offset;
|
||||
v -= offset;
|
||||
} else if (translation.fallback) {
|
||||
buf[addMethod](translation.fallback);
|
||||
m += offset;
|
||||
v -= offset;
|
||||
} else {
|
||||
p.invalid.push({p: v, v: valDigit, e: translation.pattern});
|
||||
}
|
||||
v += offset;
|
||||
} else {
|
||||
if (!skipMaskChars) {
|
||||
buf[addMethod](maskDigit);
|
||||
}
|
||||
|
||||
if (valDigit === maskDigit) {
|
||||
v += offset;
|
||||
}
|
||||
|
||||
m += offset;
|
||||
}
|
||||
}
|
||||
|
||||
var lastMaskCharDigit = mask.charAt(lastMaskChar);
|
||||
if (maskLen === valLen + 1 && !jMask.translation[lastMaskCharDigit]) {
|
||||
buf.push(lastMaskCharDigit);
|
||||
}
|
||||
|
||||
return buf.join("");
|
||||
},
|
||||
callbacks: function (e) {
|
||||
var val = p.val(),
|
||||
changed = val !== old_value,
|
||||
defaultArgs = [val, e, el, options],
|
||||
callback = function(name, criteria, args) {
|
||||
if (typeof options[name] === "function" && criteria) {
|
||||
options[name].apply(this, args);
|
||||
}
|
||||
};
|
||||
|
||||
callback('onChange', changed === true, defaultArgs);
|
||||
callback('onKeyPress', changed === true, defaultArgs);
|
||||
callback('onComplete', val.length === mask.length, defaultArgs);
|
||||
callback('onInvalid', p.invalid.length > 0, [val, e, el, p.invalid, options]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// public methods
|
||||
jMask.mask = mask;
|
||||
jMask.options = options;
|
||||
jMask.remove = function() {
|
||||
var caret = p.getCaret();
|
||||
p.destroyEvents();
|
||||
p.val(jMask.getCleanVal());
|
||||
p.setCaret(caret - p.getMCharsBeforeCount(caret));
|
||||
return el;
|
||||
};
|
||||
|
||||
// get value without mask
|
||||
jMask.getCleanVal = function() {
|
||||
return p.getMasked(true);
|
||||
};
|
||||
|
||||
jMask.init = function(only_mask) {
|
||||
only_mask = only_mask || false;
|
||||
options = options || {};
|
||||
|
||||
jMask.byPassKeys = $.jMaskGlobals.byPassKeys;
|
||||
jMask.translation = $.jMaskGlobals.translation;
|
||||
|
||||
jMask.translation = $.extend({}, jMask.translation, options.translation);
|
||||
jMask = $.extend(true, {}, jMask, options);
|
||||
|
||||
regexMask = p.getRegexMask();
|
||||
|
||||
if (only_mask === false) {
|
||||
|
||||
if (options.placeholder) {
|
||||
el.attr('placeholder' , options.placeholder);
|
||||
}
|
||||
|
||||
// autocomplete needs to be off. we can't intercept events
|
||||
// the browser doesn't fire any kind of event when something is
|
||||
// selected in a autocomplete list so we can't sanitize it.
|
||||
el.attr('autocomplete', 'off');
|
||||
p.destroyEvents();
|
||||
p.events();
|
||||
|
||||
var caret = p.getCaret();
|
||||
p.val(p.getMasked());
|
||||
p.setCaret(caret + p.getMCharsBeforeCount(caret, true));
|
||||
|
||||
} else {
|
||||
p.events();
|
||||
p.val(p.getMasked());
|
||||
}
|
||||
};
|
||||
|
||||
jMask.init(!el.is("input"));
|
||||
};
|
||||
|
||||
$.maskWatchers = {};
|
||||
var HTMLAttributes = function () {
|
||||
var input = $(this),
|
||||
options = {},
|
||||
prefix = "data-mask-",
|
||||
mask = input.attr('data-mask');
|
||||
|
||||
if (input.attr(prefix + 'reverse')) {
|
||||
options.reverse = true;
|
||||
}
|
||||
|
||||
if (input.attr(prefix + 'clearifnotmatch')) {
|
||||
options.clearIfNotMatch = true;
|
||||
}
|
||||
|
||||
if (input.attr(prefix + 'selectonfocus') === 'true') {
|
||||
options.selectOnFocus = true;
|
||||
}
|
||||
|
||||
if (notSameMaskObject(input, mask, options)) {
|
||||
return input.data('mask', new Mask(this, mask, options));
|
||||
}
|
||||
},
|
||||
notSameMaskObject = function(field, mask, options) {
|
||||
options = options || {};
|
||||
var maskObject = $(field).data('mask'),
|
||||
stringify = JSON.stringify,
|
||||
value = $(field).val() || $(field).text();
|
||||
try {
|
||||
if (typeof mask === "function") {
|
||||
mask = mask(value);
|
||||
}
|
||||
return typeof maskObject !== "object" || stringify(maskObject.options) !== stringify(options) || maskObject.mask !== mask;
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
|
||||
$.fn.mask = function(mask, options) {
|
||||
options = options || {};
|
||||
var selector = this.selector,
|
||||
globals = $.jMaskGlobals,
|
||||
interval = $.jMaskGlobals.watchInterval,
|
||||
maskFunction = function() {
|
||||
if (notSameMaskObject(this, mask, options)) {
|
||||
return $(this).data('mask', new Mask(this, mask, options));
|
||||
}
|
||||
};
|
||||
|
||||
$(this).each(maskFunction);
|
||||
|
||||
if (selector && selector !== "" && globals.watchInputs) {
|
||||
clearInterval($.maskWatchers[selector]);
|
||||
$.maskWatchers[selector] = setInterval(function(){
|
||||
$(document).find(selector).each(maskFunction);
|
||||
}, interval);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.unmask = function() {
|
||||
clearInterval($.maskWatchers[this.selector]);
|
||||
delete $.maskWatchers[this.selector];
|
||||
return this.each(function() {
|
||||
var dataMask = $(this).data('mask');
|
||||
if (dataMask) {
|
||||
dataMask.remove().removeData('mask');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.cleanVal = function() {
|
||||
return this.data('mask').getCleanVal();
|
||||
};
|
||||
|
||||
$.applyDataMask = function() {
|
||||
$(document).find($.jMaskGlobals.maskElements).filter(globals.dataMaskAttr).each(HTMLAttributes);
|
||||
}
|
||||
|
||||
var globals = {
|
||||
maskElements: 'input,td,span,div',
|
||||
dataMaskAttr: '*[data-mask]',
|
||||
dataMask: true,
|
||||
watchInterval: 300,
|
||||
watchInputs: true,
|
||||
watchDataMask: false,
|
||||
byPassKeys: [9, 16, 17, 18, 36, 37, 38, 39, 40, 91],
|
||||
translation: {
|
||||
'0': {pattern: /\d/},
|
||||
'9': {pattern: /\d/, optional: true},
|
||||
'#': {pattern: /\d/, recursive: true},
|
||||
'A': {pattern: /[a-zA-Z0-9]/},
|
||||
'S': {pattern: /[a-zA-Z]/}
|
||||
}
|
||||
};
|
||||
|
||||
$.jMaskGlobals = $.jMaskGlobals || {};
|
||||
globals = $.jMaskGlobals = $.extend(true, {}, globals, $.jMaskGlobals);
|
||||
|
||||
// looking for inputs with data-mask attribute
|
||||
if (globals.dataMask) { $.applyDataMask(); }
|
||||
|
||||
setInterval(function(){
|
||||
if ($.jMaskGlobals.watchDataMask) { $.applyDataMask(); }
|
||||
}, globals.watchInterval);
|
||||
}));
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,92 +0,0 @@
|
||||
/*! Parser: metric *//*
|
||||
* Demo: http://jsfiddle.net/Mottie/abkNM/382/
|
||||
* Set the metric name in the header (defaults to 'm|meter'), e.g.
|
||||
* <th data-metric-name-abbr="b|B" data-metric-name-full="byte|Byte|BYTE">HDD Size</th>
|
||||
* <th data-metric-name="m|meter">Distance</th> <!-- data-metric-name is deprecated in v2.22.2 -->
|
||||
*/
|
||||
/*jshint jquery:true */
|
||||
;( function( $ ) {
|
||||
'use strict';
|
||||
|
||||
var prefixes = {
|
||||
// 'prefix' : [ base 10, base 2 ]
|
||||
// skipping IEEE 1541 defined prefixes: kibibyte, mebibyte, etc, for now.
|
||||
'Y|Yotta|yotta' : [ 1e24, Math.pow(1024, 8) ], // 1024^8
|
||||
'Z|Zetta|zetta' : [ 1e21, Math.pow(1024, 7) ], // 1024^7
|
||||
'E|Exa|exa' : [ 1e18, Math.pow(1024, 6) ], // 1024^6
|
||||
'P|Peta|peta' : [ 1e15, Math.pow(1024, 5) ], // 1024^5
|
||||
'T|Tera|tera' : [ 1e12, Math.pow(1024, 4) ], // 1024^4
|
||||
'G|Giga|giga' : [ 1e9, Math.pow(1024, 3) ], // 1024^3
|
||||
'M|Mega|mega' : [ 1e6, Math.pow(1024, 2) ], // 1024^2
|
||||
'k|Kilo|kilo' : [ 1e3, 1024 ], // 1024
|
||||
// prefixes below here are rarely, if ever, used in binary
|
||||
'h|hecto' : [ 1e2, 1e2 ],
|
||||
'da|deka' : [ 1e1, 1e1 ],
|
||||
'd|deci' : [ 1e-1, 1e-1 ],
|
||||
'c|centi' : [ 1e-2, 1e-2 ],
|
||||
'm|milli' : [ 1e-3, 1e-3 ],
|
||||
'µ|micro' : [ 1e-6, 1e-6 ],
|
||||
'n|nano' : [ 1e-9, 1e-9 ],
|
||||
'p|pico' : [ 1e-12, 1e-12 ],
|
||||
'f|femto' : [ 1e-15, 1e-15 ],
|
||||
'a|atto' : [ 1e-18, 1e-18 ],
|
||||
'z|zepto' : [ 1e-21, 1e-21 ],
|
||||
'y|yocto' : [ 1e-24, 1e-24 ]
|
||||
},
|
||||
// the \\d+ will not catch digits with spaces, commas or decimals; so use the value from n instead
|
||||
RegLong = '(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)(',
|
||||
RegAbbr = '(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)(',
|
||||
// make these case-insensitive because we all forget the case for these binary values
|
||||
byteTest = /^[b|bit|byte|o|octet]/i;
|
||||
|
||||
$.tablesorter.addParser({
|
||||
id: 'metric',
|
||||
is: function() {
|
||||
return false;
|
||||
},
|
||||
format: function(txt, table, cell, cellIndex) {
|
||||
var unit, isBinary, nameLong, nameAbbr,
|
||||
// default base unit name
|
||||
base = 'm|meter',
|
||||
// process number here to get a numerical format (us or eu)
|
||||
num = $.tablesorter.formatFloat( txt.replace(/[^\w,. \-()]/g, ''), table ),
|
||||
$t = table.config.$headerIndexed[ cellIndex ],
|
||||
regex = $t.data( 'metric' );
|
||||
if ( !regex ) {
|
||||
// stored values
|
||||
unit = ( $t.attr('data-metric-name') || base ).split( '|' );
|
||||
nameLong = $t.attr( 'data-metric-name-full' ) || '';
|
||||
nameAbbr = $t.attr( 'data-metric-name-abbr' ) || '';
|
||||
regex = [ nameLong || unit[1] || unit[0].substring(1), nameAbbr || unit[0] ];
|
||||
isBinary = byteTest.test( regex.join( '' ) );
|
||||
// adding 'data-metric-name-full' which would contain 'byte|BYTE|Byte' etc
|
||||
regex[2] = new RegExp( RegLong + (
|
||||
( nameLong === '' ? '' : nameLong + '|' + nameAbbr ) ||
|
||||
// with data-metric-name='b|byte', we end up with 'b|B|byte|BYTE' - maybe not the best solution for case-insensitivity
|
||||
( ( isBinary ? regex[0].toLowerCase() + '|' + regex[0].toUpperCase() : regex[0] ) + '|' +
|
||||
( isBinary ? regex[1].toLowerCase() + '|' + regex[1].toUpperCase() : regex[1] ) ) ) +
|
||||
')' );
|
||||
// adding 'data-metric-name-abbr' which would contain 'b|B' etc
|
||||
regex[3] = new RegExp( RegAbbr + ( nameAbbr ||
|
||||
( ( isBinary ? regex[1].toLowerCase() + '|' + regex[1].toUpperCase() : regex[1] ) ) ) +
|
||||
')' );
|
||||
$t.data( 'metric', regex );
|
||||
}
|
||||
// find match to full name or abbreviation
|
||||
unit = txt.match( regex[2] ) || txt.match( regex[3] );
|
||||
if ( unit ) {
|
||||
for ( base in prefixes ) {
|
||||
if ( unit[3].match( base ) ) {
|
||||
// exception when using binary prefix
|
||||
// change base for binary use
|
||||
isBinary = byteTest.test( unit[4] ) ? 1 : 0;
|
||||
return num * prefixes[ base ][ isBinary ];
|
||||
}
|
||||
}
|
||||
}
|
||||
return num;
|
||||
},
|
||||
type: 'numeric'
|
||||
});
|
||||
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user