Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
17f60efd
Commit
17f60efd
authored
Jul 15, 2015
by
Vivek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
e8fec70b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
539 additions
and
112 deletions
+539
-112
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/demo_interface1_html.xml
...PathTemplateItem/web_page_module/demo_interface1_html.xml
+5
-5
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/demo_interface2_html.xml
...PathTemplateItem/web_page_module/demo_interface2_html.xml
+362
-0
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_html.xml
...emplateItem/web_page_module/gadget_interfacedemo_html.xml
+6
-2
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_js.xml
...hTemplateItem/web_page_module/gadget_interfacedemo_js.xml
+37
-28
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/rjs_gadget_interfaces_js.xml
...TemplateItem/web_page_module/rjs_gadget_interfaces_js.xml
+129
-77
No files found.
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/demo_interface1_html.xml
View file @
17f60efd
...
...
@@ -116,15 +116,15 @@
<dt>
method1
</dt>
\n
<dd>
description of method1
</dd>
\n
<dl>
\n
<dt
class=
"required"
type=
"int"
>
param1
</dt>
\n
<dt
data-parameter-required=
"required"
data-parameter-
type=
"int"
>
param1
</dt>
\n
<dd>
description of param1
</dd>
\n
<dt
class
=
"optional"
>
param2
</dt>
\n
<dt
data-parameter-required
=
"optional"
>
param2
</dt>
\n
<dd>
description of param2
</dd>
\n
</dl>
\n
<dt>
method2
</dt>
\n
<dd>
description of method2
</dd>
\n
<dl>
\n
<dt
class=
"required"
type=
"boolean"
>
param1
</dt>
\n
<dt
data-parameter-required=
"required"
data-parameter-
type=
"boolean"
>
param1
</dt>
\n
<dd>
description of param1
</dd>
\n
</dl>
\n
</dd>
\n
...
...
@@ -270,7 +270,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.
17297.14978.38758
</string>
</value>
<value>
<string>
944.
23278.61726.21845
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -288,7 +288,7 @@
</tuple>
<state>
<tuple>
<float>
1436
545182.61
</float>
<float>
1436
802186.14
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/demo_interface2_html.xml
0 → 100644
View file @
17f60efd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Web Page"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_Access_contents_information_Permission
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Add_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Change_local_roles_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_Modify_portal_content_Permission
</string>
</key>
<value>
<tuple>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
_View_Permission
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
<string>
Assignee
</string>
<string>
Assignor
</string>
<string>
Associate
</string>
<string>
Auditor
</string>
<string>
Manager
</string>
<string>
Owner
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
content_md5
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/html
</string>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
demo_interface2.html
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
demo_interface2_html
</string>
</value>
</item>
<item>
<key>
<string>
language
</string>
</key>
<value>
<string>
en
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Web Page
</string>
</value>
</item>
<item>
<key>
<string>
short_title
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
<!DOCTYPE html>
\n
<html>
\n
<head>
\n
</head>
\n
<body>
\n
<h1>
interface2
</h1>
\n
<h3>
description of interface2
</h3>
\n
<dl>
\n
<dt>
testmethod1
</dt>
\n
<dd>
description of testmethod1
</dd>
\n
<dl></dl>
\n
<dt>
testmethod2
</dt>
\n
<dd>
description of testmethod2
</dd>
\n
<dl>
\n
<dt
data-parameter-required=
"required"
data-parameter-type=
"boolean"
>
param1
</dt>
\n
<dd>
description of param1
</dd>
\n
</dl>
\n
</dd>
\n
<dt>
testmethod3
</dt>
\n
<dd>
description of testmethod3
</dd>
\n
<dl>
\n
<dt
data-parameter-required=
"required"
data-parameter-type=
"int"
>
param1
</dt>
\n
<dd>
description of param1
</dd>
\n
<dt
data-parameter-required=
"optional"
>
param2
</dt>
\n
<dd>
description of param2
</dd>
\n
</dl>
\n
</dl>
\n
</body>
\n
</html>
]]>
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Demo Interface 2
</string>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
001
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
document_publication_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
edit_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
processing_status_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAU=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
publish_alive
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope1
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1436778695.92
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
published_alive
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
edit
</string>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.22907.16053.33399
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
<value>
<string>
current
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1436780039.01
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record
id=
"5"
aka=
"AAAAAAAAAAU="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
external_processing_state
</string>
</key>
<value>
<string>
empty
</string>
</value>
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
0.0.0.0
</string>
</value>
</item>
<item>
<key>
<string>
time
</string>
</key>
<value>
<object>
<klass>
<global
name=
"DateTime"
module=
"DateTime.DateTime"
/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>
1436778400.33
</float>
<string>
GMT
</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_html.xml
View file @
17f60efd
...
...
@@ -113,6 +113,7 @@
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
\n
\n
<link
rel=
"http://www.renderjs.org/rel/interface"
href=
"demo_interface1.html"
>
\n
<link
rel=
"http://www.renderjs.org/rel/interface"
href=
"demo_interface2.html"
>
\n
\n
<!-- renderjs -->
\n
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
\n
...
...
@@ -130,6 +131,9 @@
{{#each interface_item}}\n
<li>
\n
{{interface_name}}\n
<br>
\n
Status: {{status}}\n
</br>
\n
</li>
\n
{{/each}}\n
</ul>
\n
...
...
@@ -287,7 +291,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.
18548.40475.62395
</string>
</value>
<value>
<string>
944.
23131.33514.5051
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -305,7 +309,7 @@
</tuple>
<state>
<tuple>
<float>
1436
518406.8
</float>
<float>
1436
793348.9
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/gadget_interfacedemo_js.xml
View file @
17f60efd
...
...
@@ -134,18 +134,43 @@
.declareMethod("method3", function () {\n
return;\n
})\n
.declareMethod("testmethod1", function () {\n
return;\n
})\n
.declareMethod("testmethod2", function (param1) {\n
return;\n
})\n
.declareMethod("testmethod3", function (param1, param2) {\n
return;\n
})\n
\n
.declareMethod("interfaceGadgetTest", function (gadget, interface_gadget, interface_list) {\n
var interface_name = interface_list[0];\n
return new RSVP.Queue()\n
.push(function () {\n
return interface_gadget.getInterfaceData(interface_name);\n
})\n
.push(function (interface_data) {\n
console.log("interface_data", interface_data);\n
return interface_gadget.verifyInterfaceImplementation(gadget, interface_name);\n
var status_list = [],\n
key;\n
for (key in interface_list) {\n
status_list.push(interface_gadget.verifyInterfaceImplementation(gadget, interface_list[key]));\n
}\n
return RSVP.all(status_list);\n
})\n
.push(function (verification_status) {\n
console.log("Verification:", verification_status);\n
.push(function (result_list) {\n
var parameter = {interface_item: []},\n
key,\n
i = 0;\n
for (key in interface_list) {\n
parameter.interface_item.push({\n
interface_name: interface_list[key], \n
status: (result_list[i] ? "Verified Success":"Verified Failure")\n
});\n
i += 1;\n
}\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
title: "Interface List"\n
});\n
gadget.props.content_element.innerHTML =\n
gadget.props.interface_list_template(parameter);\n
$(gadget.props.element).trigger("create");\n
});\n
})\n
\n
...
...
@@ -159,31 +184,15 @@
});\n
})\n
.push(function () {\n
return gadget.getInterfaceList();\n
})\n
.push(function (interface_list) {\n
var parameter = {interface_item: []},\n
key;\n
for (key in interface_list) {\n
parameter.interface_item.push({\n
interface_name: interface_list[key]\n
});\n
}\n
gadget.props.header_element.innerHTML = gadget.props.header_template({\n
title: "Interface List"\n
});\n
gadget.props.content_element.innerHTML =\n
gadget.props.interface_list_template(parameter);\n
$(gadget.props.element).trigger("create");\n
return RSVP.all([\n
gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE),\n
interface_list
\n
gadget.getInterfaceList()
\n
]);\n
})\n
.push(function (interface_gadget_list) {\n
var interface_gadget = interface_gadget_list[0],\n
interface_list = interface_gadget_list[1];\n
return gadget.interfaceGadgetTest(gadget, interface_gadget, interface_list);\n
return gadget.interfaceGadgetTest(gadget, interface_gadget, interface_list);\n
});\n
});\n
\n
...
...
@@ -322,7 +331,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.
18996.27011.18756
</string>
</value>
<value>
<string>
944.
23155.255.46643
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -340,7 +349,7 @@
</tuple>
<state>
<tuple>
<float>
1436
545240.66
</float>
<float>
1436
795666.02
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
bt5/erp5_web_rjs_interfacedemo/PathTemplateItem/web_page_module/rjs_gadget_interfaces_js.xml
View file @
17f60efd
...
...
@@ -101,7 +101,8 @@
<key>
<string>
text_content
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
;/*\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
/*\n
* DOMParser HTML extension\n
* 2012-09-04\n
*\n
...
...
@@ -110,6 +111,7 @@
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n
*/\n
/*! @source https://gist.github.com/1129031 */\n
\n
(function (DOMParser) {\n
"use strict";\n
var DOMParser_proto = DOMParser.prototype,\n
...
...
@@ -146,57 +148,137 @@
};\n
}(DOMParser));\n
\n
;
/*global window, rJS, RSVP */\n
/*global window, rJS, RSVP */\n
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, Handlebars, $, RSVP, loopEventListener, DOMParser) {\n
"use strict";\n
\n
function verifyInterfaceDefiniti
ion
(interface_name) {\n
function verifyInterfaceDefiniti
on
(interface_name) {\n
//to verify if interface definition follows the correct template.\n
return RSVP.Queue()\n
.push(function () {\n
return jQuery.get(interface_name);\n
})\n
.push(function(file_data) {\n
var doc = (new DOMParser()).parseFromString(file_data, \'text/html\').body,\n
dl_list = doc.getElementsByTagName(\'dl\'),\n
next_element = dl_list[0].firstElementChild,\n
method_len = dl_list.length - 1,\n
defer = RSVP.defer();\n
if (dl_list[0].childElementCount !== 3*method_len) {\n
throw new Error("Interface Definition Incorrect.");\n
} \n
try {\n
for (var i=0; i<method_len; i+=1) {\n
if ((!next_element || next_element.localName !== "dt") ||\n
(!(next_element = next_element.nextElementSibling) || next_element.localName !== "dd") ||\n
(!(next_element = next_element.nextElementSibling) || next_element.localName !== "dl")) {\n
throw new Error("Interface Definition Incorrect.");\n
}\n
if(next_element.getElementsByTagName(\'dt\').length !== next_element.getElementsByTagName(\'dd\').length) {\n
throw new Error("Interface Definition Incorrect.");\n
}\n
var argument_len = next_element.getElementsByTagName(\'dt\').length,\n
next_child_element = next_element.firstElementChild;\n
for (var j=0; j<argument_len; j+=1) {\n
if ((!next_child_element || next_child_element.localName !== "dt") ||\n
(!(next_child_element = next_child_element.nextElementSibling) || next_child_element.localName !== "dd")) {\n
throw new Error("Interface Definition Incorrect.");\n
}\n
next_child_element = next_child_element.nextElementSibling;\n
}\n
next_element = next_element.nextElementSibling;\n
}\n
defer.resolve("Success");\n
} catch(error) {\n
defer.reject(error);\n
} \n
return defer.promise;\n
});\n
}\n
\n
function verifyInterfaceDeclaration
(interface_name, declared_interfaces
) {\n
function verifyInterfaceDeclaration
(interface_name, declared_interface_list
) {\n
//to verify if gadget declares the interface.\n
return declared_interfaces.indexOf(interface_name) >
-1;\n
var defer = RSVP.defer();\n
try {\n
if (declared_interface_list.indexOf(interface_name) >
-1) {\n
defer.resolve("Success");\n
} else {\n
throw new Error("Interface not declared.");\n
}\n
} catch(error) {\n
defer.reject(error);\n
}\n
return defer.promise;\n
}\n
\n
function verifyAllMethodsDeclared (interface_methods, gadget_methods) {\n
function verifyAllMethods(interface_method_list, gadget_method_list) {\n
var defer = RSVP.defer();\n
return RSVP.Queue()\n
.push(function() {\n
return verifyAllMethodsDeclared(interface_method_list, gadget_method_list);\n
})\n
.push(function() {\n
return verifyAllMethodsSignature(interface_method_list, gadget_method_list);\n
})\n
.push (function() {\n
defer.resolve("Success");\n
return defer.promise;\n
}, function(error) {\n
defer.reject(error);\n
return defer.promise;\n
});\n
}\n
\n
function verifyAllMethodsDeclared(interface_method_list, gadget_method_list) {\n
//to verify if all the interface methods are declared by the gadget.\n
var gadget_methods_names = [],\n
interface_methods_names = [];\n
for (var i=0; i
<gadget_methods.length
;
i+=1)
{\n
gadget_methods_names.push(gadget_methods[i].name);\n
var defer = RSVP.defer(),\n
gadget_method_name_list = [],\n
interface_method_name_list = [];\n
for (var i=0; i
<gadget_method_list.length
;
i+=1)
{\n
gadget_method_name_list.push(gadget_method_list[i].name);\n
}\n
for
(var
j=
0;
j<interface_method
s
.length;
j+=1)
{\n
interface_method
s_names.push(interface_methods
[j].name);\n
for
(var
j=
0;
j<interface_method
_list
.length;
j+=1)
{\n
interface_method
_name_list.push(interface_method_list
[j].name);\n
}\n
for
(var
k=
0;
k<interface_methods_names.length;
k+=1)
{\n
if(gadget_methods_names.indexOf(interface_methods_names[k])
<
0)
{\n
return
false;\n
try
{\n
for
(var
k=
0;
k<interface_method_name_list.length;
k+=1)
{\n
if(gadget_method_name_list.indexOf(interface_method_name_list[k])
<
0)
{\n
throw
new
Error("All
methods
are
not
declared.");\n
}\n
}\n
defer.resolve("Success");\n
}
catch(error)
{\n
defer.reject(error);\n
}\n
return
tru
e;\n
return
defer.promis
e;\n
}\n
\n
function
verifyAllMethodsSignature
(interface_methods,
gadget_methods
)
{\n
function
verifyAllMethodsSignature
(interface_method_list,
gadget_method_list
)
{\n
//to
verify
if
all
the
declared
methods
match
the
signature
of
the
interface
methods.\n
var
interface_methods_dict =
{},\n
var
defer =
RSVP.defer(),\n
interface_method_dict =
{},\n
gadget_methods_dict =
{};\n
for(var
i=
0;
i<interface_method
s
.length;
i+=1)
{\n
interface_method
s_dict[interface_methods[i].name]
=
interface_methods
[i];\n
for(var
i=
0;
i<interface_method
_list
.length;
i+=1)
{\n
interface_method
_dict[interface_method_list[i].name]
=
interface_method_list
[i];\n
}\n
for(var
j=
0;
j<gadget_method
s
.length;
j+=1)
{\n
gadget_methods_dict[gadget_method
s[j].name]
=
gadget_methods
[j];\n
for(var
j=
0;
j<gadget_method
_list
.length;
j+=1)
{\n
gadget_methods_dict[gadget_method
_list[j].name]
=
gadget_method_list
[j];\n
}\n
for(var
item
in
interface_methods_dict)
{\n
if(!verifyMethodSignature(interface_methods_dict[item],
gadget_methods_dict[item]))
{\n
return
false;\n
try
{\n
for(var
item
in
interface_method_dict)
{\n
if(!verifyMethodSignature(interface_method_dict[item],
gadget_methods_dict[item]))
{\n
throw
new
Error("All
methods
signature
do
not
match.");\n
}\n
}\n
defer.resolve("Success");\n
}
catch(error)
{\n
defer.reject(error);\n
}\n
return
tru
e;\n
return
defer.promis
e;\n
}\n
\n
function
verifyMethodSignature
(interface_method,
gadget_method)
{\n
\n
function
verifyMethodSignature(interface_method,
gadget_method)
{\n
//to
verify
if
two
methods
have
the
same
signature\n
var
max_arg_len =
interface_method.argument_list.length,\n
min_arg_len =
0;\n
...
...
@@ -217,30 +299,18 @@
})\n
\n
.declareMethod("getDeclaredGadgetInterfaces", function (gadget) {\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getInterfaceList();\n
})\n
.push(function (declared_interfaces) {\n
return declared_interfaces;\n
});\n
return gadget.getInterfaceList();\n
})\n
\n
.declareMethod("getDeclaredGadgetMethods", function (gadget) {\n
return RSVP.Queue()\n
.push(function() {\n
return gadget.getDeclaredMethodList();\n
})\n
.push(function (declared_methods) {\n
return declared_methods;\n
});\n
return gadget.getDeclaredMethodList();\n
})\n
\n
.declareMethod("getInterfaceData", function (interface_name) {\n
var interface_data = {\n
name: "",\n
description: "",\n
method
s
: []\n
method
_list
: []\n
};\n
return RSVP.Queue()\n
.push(function() {\n
...
...
@@ -269,13 +339,13 @@
var
argument_item =
{\n
name:
dt_list[dt_count].innerText,\n
description:
dd_list[dt_count].innerText,\n
required:
dt_list[dt_count].getAttribute("
class
")
===
"optional"
?
false:true,\n
type:
dt_list[dt_count].getAttribute("type")\n
required:
dt_list[dt_count].getAttribute("
data-parameter-required
")
===
"optional"
?
false:true,\n
type:
dt_list[dt_count].getAttribute("
data-parameter-
type")\n
};\n
dt_count
+=
1;\n
method.argument_list.push(argument_item);\n
}\n
interface_data.method
s
.push(method);\n
interface_data.method
_list
.push(method);\n
}\n
return
interface_data;\n
});\n
...
...
@@ -284,7 +354,7 @@
.declareMethod("getDefinedInterfaceMethods",
function
(interface_name)
{\n
return
this.getInterfaceData(interface_name)\n
.push(function(interface_data)
{\n
return
interface_data.method
s
;\n
return
interface_data.method
_list
;\n
});\n
})\n
\n
...
...
@@ -292,48 +362,30 @@
var
interface_gadget =
this;\n
return
RSVP.Queue()\n
.push(function
()
{\n
return
interface_gadget.getDeclaredGadgetInterfaces(gadget);\n
})\n
.push(function
(declared_interfaces)
{\n
return
verifyInterfaceDeclaration(interface_name,
declared_interfaces);\n
return
verifyInterfaceDefinition(interface_name);\n
})\n
.push(function
(verified)
{\n
if
(!verified)
{\n
throw
new
Error("Interface
not
declared.");\n
}\n
return
RSVP.all([\n
interface_gadget.getDefinedInterfaceMethods(interface_name),\n
interface_gadget.getDeclaredGadgetMethods(gadget)\n
]);\n
.push(function
()
{\n
return
interface_gadget.getDeclaredGadgetInterfaces(gadget);\n
})\n
.push(function
(methods
_list)
{\n
return
verify
AllMethodsDeclared(methods_list[0],
methods_list[1]
);\n
.push(function
(declared_interface
_list)
{\n
return
verify
InterfaceDeclaration(interface_name,
declared_interface_list
);\n
})\n
.push(function
(verified)
{\n
if
(!verified)
{\n
throw
new
Error("All
methods
are
not
declared.");\n
}\n
.push(function
()
{\n
return
RSVP.all([\n
interface_gadget.getDefinedInterfaceMethods(interface_name),\n
interface_gadget.getDeclaredGadgetMethods(gadget)\n
]);\n
})\n
.push(function(methods_list)
{\n
return
verifyAllMethodsSignature(methods_list[0],
methods_list[1]);\n
})\n
.push(function
(verified)
{\n
if
(!verified)
{\n
throw
new
Error("All
methods
signature
do
not
match.");\n
}\n
.push(function(method_list)
{\n
return
verifyAllMethods(method_list[0],
method_list[1]);\n
})\n
.push
(function()
{\n
console.log("Verified
:
Success");\n
return
true;\n
},
function(error
_message
)
{\n
console.log("Verified
:
Failure",
error
_message
);\n
},
function(error)
{\n
console.log("Verified
:
Failure",
error);\n
return
false;\n
});\n
\n
});\n
\n
}(window,
rJS,
Handlebars,
jQuery,
RSVP,
loopEventListener,
DOMParser));
...
...
@@ -473,7 +525,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
944.
18970.20251.32904
</string>
</value>
<value>
<string>
944.
23277.56085.50961
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -491,7 +543,7 @@
</tuple>
<state>
<tuple>
<float>
1436
544696.2
</float>
<float>
1436
802159.16
</float>
<string>
GMT
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment