mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 15:53:55 +00:00
Updated so if getParameter() is already defined, it will ignore redefinition
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -15,66 +15,85 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
try
|
||||||
Object.defineProperty(Array.prototype, 'getParameterEx',
|
{
|
||||||
{
|
Object.defineProperty(Array.prototype, 'getParameterEx',
|
||||||
value: function (name, defaultValue)
|
|
||||||
{
|
{
|
||||||
var i, ret;
|
value: function (name, defaultValue)
|
||||||
for (i = 0; i < this.length; ++i)
|
|
||||||
{
|
{
|
||||||
if (this[i].startsWith(name + '='))
|
var i, ret;
|
||||||
|
for (i = 0; i < this.length; ++i)
|
||||||
{
|
{
|
||||||
ret = this[i].substring(name.length + 1);
|
if (this[i].startsWith(name + '='))
|
||||||
if (ret.startsWith('"')) { ret = ret.substring(1, ret.length - 1); }
|
{
|
||||||
return (ret);
|
ret = this[i].substring(name.length + 1);
|
||||||
|
if (ret.startsWith('"')) { ret = ret.substring(1, ret.length - 1); }
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (defaultValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.defineProperty(Array.prototype, 'getParameter',
|
||||||
|
{
|
||||||
|
value: function (name, defaultValue)
|
||||||
|
{
|
||||||
|
return (this.getParameterEx('--' + name, defaultValue));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch(x)
|
||||||
|
{ }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Object.defineProperty(Array.prototype, 'getParameterIndex',
|
||||||
|
{
|
||||||
|
value: function (name)
|
||||||
|
{
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < this.length; ++i)
|
||||||
|
{
|
||||||
|
if (this[i].startsWith('--' + name + '='))
|
||||||
|
{
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch(x)
|
||||||
|
{ }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Object.defineProperty(Array.prototype, 'deleteParameter',
|
||||||
|
{
|
||||||
|
value: function (name)
|
||||||
|
{
|
||||||
|
var i = this.getParameterIndex(name);
|
||||||
|
if(i>=0)
|
||||||
|
{
|
||||||
|
this.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (defaultValue);
|
});
|
||||||
}
|
}
|
||||||
});
|
catch(x)
|
||||||
Object.defineProperty(Array.prototype, 'getParameter',
|
{ }
|
||||||
{
|
try
|
||||||
value: function (name, defaultValue)
|
{
|
||||||
|
Object.defineProperty(Array.prototype, 'getParameterValue',
|
||||||
{
|
{
|
||||||
return (this.getParameterEx('--' + name, defaultValue));
|
value: function (i)
|
||||||
}
|
|
||||||
});
|
|
||||||
Object.defineProperty(Array.prototype, 'getParameterIndex',
|
|
||||||
{
|
|
||||||
value: function (name)
|
|
||||||
{
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < this.length; ++i)
|
|
||||||
{
|
{
|
||||||
if (this[i].startsWith('--' + name + '='))
|
var ret = this[i].substring(this[i].indexOf('=')+1);
|
||||||
{
|
if (ret.startsWith('"')) { ret = ret.substring(1, ret.length - 1); }
|
||||||
return (i);
|
return (ret);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return (-1);
|
});
|
||||||
}
|
}
|
||||||
});
|
catch(x)
|
||||||
Object.defineProperty(Array.prototype, 'deleteParameter',
|
{ }
|
||||||
{
|
|
||||||
value: function (name)
|
|
||||||
{
|
|
||||||
var i = this.getParameterIndex(name);
|
|
||||||
if(i>=0)
|
|
||||||
{
|
|
||||||
this.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Object.defineProperty(Array.prototype, 'getParameterValue',
|
|
||||||
{
|
|
||||||
value: function (i)
|
|
||||||
{
|
|
||||||
var ret = this[i].substring(this[i].indexOf('=')+1);
|
|
||||||
if (ret.startsWith('"')) { ret = ret.substring(1, ret.length - 1); }
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function checkParameters(parms)
|
function checkParameters(parms)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user