diff --git a/www/frame.html b/www/frame.html index 8284f05..1464020 100644 --- a/www/frame.html +++ b/www/frame.html @@ -12,6 +12,7 @@ + diff --git a/www/js/jquery.mask.min.js b/www/js/jquery.mask.min.js new file mode 100644 index 0000000..ce86d08 --- /dev/null +++ b/www/js/jquery.mask.min.js @@ -0,0 +1,19 @@ +// jQuery Mask Plugin v1.14.15 +// github.com/igorescobar/jQuery-Mask-Plugin +var $jscomp={scope:{},findInternal:function(a,l,d){a instanceof String&&(a=String(a));for(var p=a.length,h=0;hd?g=10*e:f>=g&&f!==d?c.maskDigitPosMapOld[g]||(f=g,g=g-(l-h)-a,c.maskDigitPosMap[g]&&(g=f)):g>f&& +(g=g+(h-l)+m)}return g},behaviour:function(f){f=f||window.event;c.invalid=[];var e=b.data("mask-keycode");if(-1===a.inArray(e,m.byPassKeys)){var e=c.getMasked(),g=c.getCaret();setTimeout(function(){c.setCaret(c.calculateCaretPosition())},a.jMaskGlobals.keyStrokeCompensation);c.val(e);c.setCaret(g);return c.callbacks(f)}},getMasked:function(a,b){var g=[],d=void 0===b?c.val():b+"",n=0,h=e.length,q=0,l=d.length,k=1,r="push",p=-1,t=0,y=[],v,z;f.reverse?(r="unshift",k=-1,v=0,n=h-1,q=l-1,z=function(){return-1< +n&&-1") + .attr("value", e.Name) + .text( e.Name ) + .appendTo( element ); + } ); + }, + }); + }, + + _destroy: function(){ + + }, + + }); + $.widget( "sky.IPv4", { + options: { + mask: '099.099.099.099', + placeholder: '000.000.000.000', + }, + + _create: function(){ + this.element.mask( this.options.mask, { + placeholder: this.options.placeholder, + } ); + }, + + value: function(v){ + if (arguments.length == 0){ + return this.element.val(); + } + this.element.val(v); + }, + + _destroy: function(){ + }, + + }); - $.fn.IPPool = function( opts ){ - alert(this); - var select = this.find("select")[0]; + $.fn.___IPPool = function( opts ){ + var select = this.filter("select")[0]; if (!select) throw "IPPool needs an ").IPPool().attr( "id", key ); - }; + $.sky.controls.IPPool = function(type,key){ + return $("").attr( "id", key ).IPPool(); + }; + $.sky.controls.IPv4 = function(type,key){ + return $("").attr( "id", key ).IPv4(); + }; diff --git a/www/js/sky.dhcp.js b/www/js/sky.dhcp.js index 48fb198..203f329 100644 --- a/www/js/sky.dhcp.js +++ b/www/js/sky.dhcp.js @@ -3,47 +3,20 @@ function editIPPool(ippool, editable) { - var content = $(`
-
- - - - - - - - -
-
`); - - $("#FirstIP", content).ipAddress(); - $("#LastIP", content).ipAddress(); - - skyapi().getJson( "/DHCP/collections/IPPool/" + ippool, function(ippool){ - PopulateForm( ippool, { - top: content, - }); - content.dialog( "open" ); - } ); - - content.dialog({ - modal: true, - closeOnEscape: true, - draggable: false, - title: "IP Pool", - minWidth: 600, - autoOpen: false, - buttons: [ - { - text: "abbrechen", - click: function(){ $(this).dialog( "close" ); }, + skyapi().getJson( "/DHCP/collections/IPPool/" + ippool, function(pool){ + $.skyForm( pool, { + title: "DHCP IP Pool", + fields: [ + { key: "Name", label: "Bezeichnung", }, + { key: "FirstIP", label: "Erste IP", type: "IPv4", }, + { key: "LastIP", label: "Letzte IP", type: "IPv4", }, + { key: "DefaultLeaseTime", label: "Standard Gültigkeit", } + ], + accept: function(pool){ + alert("OK: " + pool); }, - { - text: "OK", - click: function(){ $(this).dialog( "close" ); }, - }, - ] - }); + } ); + } ); } @@ -54,7 +27,7 @@ function editDHCPServerInterface(intf, editable){ fields: [ { key: "Name", label: "Bezeichnung", }, { key: "InterfaceAddress", label: "Interface IP", }, - { key: "IPPool", label: "IP Pool", type: "IPPool" }, + { key: "IPPool", label: "IP Pool", type: "IPPool", toEditor: function(p){ return p.Name; } }, ] } ); diff --git a/www/js/sky.form.js b/www/js/sky.form.js index 8ca5224..0d25cee 100644 --- a/www/js/sky.form.js +++ b/www/js/sky.form.js @@ -21,7 +21,14 @@ ajax: { url: null, // ajax collection URLSchnuff17 - }, + }, + + accept: function(o){ + + }, + cancel: function(o){ + }, + }; var defaultDialogOptions = { modal: true, @@ -33,11 +40,11 @@ buttons: [ { text: "abbrechen", - click: function(){ $(this).dialog( "close" ); }, + click: null, }, { text: "OK", - click: function(){ $(this).dialog( "close" ); }, + click: null, }, ] }; @@ -77,8 +84,7 @@ } $.skyForm = function(o, options = {} ){ - var opts = Object.assign(defaultOptions, options); - + var opts = Object.assign(defaultOptions, options); var fieldSet = $("
"); var fields = (opts.fields.length) ? opts.fields : log(Object.keys(o)).map( function(k){ return { key: k, label: k }; } ); @@ -91,7 +97,20 @@ }); var dlgOptions = Object.assign( {}, defaultDialogOptions ); - dlgOptions.title = opts.title; + dlgOptions.title = opts.title; + dlgOptions.buttons[0].click = function(){ + if (options.cancel) + options.cancel(o); + + $(this).dialog("close"); + }; + dlgOptions.buttons[1].click = function(){ + + if (options.accept) + options.accept(o); + + $(this).dialog("close"); + }; fieldSet.dialog( dlgOptions ); fieldSet.dialog( "open" );