mirror of
				https://github.com/Mibew/java.git
				synced 2025-10-31 10:31:07 +03:00 
			
		
		
		
	Renamed MibewAPIInteraction::getDefaultObligatoryArguments to MibewAPIinteraction::getObligatoryArgumentsDefaults
This commit is contained in:
		
							parent
							
								
									41d40e3c04
								
							
						
					
					
						commit
						344299805c
					
				| @ -11,10 +11,10 @@ e;a:for(e in a.arguments)for(c=0;c<f.length;c++)if(e==f[c]){d++;continue a}if(d! | ||||
| MibewAPI.prototype.checkRequest=function(a){if("string"!=typeof a.token){if("undefined"==typeof a.token)throw Error("Empty token");throw Error("Wrong token type");}if(""==a.token)throw Error("Empty token");if("object"!=typeof a.functions||!(a.functions instanceof Array)||0==a.functions.length)throw Error("Empty functions set");for(var b=0;b<a.functions.length;b++)this.checkFunction(a.functions[b])}; | ||||
| MibewAPI.prototype.checkPackage=function(a){if("undefined"==typeof a.signature)throw Error("Missed package signature");if("undefined"==typeof a.proto)throw Error("Missed protocol version");if(a.proto!=this.protocolVersion)throw Error("Wrong protocol version");if("undefined"==typeof a.async)throw Error("'async' flag is missed");if("boolean"!=typeof a.async)throw Error("Wrong 'async' flag value");if("object"!=typeof a.requests||!(a.requests instanceof Array)||0==a.requests.length)throw Error("Empty requests set"); | ||||
| for(var b=0;b<a.requests.length;b++)this.checkRequest(a.requests[b])};MibewAPI.prototype.getResultFunction=function(a,b){"undefined"==typeof b&&(b=null);var c=null,d;for(d in a)if(a.hasOwnProperty(d)&&"result"==a[d]["function"]){if(null!==c)throw Error("Function 'result' already exists in functions list");c=a[d]}if(!0===b&&null===c)throw Error("There is no 'result' function in functions list");if(!1===b&&null!==c)throw Error("There is 'result' function in functions list");return c}; | ||||
| MibewAPI.prototype.buildResult=function(a,b){var c=this.interaction.getDefaultObligatoryArguments("result"),d;for(d in c)c.hasOwnProperty(d)&&(a[d]=c[d]);return{token:b,functions:[{"function":"result",arguments:a}]}};MibewAPI.prototype.encodePackage=function(a){var b={signature:""};b.proto=this.protocolVersion;b.async=!0;b.requests=a;return encodeURIComponent(JSON.stringify(b)).replace(/\%20/gi,"+")}; | ||||
| MibewAPI.prototype.buildResult=function(a,b){var c=this.interaction.getObligatoryArgumentsDefaults("result"),d;for(d in c)c.hasOwnProperty(d)&&(a[d]=c[d]);return{token:b,functions:[{"function":"result",arguments:a}]}};MibewAPI.prototype.encodePackage=function(a){var b={signature:""};b.proto=this.protocolVersion;b.async=!0;b.requests=a;return encodeURIComponent(JSON.stringify(b)).replace(/\%20/gi,"+")}; | ||||
| MibewAPI.prototype.decodePackage=function(a){a=JSON.parse(decodeURIComponent(a.replace(/\+/gi," ")));this.checkPackage(a);return a};function MibewAPIInteraction(){this.obligatoryArguments={};this.reservedFunctionNames=[]} | ||||
| MibewAPIInteraction.prototype.getObligatoryArguments=function(a){var b=[];if("object"==typeof this.obligatoryArguments["*"]&&this.obligatoryArguments["*"]instanceof Array)for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&b.push(c);if("object"==typeof this.obligatoryArguments[a]&&this.obligatoryArguments[a]instanceof Array)for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&b.push(c);return b}; | ||||
| MibewAPIInteraction.prototype.getDefaultObligatoryArguments=function(a){var b=[];if("object"==typeof this.obligatoryArguments["*"]&&this.obligatoryArguments["*"]instanceof Array)for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments["*"][c]);if("object"==typeof this.obligatoryArguments[a]&&this.obligatoryArguments[a]instanceof Array)for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments[a][c]); | ||||
| MibewAPIInteraction.prototype.getObligatoryArgumentsDefaults=function(a){var b=[];if("object"==typeof this.obligatoryArguments["*"]&&this.obligatoryArguments["*"]instanceof Array)for(var c in this.obligatoryArguments["*"])this.obligatoryArguments["*"].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments["*"][c]);if("object"==typeof this.obligatoryArguments[a]&&this.obligatoryArguments[a]instanceof Array)for(c in this.obligatoryArguments[a])this.obligatoryArguments[a].hasOwnProperty(c)&&(b[c]=this.obligatoryArguments[a][c]); | ||||
| return b};function MibewAPIWindowToCoreInteraction(){this.obligatoryArguments={"*":{"return":{},references:{}}};this.reservedFunctionNames=["result"]}MibewAPIWindowToCoreInteraction.prototype=new MibewAPIInteraction;function MibewAPIExecutionContext(){this.returnValues={};this.functionsResults=[]} | ||||
| MibewAPIExecutionContext.prototype.getArgumentsList=function(a){var b=a.arguments,c=a.arguments.references,d,f,e;for(e in c)if(c.hasOwnProperty(e)){f=c[e];if("undefined"==typeof this.functionsResults[f-1])throw Error("Wrong reference in '"+a["function"]+"' function. Function #"+f+" does not call yet.");if("undefined"==typeof b[e]||""==b[e])throw Error("Wrong reference in '"+a["function"]+"' function. Empty '"+e+"' argument.");d=b[e];if("undefined"==typeof this.functionsResults[f-1][d])throw Error("Wrong reference in '"+ | ||||
| a["function"]+"' function. There is no '"+d+"' argument in #"+f+" function results");b[e]=this.functionsResults[f-1][d]}return b};MibewAPIExecutionContext.prototype.getResults=function(){return this.returnValues}; | ||||
|  | ||||
| @ -223,7 +223,7 @@ MibewAPI.prototype.getResultFunction = function(functionsList, existance){ | ||||
|  */ | ||||
| MibewAPI.prototype.buildResult = function(resultArguments, token) { | ||||
|     var mergedArguments = resultArguments; | ||||
|     var defaultArguments = this.interaction.getDefaultObligatoryArguments('result'); | ||||
|     var defaultArguments = this.interaction.getObligatoryArgumentsDefaults('result'); | ||||
|     for (var argName in defaultArguments) { | ||||
|         if (! defaultArguments.hasOwnProperty(argName)) { | ||||
|             continue; | ||||
| @ -353,7 +353,7 @@ MibewAPIInteraction.prototype.getObligatoryArguments = function(functionName) { | ||||
|  * @returns {Object} An object fields names are obligatory arguments and | ||||
|  * values are default values of them | ||||
|  */ | ||||
| MibewAPIInteraction.prototype.getDefaultObligatoryArguments = function(functionName) { | ||||
| MibewAPIInteraction.prototype.getObligatoryArgumentsDefaults = function(functionName) { | ||||
|     var obligatoryArguments = []; | ||||
|     // Add obligatory for all functions arguments
 | ||||
|     if (typeof this.obligatoryArguments['*'] == 'object' && | ||||
|  | ||||
| @ -274,7 +274,7 @@ Class MibewAPI { | ||||
| 	 * @return array Result package | ||||
| 	 */ | ||||
| 	public function buildResult($token, $result_arguments) { | ||||
| 		$arguments = $result_arguments + $this->interaction->getDefaultObligatoryArguments('result'); | ||||
| 		$arguments = $result_arguments + $this->interaction->getObligatoryArgumentsDefaults('result'); | ||||
| 		$package = array( | ||||
| 			'token' => $token, | ||||
| 			'functions' => array( | ||||
|  | ||||
| @ -80,7 +80,7 @@ abstract class MibewAPIInteraction { | ||||
| 	 * @return array Associative array with keys are obligatory arguments and values are default | ||||
| 	 * values of them | ||||
| 	 */ | ||||
| 	public function getDefaultObligatoryArguments($function_name) { | ||||
| 	public function getObligatoryArgumentsDefaults($function_name) { | ||||
| 		$obligatory_arguments = array(); | ||||
| 		// Add obligatory for all functions arguments
 | ||||
| 		if (! empty($this->obligatoryArguments['*'])) { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user