Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
af3fb549
Commit
af3fb549
authored
Jun 15, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_gadget_interface_validator] JSLint
parent
fe9a9c94
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
550 additions
and
464 deletions
+550
-464
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_js.js
...r/PathTemplateItem/web_page_module/gadget_interface_js.js
+397
-325
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_js.xml
.../PathTemplateItem/web_page_module/gadget_interface_js.xml
+2
-2
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_form_js.js
...eb_page_module/gadget_interface_validator_page_form_js.js
+40
-33
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_form_js.xml
...b_page_module/gadget_interface_validator_page_form_js.xml
+2
-2
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_report_js.js
..._page_module/gadget_interface_validator_page_report_js.js
+93
-87
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_report_js.xml
...page_module/gadget_interface_validator_page_report_js.xml
+2
-2
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_router_js.js
...m/web_page_module/gadget_interface_validator_router_js.js
+12
-11
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_router_js.xml
.../web_page_module/gadget_interface_validator_router_js.xml
+2
-2
No files found.
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_js.js
View file @
af3fb549
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 30, maxlen: 80 */
/*global DOMParser, document, XMLHttpRequest, rJS, renderJS, RSVP, window*/
/*
/*
* DOMParser HTML extension
* DOMParser HTML extension
* 2012-09-04
* 2012-09-04
...
@@ -8,7 +9,7 @@
...
@@ -8,7 +9,7 @@
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
*/
/*! @source https://gist.github.com/1129031 */
/*! @source https://gist.github.com/1129031 */
(
function
(
DOMParser
)
{
(
function
(
DOMParser
,
document
)
{
"
use strict
"
;
"
use strict
"
;
var
DOMParser_proto
=
DOMParser
.
prototype
,
var
DOMParser_proto
=
DOMParser
.
prototype
,
real_parseFromString
=
DOMParser_proto
.
parseFromString
;
real_parseFromString
=
DOMParser_proto
.
parseFromString
;
...
@@ -42,11 +43,9 @@
...
@@ -42,11 +43,9 @@
}
}
return
result
;
return
result
;
};
};
}(
DOMParser
));
}(
DOMParser
,
document
));
/*global window, rJS, RSVP */
(
function
(
window
,
rJS
,
RSVP
,
DOMParser
,
XMLHttpRequest
,
renderJS
)
{
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
RSVP
,
DOMParser
)
{
"
use strict
"
;
"
use strict
"
;
function
ajax
(
url
)
{
function
ajax
(
url
)
{
var
xhr
;
var
xhr
;
...
@@ -88,13 +87,13 @@
...
@@ -88,13 +87,13 @@
function
fetchAppcacheData
(
appcache_url
)
{
function
fetchAppcacheData
(
appcache_url
)
{
var
defer
=
RSVP
.
defer
();
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
appcache_url
);
return
ajax
(
appcache_url
);
})
})
.
push
(
function
(
xhr
)
{
.
push
(
function
(
xhr
)
{
var
filename_list
=
xhr
.
responseText
.
split
(
'
\n
'
);
var
filename_list
=
xhr
.
responseText
.
split
(
'
\n
'
);
return
filename_list
;
return
filename_list
;
},
function
(
error
)
{
},
function
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
return
defer
.
promise
;
return
defer
.
promise
;
});
});
...
@@ -107,20 +106,20 @@
...
@@ -107,20 +106,20 @@
ext
,
ext
,
file_name
,
file_name
,
last_index
,
last_index
,
i
tem
;
i
;
for
(
item
in
filename_list
)
{
for
(
i
=
0
;
i
<
filename_list
.
length
;
i
+=
1
)
{
last_index
=
filename_list
[
i
tem
].
lastIndexOf
(
'
.
'
);
last_index
=
filename_list
[
i
].
lastIndexOf
(
'
.
'
);
file_name
=
filename_list
[
i
tem
].
substr
(
0
,
last_index
);
file_name
=
filename_list
[
i
].
substr
(
0
,
last_index
);
ext
=
filename_list
[
i
tem
].
substr
(
last_index
+
1
);
ext
=
filename_list
[
i
].
substr
(
last_index
+
1
);
if
(
ext
===
"
html
"
)
{
if
(
ext
===
"
html
"
)
{
html_list
.
push
(
file_name
);
html_list
.
push
(
file_name
);
}
else
if
(
ext
===
"
js
"
)
{
}
else
if
(
ext
===
"
js
"
)
{
js_list
.
push
(
file_name
);
js_list
.
push
(
file_name
);
}
}
}
}
for
(
item
in
html_list
)
{
for
(
i
=
0
;
i
<
html_list
.
length
;
i
+=
1
)
{
if
(
js_list
.
indexOf
(
html_list
[
i
tem
])
>
-
1
)
{
if
(
js_list
.
indexOf
(
html_list
[
i
])
>
-
1
)
{
gadget_list
.
push
(
html_list
[
i
tem
]
+
"
.html
"
);
gadget_list
.
push
(
html_list
[
i
]
+
"
.html
"
);
}
}
}
}
return
gadget_list
;
return
gadget_list
;
...
@@ -128,77 +127,99 @@
...
@@ -128,77 +127,99 @@
function
generateErrorMessage
(
error
)
{
function
generateErrorMessage
(
error
)
{
var
error_message
=
''
;
var
error_message
=
''
;
error_message
=
error_message
error_message
=
error_message
+
+
error
.
toString
()
error
.
toString
()
+
+
(
error
.
message
!==
undefined
?
error
.
message
:
''
)
(
error
.
message
!==
undefined
?
error
.
message
:
''
)
+
+
(
error
.
status
?
error
.
status
.
toString
()
+
'
'
:
''
)
(
error
.
status
?
error
.
status
.
toString
()
+
'
'
:
''
)
+
+
(
error
.
statusText
!==
undefined
?
error
.
statusText
:
''
);
(
error
.
statusText
!==
undefined
?
error
.
statusText
:
''
);
return
error_message
;
return
error_message
;
}
}
function
getInterfaceListFromURL
(
gadget_url
)
{
function
getInterfaceListFromURL
(
gadget_url
)
{
var
defer
=
RSVP
.
defer
();
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
gadget_url
);
return
ajax
(
gadget_url
);
})
})
.
push
(
function
(
xhr
)
{
.
push
(
function
(
xhr
)
{
var
document_element
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
),
var
document_element
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
),
interface_list
=
[],
interface_list
=
[],
element
,
element
,
i
;
i
;
if
(
document_element
.
nodeType
===
9
&&
document_element
.
head
!==
null
)
{
if
(
document_element
.
nodeType
===
9
&&
document_element
.
head
!==
null
)
{
for
(
i
=
0
;
i
<
document_element
.
head
.
children
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
document_element
.
head
.
children
.
length
;
i
+=
1
)
{
element
=
document_element
.
head
.
children
[
i
];
element
=
document_element
.
head
.
children
[
i
];
if
(
element
.
href
!==
null
&&
element
.
rel
===
"
http://www.renderjs.org/rel/interface
"
)
{
if
(
element
.
href
!==
null
&&
element
.
rel
===
"
http://www.renderjs.org/rel/interface
"
)
{
interface_list
.
push
(
interface_list
.
push
(
renderJS
.
getAbsoluteURL
(
element
.
getAttribute
(
"
href
"
),
window
.
location
.
href
)
renderJS
.
getAbsoluteURL
(
element
.
getAttribute
(
"
href
"
),
window
.
location
.
href
)
);
);
}
}
}
}
}
}
return
interface_list
;
return
interface_list
;
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the gadget data.
\n
"
;
var
message
=
"
Error with loading the gadget data.
\n
"
;
error
.
message
=
message
+
generateErrorMessage
(
error
);
error
.
message
=
message
+
generateErrorMessage
(
error
);
defer
.
reject
(
error
);
defer
.
reject
(
error
);
return
defer
.
promise
;
return
defer
.
promise
;
});
});
}
}
function
verifyInterfaceDefinition
(
interface_url
)
{
function
verifyInterfaceDefinition
(
interface_url
)
{
//to verify if interface definition follows the correct template.
//to verify if interface definition follows the correct template.
var
error_message
=
"
Interface definition is incorrect: One or more required tags are missing.
"
,
var
error_message
=
"
Interface definition is incorrect:
"
+
"
One or more required tags are missing.
"
,
defer
=
RSVP
.
defer
();
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
interface_url
);
return
ajax
(
interface_url
);
})
})
.
push
(
function
(
xhr
)
{
.
push
(
function
(
xhr
)
{
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
).
body
,
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
).
body
,
dl_list
=
doc
.
getElementsByTagName
(
'
dl
'
),
dl_list
=
doc
.
getElementsByTagName
(
'
dl
'
),
next_element
=
dl_list
[
0
].
firstElementChild
,
next_element
=
dl_list
[
0
].
firstElementChild
,
method_len
=
dl_list
.
length
-
1
,
method_len
=
dl_list
.
length
-
1
,
i
;
argument_len
,
if
(
dl_list
[
0
].
childElementCount
!==
3
*
method_len
)
{
next_child_element
,
i
,
j
;
if
(
dl_list
[
0
].
childElementCount
!==
3
*
method_len
)
{
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
try
{
try
{
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
if
((
!
next_element
||
next_element
.
localName
.
toLowerCase
()
!==
'
dt
'
)
||
if
((
next_element
===
null
)
||
(
!
(
next_element
=
next_element
.
nextElementSibling
)
||
next_element
.
localName
.
toLowerCase
()
!==
'
dd
'
)
||
(
next_element
.
localName
.
toLowerCase
()
!==
'
dt
'
))
{
(
!
(
next_element
=
next_element
.
nextElementSibling
)
||
next_element
.
localName
.
toLowerCase
()
!==
'
dl
'
))
{
throw
new
Error
(
error_message
);
}
next_element
=
next_element
.
nextElementSibling
;
if
(
next_element
.
localName
.
toLowerCase
()
!==
'
dd
'
)
{
throw
new
Error
(
error_message
);
}
next_element
=
next_element
.
nextElementSibling
;
if
(
next_element
.
localName
.
toLowerCase
()
!==
'
dl
'
)
{
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
if
(
next_element
.
getElementsByTagName
(
'
dt
'
).
length
!==
next_element
.
getElementsByTagName
(
'
dd
'
).
length
)
{
if
(
next_element
.
getElementsByTagName
(
'
dt
'
).
length
!==
next_element
.
getElementsByTagName
(
'
dd
'
).
length
)
{
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
var
argument_len
=
next_element
.
getElementsByTagName
(
'
dt
'
).
length
,
argument_len
=
next_element
.
getElementsByTagName
(
'
dt
'
).
length
;
next_child_element
=
next_element
.
firstElementChild
,
next_child_element
=
next_element
.
firstElementChild
;
j
;
for
(
j
=
0
;
j
<
argument_len
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
argument_len
;
j
+=
1
)
{
if
((
!
next_child_element
||
next_child_element
.
localName
.
toLowerCase
()
!==
'
dt
'
)
||
if
((
next_child_element
===
null
)
||
(
!
(
next_child_element
=
next_child_element
.
nextElementSibling
)
||
next_child_element
.
localName
.
toLowerCase
()
!==
'
dd
'
))
{
(
next_child_element
.
localName
.
toLowerCase
()
!==
'
dt
'
))
{
throw
new
Error
(
error_message
);
}
next_child_element
=
next_child_element
.
nextElementSibling
;
if
(
next_child_element
.
localName
.
toLowerCase
()
!==
'
dd
'
)
{
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
next_child_element
=
next_child_element
.
nextElementSibling
;
next_child_element
=
next_child_element
.
nextElementSibling
;
...
@@ -206,11 +227,11 @@
...
@@ -206,11 +227,11 @@
next_element
=
next_element
.
nextElementSibling
;
next_element
=
next_element
.
nextElementSibling
;
}
}
defer
.
resolve
(
"
Success
"
);
defer
.
resolve
(
"
Success
"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
}
}
return
defer
.
promise
;
return
defer
.
promise
;
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the interface data.
\n
"
;
var
message
=
"
Error with loading the interface data.
\n
"
;
error
.
message
=
message
+
generateErrorMessage
(
error
);
error
.
message
=
message
+
generateErrorMessage
(
error
);
defer
.
reject
(
error
);
defer
.
reject
(
error
);
...
@@ -227,119 +248,135 @@
...
@@ -227,119 +248,135 @@
}
else
{
}
else
{
throw
new
Error
(
"
Interface is not declared.
"
);
throw
new
Error
(
"
Interface is not declared.
"
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
}
}
return
defer
.
promise
;
return
defer
.
promise
;
}
}
function
verifyAllMethod
(
interface_method_list
,
gadget_method_list
)
{
/*
//to verify all methods of gadget and interface.
function verifyMethodSignature(interface_method, gadget_method) {
var
defer
=
RSVP
.
defer
();
//to verify if two methods have the same signature
return
new
RSVP
.
Queue
()
var max_arg_len = interface_method.argument_list.length,
.
push
(
function
()
{
min_arg_len = 0,
return
verifyAllMethodDeclared
(
interface_method_list
,
gadget_method_list
[
0
]);
i,
})
argument_list;
/* Commented till figure out the way to fetch the argument length of a defined function.
if (max_arg_len) {
.push(function() {
argument_list = interface_method.argument_list;
return verifyAllMethodSignature(interface_method_list, gadget_method_list[1]);
for (i = 0; i < argument_list.length; i += 1) {
})
if (argument_list[i].required) {
*/
min_arg_len += 1;
.
push
(
function
()
{
}
defer
.
resolve
(
"
Success
"
);
}
return
defer
.
promise
;
}
},
function
(
error
)
{
return (gadget_method.arg_len >= min_arg_len &&
defer
.
reject
(
error
);
gadget_method.arg_len <= max_arg_len);
return
defer
.
promise
;
});
}
}
function
verifyAllMethodDeclared
(
interface_method_list
,
gadget_method_list
)
{
function verifyAllMethodSignature(interface_method_list, gadget_method_list) {
//to verify if all the interface methods are declared by the gadget.
//to verify if all the declared methods match the signature
// of the interface methods.
var defer = RSVP.defer(),
var defer = RSVP.defer(),
gadget_method_name_list
=
gadget_method_list
,
interface_method_dict = {},
interface_method_name_list
=
[],
gadget_method_name_list = [],
i
,
j
,
index,
item,
i,
j,
failed = false,
failed = false,
failed_methods = [];
failed_methods = [];
for (i = 0; i < interface_method_list.length; i += 1) {
for (i = 0; i < interface_method_list.length; i += 1) {
interface_method_name_list
.
push
(
interface_method_list
[
i
].
name
);
interface_method_dict[interface_method_list[i].name] =
interface_method_list[i];
}
for (j = 0; j < gadget_method_list.length; j += 1) {
gadget_method_name_list.push(gadget_method_list[j].name);
}
}
try {
try {
for
(
j
=
0
;
j
<
interface_method_name_list
.
length
;
j
+=
1
)
{
for (item in interface_method_dict) {
if
(
gadget_method_name_list
.
indexOf
(
interface_method_name_list
[
j
])
<
0
)
{
index = gadget_method_name_list.lastIndexOf(item);
if (!verifyMethodSignature(interface_method_dict[item],
gadget_method_list[index])) {
failed = true;
failed = true;
failed_methods
.
push
(
i
nterface_method_name_list
[
j
]
);
failed_methods.push(i
tem
);
}
}
}
}
if
(
failed
)
{
if (failed) {
var
error_message
=
"
Following required methods are not declared in the gadget:
"
,
var error_message =
"Following methods have missing/mismatched arguments: ",
method;
method;
for
(
method
in
failed_methods
)
{
for
(method in failed_methods) {
error_message += ("\n" + failed_methods[method]);
error_message += ("\n" + failed_methods[method]);
}
}
throw new Error(error_message);
throw new Error(error_message);
}
}
defer.resolve("Success");
defer.resolve("Success");
}
catch
(
error
)
{
} catch
(error) {
defer.reject(error);
defer.reject(error);
}
}
return defer.promise;
return defer.promise;
}
}
*/
function
verifyAllMethod
Signature
(
interface_method_list
,
gadget_method_list
)
{
function
verifyAllMethod
Declared
(
interface_method_list
,
gadget_method_list
)
{
//to verify if all the
declared methods match the signature of the interface methods
.
//to verify if all the
interface methods are declared by the gadget
.
var
defer
=
RSVP
.
defer
(),
var
defer
=
RSVP
.
defer
(),
interface_method_dict
=
{},
gadget_method_name_list
=
gadget_method_list
,
gadget_method_name_list
=
[],
interface_method_name_list
=
[],
index
,
i
,
item
,
j
,
i
,
j
,
failed
=
false
,
failed
=
false
,
failed_methods
=
[];
failed_methods
=
[],
for
(
i
=
0
;
i
<
interface_method_list
.
length
;
i
+=
1
)
{
error_message
;
interface_method_dict
[
interface_method_list
[
i
].
name
]
=
interface_method_list
[
i
];
for
(
i
=
0
;
i
<
interface_method_list
.
length
;
i
+=
1
)
{
}
interface_method_name_list
.
push
(
interface_method_list
[
i
].
name
);
for
(
j
=
0
;
j
<
gadget_method_list
.
length
;
j
+=
1
)
{
gadget_method_name_list
.
push
(
gadget_method_list
[
j
].
name
);
}
}
try
{
try
{
for
(
item
in
interface_method_dict
)
{
for
(
j
=
0
;
j
<
interface_method_name_list
.
length
;
j
+=
1
)
{
index
=
gadget_method_name_list
.
lastIndexOf
(
item
);
if
(
gadget_method_name_list
.
indexOf
(
if
(
!
verifyMethodSignature
(
interface_method_dict
[
item
],
gadget_method_list
[
index
]))
{
interface_method_name_list
[
j
]
)
<
0
)
{
failed
=
true
;
failed
=
true
;
failed_methods
.
push
(
i
tem
);
failed_methods
.
push
(
i
nterface_method_name_list
[
j
]
);
}
}
}
}
if
(
failed
)
{
if
(
failed
)
{
var
error_message
=
"
Following methods have missing/mismatched arguments:
"
,
error_message
=
method
;
"
Following required methods are not declared in the gadget:
"
;
for
(
method
in
failed_methods
)
{
for
(
i
=
0
;
i
<
failed_methods
.
length
;
i
+=
1
)
{
error_message
+=
(
"
\n
"
+
failed_methods
[
method
]);
error_message
+=
(
"
\n
"
+
failed_methods
[
i
]);
}
}
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
defer
.
resolve
(
"
Success
"
);
defer
.
resolve
(
"
Success
"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
}
}
return
defer
.
promise
;
return
defer
.
promise
;
}
}
function
verifyMethodSignature
(
interface_method
,
gadget_method
)
{
function
verifyAllMethod
(
interface_method_list
,
gadget_method_list
)
{
//to verify if two methods have the same signature
//to verify all methods of gadget and interface.
var
max_arg_len
=
interface_method
.
argument_list
.
length
,
var
defer
=
RSVP
.
defer
();
min_arg_len
=
0
,
return
new
RSVP
.
Queue
()
i
;
.
push
(
function
()
{
if
(
max_arg_len
)
{
return
verifyAllMethodDeclared
(
interface_method_list
,
var
argument_list
=
interface_method
.
argument_list
;
gadget_method_list
[
0
]);
for
(
i
=
0
;
i
<
argument_list
.
length
;
i
+=
1
)
{
})
if
(
argument_list
[
i
].
required
)
{
/* Commented till figure out the way to fetch the argument length of a
min_arg_len
+=
1
;
defined function.
}
.push(function() {
}
return verifyAllMethodSignature(interface_method_list,
}
gadget_method_list[1]);
return
(
gadget_method
.
arg_len
>=
min_arg_len
&&
gadget_method
.
arg_len
<=
max_arg_len
);
})
*/
.
push
(
function
()
{
defer
.
resolve
(
"
Success
"
);
return
defer
.
promise
;
},
function
(
error
)
{
defer
.
reject
(
error
);
return
defer
.
promise
;
});
}
}
rJS
(
window
)
rJS
(
window
)
...
@@ -358,7 +395,7 @@
...
@@ -358,7 +395,7 @@
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
interface_gadget
.
getDeclaredGadget
(
gadget_url
);
return
interface_gadget
.
getDeclaredGadget
(
gadget_url
);
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the gadget.
\n
"
;
var
message
=
"
Error with loading the gadget.
\n
"
;
error
.
message
=
message
+
error
.
message
;
error
.
message
=
message
+
error
.
message
;
defer
.
reject
(
error
);
defer
.
reject
(
error
);
...
@@ -367,19 +404,17 @@
...
@@ -367,19 +404,17 @@
})
})
.
declareMethod
(
"
getDeclaredGadgetInterfaceList
"
,
function
(
gadget_data
)
{
.
declareMethod
(
"
getDeclaredGadgetInterfaceList
"
,
function
(
gadget_data
)
{
var
interface_gadget
=
this
,
var
defer
=
RSVP
.
defer
();
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
if
(
gadget_data
.
constructor
===
String
)
{
if
(
gadget_data
.
constructor
===
String
)
{
return
getInterfaceListFromURL
(
gadget_data
);
return
getInterfaceListFromURL
(
gadget_data
);
}
else
{
return
gadget_data
.
getInterfaceList
();
}
}
return
gadget_data
.
getInterfaceList
();
})
})
.
push
(
function
(
interface_list
)
{
.
push
(
function
(
interface_list
)
{
return
interface_list
;
return
interface_list
;
},
function
(
error
)
{
},
function
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
return
defer
.
promise
;
return
defer
.
promise
;
});
});
...
@@ -389,32 +424,36 @@
...
@@ -389,32 +424,36 @@
var
declared_method_dict
=
{},
var
declared_method_dict
=
{},
declared_method_list
=
[],
declared_method_list
=
[],
item
;
item
;
for
(
item
in
gadget
)
{
for
(
item
in
gadget
.
constructor
.
prototype
)
{
if
(
!
(
/__/
).
test
(
item
))
{
if
(
gadget
.
constructor
.
prototype
.
hasOwnProperty
(
item
))
{
declared_method_dict
[
item
]
=
gadget
[
item
];
if
(
!
(
/__/
).
test
(
item
))
{
declared_method_dict
[
item
]
=
gadget
[
item
];
}
}
}
for
(
item
in
declared_method_dict
)
{
if
(
declared_method_dict
.
hasOwnProperty
(
item
))
{
declared_method_list
.
push
(
item
);
}
}
}
}
for
(
item
in
declared_method_dict
)
{
declared_method_list
.
push
(
item
);
}
return
RSVP
.
all
([
return
RSVP
.
all
([
declared_method_list
//,
declared_method_list
//,
// gadget.getDeclaredMethodList()
// gadget.getDeclaredMethodList()
]);
]);
})
})
.
declareMethod
(
"
getGadgetListFromAppcache
"
,
function
(
appcache_url
)
{
.
declareMethod
(
"
getGadgetListFromAppcache
"
,
function
(
appcache_url
)
{
var
defer
=
RSVP
.
defer
();
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
fetchAppcacheData
(
appcache_url
);
return
fetchAppcacheData
(
appcache_url
);
})
})
.
push
(
function
(
filename_list
)
{
.
push
(
function
(
filename_list
)
{
return
filterGadgetList
(
filename_list
);
return
filterGadgetList
(
filename_list
);
})
})
.
push
(
function
(
filtered_gadget_list
)
{
.
push
(
function
(
filtered_gadget_list
)
{
return
filtered_gadget_list
;
return
filtered_gadget_list
;
},
function
(
error
)
{
},
function
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
return
defer
.
promise
;
return
defer
.
promise
;
});
});
...
@@ -422,10 +461,10 @@
...
@@ -422,10 +461,10 @@
.
declareMethod
(
"
getAbsoluteURL
"
,
function
(
gadget
,
url
)
{
.
declareMethod
(
"
getAbsoluteURL
"
,
function
(
gadget
,
url
)
{
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
getPath
();
return
gadget
.
getPath
();
})
})
.
push
(
function
(
base_url
)
{
.
push
(
function
(
base_url
)
{
return
rJS
.
getAbsoluteURL
(
url
,
base_url
);
return
rJS
.
getAbsoluteURL
(
url
,
base_url
);
});
});
})
})
...
@@ -438,222 +477,255 @@
...
@@ -438,222 +477,255 @@
},
},
defer
=
RSVP
.
defer
();
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
interface_url
);
return
ajax
(
interface_url
);
})
})
.
push
(
function
(
xhr
)
{
.
push
(
function
(
xhr
)
{
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
).
body
,
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
).
body
,
dl_list
=
doc
.
getElementsByTagName
(
'
dl
'
),
dl_list
=
doc
.
getElementsByTagName
(
'
dl
'
),
dt_list
=
doc
.
getElementsByTagName
(
'
dt
'
),
dt_list
=
doc
.
getElementsByTagName
(
'
dt
'
),
dd_list
=
doc
.
getElementsByTagName
(
'
dd
'
),
dd_list
=
doc
.
getElementsByTagName
(
'
dd
'
),
method_len
=
dl_list
.
length
-
1
,
method_len
=
dl_list
.
length
-
1
,
dt_count
=
0
,
dt_count
=
0
,
dl_count
=
1
,
dl_count
=
1
,
i
;
i
,
method
,
argument_len
,
j
,
argument_item
;
interface_data
.
name
=
doc
.
getElementsByTagName
(
'
h1
'
)[
0
].
innerHTML
;
interface_data
.
name
=
doc
.
getElementsByTagName
(
'
h1
'
)[
0
].
innerHTML
;
interface_data
.
description
=
doc
.
getElementsByTagName
(
'
h3
'
)[
0
].
innerHTML
;
interface_data
.
description
=
doc
.
getElementsByTagName
(
'
h3
'
)[
0
].
innerHTML
;
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
var
method
=
{
method
=
{
name
:
dt_list
[
dt_count
].
innerHTML
,
name
:
dt_list
[
dt_count
].
innerHTML
,
description
:
dd_list
[
dt_count
].
innerHTML
,
description
:
dd_list
[
dt_count
].
innerHTML
,
argument_list
:
[]
argument_list
:
[]
},
};
argument_len
=
dl_list
[
dl_count
].
getElementsByTagName
(
'
dt
'
).
length
,
argument_len
=
dl_list
[
dl_count
].
getElementsByTagName
(
'
dt
'
)
j
;
.
length
;
dt_count
+=
1
;
dt_count
+=
1
;
dl_count
+=
1
;
dl_count
+=
1
;
for
(
j
=
0
;
j
<
argument_len
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
argument_len
;
j
+=
1
)
{
var
argument_item
=
{
argument_item
=
{
name
:
dt_list
[
dt_count
].
innerHTML
,
name
:
dt_list
[
dt_count
].
innerHTML
,
description
:
dd_list
[
dt_count
].
innerHTML
,
description
:
dd_list
[
dt_count
].
innerHTML
,
required
:
dt_list
[
dt_count
].
getAttribute
(
"
data-parameter-required
"
)
===
"
optional
"
?
false
:
true
,
required
:
dt_list
[
dt_count
]
type
:
dt_list
[
dt_count
].
getAttribute
(
"
data-parameter-type
"
)
.
getAttribute
(
"
data-parameter-required
"
)
!==
"
optional
"
,
};
type
:
dt_list
[
dt_count
].
getAttribute
(
"
data-parameter-type
"
)
};
dt_count
+=
1
;
dt_count
+=
1
;
method
.
argument_list
.
push
(
argument_item
);
method
.
argument_list
.
push
(
argument_item
);
}
}
interface_data
.
method_list
.
push
(
method
);
interface_data
.
method_list
.
push
(
method
);
}
}
return
interface_data
;
return
interface_data
;
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the interface data.
\n
"
;
var
message
=
"
Error with loading the interface data.
\n
"
;
error
.
message
=
message
+
generateErrorMessage
(
error
);
error
.
message
=
message
+
generateErrorMessage
(
error
);
defer
.
reject
(
error
);
defer
.
reject
(
error
);
return
defer
.
promise
;
return
defer
.
promise
;
});
});
})
})
.
declareMethod
(
"
getDefinedInterfaceMethodList
"
,
function
(
interface_url
)
{
.
declareMethod
(
"
getDefinedInterfaceMethodList
"
,
function
(
interface_url
)
{
var
defer
=
RSVP
.
defer
();
var
defer
=
RSVP
.
defer
();
return
this
.
getInterfaceData
(
interface_url
)
return
this
.
getInterfaceData
(
interface_url
)
.
push
(
function
(
interface_data
)
{
.
push
(
function
(
interface_data
)
{
return
interface_data
.
method_list
;
return
interface_data
.
method_list
;
},
function
(
error
)
{
},
function
(
error
)
{
defer
.
reject
(
error
);
defer
.
reject
(
error
);
return
defer
.
promise
;
return
defer
.
promise
;
});
});
})
})
.
declareMethod
(
"
getGadgetListImplementingInterface
"
,
function
(
interface_data
,
gadget_source_data
)
{
.
declareMethod
(
"
getGadgetListImplementingInterface
"
,
var
interface_gadget
=
this
,
function
(
interface_data
,
gadget_source_data
)
{
interface_list
,
var
interface_gadget
=
this
,
gadget_list
;
interface_list
,
return
new
RSVP
.
Queue
()
gadget_list
;
.
push
(
function
()
{
return
new
RSVP
.
Queue
()
var
required_interface_list
=
[];
.
push
(
function
()
{
if
(
!
interface_data
)
{
var
required_interface_list
=
[];
throw
new
Error
(
"
Invalid input: No interface data is provided.
"
);
if
(
!
interface_data
)
{
}
else
if
(
interface_data
.
constructor
===
Array
)
{
throw
new
Error
(
"
Invalid input: No interface data is provided.
"
);
required_interface_list
=
interface_data
;
}
else
if
(
interface_data
.
constructor
===
String
)
{
required_interface_list
.
push
(
interface_data
);
}
else
{
throw
new
Error
(
"
Invalid input: Invalid interface data is provided.
"
);
}
return
required_interface_list
;
})
.
push
(
function
(
i_list
)
{
var
source_gadget_list
=
[];
interface_list
=
i_list
;
if
(
!
gadget_source_data
)
{
throw
new
Error
(
"
Invalid input: No gadget source information is provided.
"
);
}
else
if
(
gadget_source_data
.
constructor
===
Array
)
{
source_gadget_list
=
gadget_source_data
;
}
else
if
(
gadget_source_data
.
constructor
===
String
)
{
source_gadget_list
=
interface_gadget
.
getGadgetListFromAppcache
(
gadget_source_data
);
}
else
{
throw
new
Error
(
"
Invalid input: Invalid gadget source information is provided.
"
);
}
return
source_gadget_list
;
})
.
push
(
function
(
g_list
)
{
var
item
,
result_list
=
[];
gadget_list
=
g_list
;
for
(
item
in
gadget_list
)
{
result_list
.
push
(
interface_gadget
.
verifyGadgetInterfaceImplementation
(
gadget_list
[
item
],
interface_list
));
}
return
RSVP
.
all
(
result_list
);
})
.
push
(
function
(
result_list
)
{
var
item
,
result_gadget_list
=
[];
for
(
item
in
result_list
)
{
if
(
result_list
[
item
].
result
===
true
)
{
result_gadget_list
.
push
(
gadget_list
[
item
]);
}
}
}
if
(
interface_data
.
constructor
===
Array
)
{
return
result_gadget_list
;
required_interface_list
=
interface_data
;
});
}
else
if
(
interface_data
.
constructor
===
String
)
{
})
required_interface_list
.
push
(
interface_data
);
}
else
{
throw
new
Error
(
"
Invalid input: Invalid interface data is provided.
"
);
}
return
required_interface_list
;
})
.
push
(
function
(
i_list
)
{
var
source_gadget_list
=
[];
interface_list
=
i_list
;
if
(
!
gadget_source_data
)
{
throw
new
Error
(
"
Invalid input: No gadget source information is provided.
"
);
}
if
(
gadget_source_data
.
constructor
===
Array
)
{
source_gadget_list
=
gadget_source_data
;
}
else
if
(
gadget_source_data
.
constructor
===
String
)
{
source_gadget_list
=
interface_gadget
.
getGadgetListFromAppcache
(
gadget_source_data
);
}
else
{
throw
new
Error
(
"
Invalid input: Invalid gadget source information is provided.
"
);
}
return
source_gadget_list
;
})
.
push
(
function
(
g_list
)
{
var
i
,
result_list
=
[];
gadget_list
=
g_list
;
for
(
i
=
0
;
i
<
gadget_list
.
length
;
i
+=
1
)
{
result_list
.
push
(
interface_gadget
.
verifyGadgetInterfaceImplementation
(
gadget_list
[
i
],
interface_list
)
);
}
return
RSVP
.
all
(
result_list
);
})
.
push
(
function
(
result_list
)
{
var
i
,
result_gadget_list
=
[];
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
if
(
result_list
[
i
].
result
)
{
result_gadget_list
.
push
(
gadget_list
[
i
]);
}
}
return
result_gadget_list
;
});
})
.
declareMethod
(
"
verifyGadgetSingleInterfaceImplementation
"
,
function
(
verify_gadget
,
interface_url
)
{
.
declareMethod
(
"
verifyGadgetSingleInterfaceImplementation
"
,
var
interface_gadget
=
this
,
function
(
verify_gadget
,
interface_url
)
{
absolute_interface_url
,
var
interface_gadget
=
this
,
verify_result
=
{};
absolute_interface_url
,
return
new
RSVP
.
Queue
()
verify_result
=
{};
.
push
(
function
()
{
return
new
RSVP
.
Queue
()
return
RSVP
.
all
([
.
push
(
function
()
{
interface_gadget
.
getDeclaredGadgetInterfaceList
(
verify_gadget
),
return
RSVP
.
all
([
interface_gadget
.
getAbsoluteURL
(
verify_gadget
,
interface_url
)
interface_gadget
.
getDeclaredGadgetInterfaceList
(
verify_gadget
),
]);
interface_gadget
.
getAbsoluteURL
(
verify_gadget
,
interface_url
)
})
]);
.
push
(
function
(
interface_detail
)
{
})
var
declared_interface_list
=
interface_detail
[
0
];
.
push
(
function
(
interface_detail
)
{
absolute_interface_url
=
interface_detail
[
1
];
var
declared_interface_list
=
interface_detail
[
0
];
return
verifyInterfaceDeclaration
(
absolute_interface_url
,
declared_interface_list
);
absolute_interface_url
=
interface_detail
[
1
];
})
return
verifyInterfaceDeclaration
(
absolute_interface_url
,
.
push
(
function
()
{
declared_interface_list
);
return
verifyInterfaceDefinition
(
absolute_interface_url
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
verifyInterfaceDefinition
(
absolute_interface_url
);
return
RSVP
.
all
([
})
interface_gadget
.
getDefinedInterfaceMethodList
(
absolute_interface_url
),
.
push
(
function
()
{
interface_gadget
.
getDeclaredGadgetMethodList
(
verify_gadget
)
return
RSVP
.
all
([
]);
interface_gadget
.
getDefinedInterfaceMethodList
(
})
absolute_interface_url
.
push
(
function
(
method_list
)
{
),
return
verifyAllMethod
(
method_list
[
0
],
method_list
[
1
]);
interface_gadget
.
getDeclaredGadgetMethodList
(
verify_gadget
)
})
]);
.
push
(
function
()
{
})
verify_result
.
result
=
true
;
.
push
(
function
(
method_list
)
{
return
verify_result
;
return
verifyAllMethod
(
method_list
[
0
],
method_list
[
1
]);
},
function
(
error
)
{
})
var
interface_name
=
absolute_interface_url
.
substr
(
absolute_interface_url
.
lastIndexOf
(
'
/
'
)
+
1
),
.
push
(
function
()
{
error_message
;
verify_result
.
result
=
true
;
error_message
=
"
Interface Name:
"
+
interface_name
+
"
\n
"
return
verify_result
;
+
"
Error Details :
\n
"
+
error
.
message
+
"
\n
"
;
},
function
(
error
)
{
verify_result
.
result
=
false
;
var
interface_name
=
absolute_interface_url
.
substr
(
verify_result
.
details
=
error_message
;
absolute_interface_url
.
lastIndexOf
(
'
/
'
)
+
1
return
verify_result
;
),
});
error_message
;
})
error_message
=
"
Interface Name:
"
+
interface_name
+
"
\n
"
+
"
Error Details :
\n
"
+
error
.
message
+
"
\n
"
;
verify_result
.
result
=
false
;
verify_result
.
details
=
error_message
;
return
verify_result
;
});
})
.
declareMethod
(
"
verifyGadgetInterfaceImplementation
"
,
function
(
gadget_data
,
interface_data
)
{
.
declareMethod
(
"
verifyGadgetInterfaceImplementation
"
,
var
interface_gadget
=
this
,
function
(
gadget_data
,
interface_data
)
{
verify_gadget
,
var
interface_gadget
=
this
,
interface_list
,
verify_gadget
,
verify_result
=
{},
interface_list
,
declared_gadget
=
false
;
verify_result
=
{};
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
var
required_gadget
;
var
required_gadget
;
if
(
!
gadget_data
)
{
if
(
!
gadget_data
)
{
throw
new
Error
(
"
Invalid input: No gadget data is provided.
"
);
throw
new
Error
(
"
Invalid input: No gadget data is provided.
"
);
}
else
if
(
gadget_data
.
constructor
===
String
)
{
verify_result
.
gadget_url
=
gadget_data
;
declared_gadget
=
true
;
required_gadget
=
interface_gadget
.
getVerifyGadget
(
gadget_data
);
}
else
{
required_gadget
=
gadget_data
;
}
return
required_gadget
;
})
.
push
(
function
(
required_gadget
)
{
var
required_interface_list
=
[];
verify_gadget
=
required_gadget
;
if
(
!
interface_data
)
{
required_interface_list
=
interface_gadget
.
getDeclaredGadgetInterfaceList
(
verify_gadget
);
}
else
if
(
interface_data
.
constructor
===
Array
)
{
required_interface_list
=
interface_data
;
}
else
if
(
interface_data
.
constructor
===
String
)
{
required_interface_list
.
push
(
interface_data
);
}
return
required_interface_list
;
})
.
push
(
function
(
required_interface_list
)
{
var
interface_url
,
result_list
=
[],
item
;
interface_list
=
required_interface_list
;
for
(
item
in
interface_list
)
{
interface_url
=
interface_list
[
item
];
result_list
.
push
(
interface_gadget
.
verifyGadgetSingleInterfaceImplementation
(
verify_gadget
,
interface_url
));
}
return
RSVP
.
all
(
result_list
);
})
.
push
(
function
(
result_list
)
{
var
item
,
failed
=
false
,
error_message
=
''
;
for
(
item
in
result_list
)
{
if
(
!
result_list
[
item
].
result
)
{
failed
=
true
;
error_message
+=
(
result_list
[
item
].
details
+
'
\n
'
);
}
}
}
if
(
gadget_data
.
constructor
===
String
)
{
if
(
failed
)
{
verify_result
.
gadget_url
=
gadget_data
;
throw
new
Error
(
error_message
);
required_gadget
=
interface_gadget
.
getVerifyGadget
(
gadget_data
);
}
}
else
{
})
required_gadget
=
gadget_data
;
.
push
(
function
()
{
}
verify_result
.
result
=
true
;
return
required_gadget
;
return
verify_result
;
})
},
function
(
error
)
{
.
push
(
function
(
required_gadget
)
{
verify_result
.
result
=
false
;
var
required_interface_list
=
[];
verify_result
.
details
=
error
.
message
;
verify_gadget
=
required_gadget
;
return
verify_result
;
if
(
!
interface_data
)
{
});
required_interface_list
=
});
interface_gadget
.
getDeclaredGadgetInterfaceList
(
verify_gadget
);
}
else
if
(
interface_data
.
constructor
===
Array
)
{
required_interface_list
=
interface_data
;
}
else
if
(
interface_data
.
constructor
===
String
)
{
required_interface_list
.
push
(
interface_data
);
}
return
required_interface_list
;
})
.
push
(
function
(
required_interface_list
)
{
var
result_list
=
[],
i
;
interface_list
=
required_interface_list
;
for
(
i
=
0
;
i
<
interface_list
.
length
;
i
+=
1
)
{
result_list
.
push
(
interface_gadget
.
verifyGadgetSingleInterfaceImplementation
(
verify_gadget
,
interface_list
[
i
]
)
);
}
return
RSVP
.
all
(
result_list
);
})
.
push
(
function
(
result_list
)
{
var
i
,
failed
=
false
,
error_message
=
''
;
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
if
(
!
result_list
[
i
].
result
)
{
failed
=
true
;
error_message
+=
(
result_list
[
i
].
details
+
'
\n
'
);
}
}
if
(
failed
)
{
throw
new
Error
(
error_message
);
}
})
.
push
(
function
()
{
verify_result
.
result
=
true
;
return
verify_result
;
},
function
(
error
)
{
verify_result
.
result
=
false
;
verify_result
.
details
=
error
.
message
;
return
verify_result
;
});
});
}(
window
,
rJS
,
RSVP
,
DOMParser
));
}(
window
,
rJS
,
RSVP
,
DOMParser
,
XMLHttpRequest
,
renderJS
));
\ No newline at end of file
\ No newline at end of file
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_js.xml
View file @
af3fb549
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
46.46289.58152.58624
</string>
</value>
<value>
<string>
9
68.15557.27071.42905
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
446475754.
4
</float>
<float>
1
529069154.3
4
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_form_js.js
View file @
af3fb549
/*global window, rJS, RSVP, Handlebars */
/*global window, rJS, RSVP, Handlebars
, $, loopEventListener
*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 3
, maxlen: 80
*/
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
)
{
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
$
,
loopEventListener
)
{
"
use strict
"
;
"
use strict
"
;
var
INTERFACE_GADGET_SCOPE
=
"
interface_gadget
"
;
var
INTERFACE_GADGET_SCOPE
=
"
interface_gadget
"
,
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
gadget_klass
=
rJS
(
window
),
source
=
gadget_klass
.
__template_element
.
getElementById
(
"
interface-validator-template
"
)
.
innerHTML
,
interface_validator_template
=
Handlebars
.
compile
(
source
);
function
fetchPageType
(
gadget_url
)
{
function
fetchPageType
(
gadget_url
)
{
var
page_type
=
''
,
var
page_type
=
''
,
key
=
'
_page_
'
;
key
=
'
_page_
'
;
if
(
gadget_url
.
indexOf
(
key
)
>
-
1
)
{
if
(
gadget_url
.
indexOf
(
key
)
>
-
1
)
{
page_type
=
gadget_url
.
substring
(
gadget_url
.
indexOf
(
key
)
+
key
.
length
,
page_type
=
gadget_url
.
substring
(
gadget_url
.
indexOf
(
key
)
+
key
.
length
,
gadget_url
.
lastIndexOf
(
'
.
'
));
gadget_url
.
lastIndexOf
(
'
.
'
));
}
}
return
page_type
;
return
page_type
;
}
}
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var
gadget_klass
=
rJS
(
window
),
source
=
gadget_klass
.
__template_element
.
getElementById
(
"
interface-validator-template
"
)
.
innerHTML
,
interface_validator_template
=
Handlebars
.
compile
(
source
);
gadget_klass
gadget_klass
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// ready
// ready
...
@@ -38,7 +37,7 @@
...
@@ -38,7 +37,7 @@
.
ready
(
function
(
g
)
{
.
ready
(
function
(
g
)
{
return
g
.
getElement
()
return
g
.
getElement
()
.
push
(
function
(
element
)
{
.
push
(
function
(
element
)
{
g
.
props
.
element
=
element
,
g
.
props
.
element
=
element
;
g
.
props
.
content_element
=
element
.
querySelector
(
'
.appcache_form
'
);
g
.
props
.
content_element
=
element
.
querySelector
(
'
.appcache_form
'
);
});
});
})
})
...
@@ -56,10 +55,11 @@
...
@@ -56,10 +55,11 @@
.
declareMethod
(
"
render
"
,
function
(
options
)
{
.
declareMethod
(
"
render
"
,
function
(
options
)
{
var
gadget
=
this
;
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
var
error_message
=
''
;
var
error_message
=
''
;
if
(
options
.
found
!==
undefined
&&
options
.
found
===
'
false
'
)
{
if
(
options
.
found
!==
undefined
&&
options
.
found
===
'
false
'
)
{
error_message
=
"
Error: Cannot load the appcache file. Please check and try again.
"
;
error_message
=
"
Error: Cannot load the appcache file.
"
+
"
Please check and try again.
"
;
}
}
gadget
.
props
.
content_element
.
innerHTML
=
gadget
.
props
.
content_element
.
innerHTML
=
interface_validator_template
({
interface_validator_template
({
...
@@ -76,7 +76,9 @@
...
@@ -76,7 +76,9 @@
.
declareService
(
function
()
{
.
declareService
(
function
()
{
////////////////////////////////////
////////////////////////////////////
// Form submit listening. Prevent browser to automatically handle the form submit in case of a bug
// Form submit listening.
// Prevent browser to automatically handle the form submit in
// case of a bug
////////////////////////////////////
////////////////////////////////////
var
gadget
=
this
;
var
gadget
=
this
;
function
formSubmit
(
submit_event
)
{
function
formSubmit
(
submit_event
)
{
...
@@ -88,37 +90,42 @@
...
@@ -88,37 +90,42 @@
.
disabled
=
true
;
.
disabled
=
true
;
return
submit_event
.
target
[
0
].
value
;
return
submit_event
.
target
[
0
].
value
;
})
})
.
push
(
function
(
submit_url
)
{
.
push
(
function
(
submit_url
)
{
appcache_url
=
submit_url
;
appcache_url
=
submit_url
;
return
gadget
.
getDeclaredGadget
(
INTERFACE_GADGET_SCOPE
);
return
gadget
.
getDeclaredGadget
(
INTERFACE_GADGET_SCOPE
);
})
})
.
push
(
function
(
i_gadget
)
{
.
push
(
function
(
i_gadget
)
{
var
required_interface
=
'
gadget_interface_validator_reportpage_interface.html
'
,
var
required_interface
=
'
gadget_interface_validator_reportpage_interface.html
'
,
gadget_source_url
=
'
gadget_interface_validator.appcache
'
;
gadget_source_url
=
'
gadget_interface_validator.appcache
'
;
interface_gadget
=
i_gadget
;
interface_gadget
=
i_gadget
;
return
interface_gadget
.
getGadgetListImplementingInterface
(
required_interface
,
gadget_source_url
);
return
interface_gadget
.
getGadgetListImplementingInterface
(
required_interface
,
gadget_source_url
);
})
})
.
push
(
function
(
gadget_list
)
{
.
push
(
function
(
gadget_list
)
{
if
(
gadget_list
.
length
>
0
)
{
if
(
gadget_list
.
length
>
0
)
{
var
page_type
=
fetchPageType
(
gadget_list
[
0
]);
var
page_type
=
fetchPageType
(
gadget_list
[
0
]);
return
gadget
.
redirect
({
return
gadget
.
redirect
({
page
:
page_type
,
page
:
page_type
,
appcache_url
:
appcache_url
appcache_url
:
appcache_url
});
});
}
else
{
return
gadget
.
redirect
({
found
:
false
});
}
}
return
gadget
.
redirect
({
found
:
false
});
});
});
}
}
// Listen to form submit
// Listen to form submit
return
loopEventListener
(
return
loopEventListener
(
gadget
.
props
.
content_element
.
querySelector
(
'
form.interface-validation-form
'
),
gadget
.
props
.
content_element
.
querySelector
(
'
form.interface-validation-form
'
),
'
submit
'
,
'
submit
'
,
false
,
false
,
formSubmit
formSubmit
);
);
});
});
}(
window
,
rJS
,
RSVP
,
Handlebars
));
}(
window
,
rJS
,
RSVP
,
Handlebars
,
$
,
loopEventListener
));
\ No newline at end of file
\ No newline at end of file
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_form_js.xml
View file @
af3fb549
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
46.54877.22908.40635
</string>
</value>
<value>
<string>
9
68.15277.3815.5239
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
446717901.46
</float>
<float>
1
529052317.55
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_report_js.js
View file @
af3fb549
/*global window, rJS, RSVP, Handlebars */
/*global window, rJS, RSVP, Handlebars
, loopEventListener, $, document
*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 3
, maxlen: 80
*/
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
)
{
(
function
(
window
,
rJS
,
RSVP
,
Handlebars
,
loopEventListener
,
$
,
document
)
{
"
use strict
"
;
"
use strict
"
;
var
INTERFACE_GADGET_SCOPE
=
"
interface_gadget
"
;
var
INTERFACE_GADGET_SCOPE
=
"
interface_gadget
"
,
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
gadget_klass
=
rJS
(
window
),
templater
=
gadget_klass
.
__template_element
,
report_widget_table
=
Handlebars
.
compile
(
templater
.
getElementById
(
"
report-widget-table
"
).
innerHTML
);
function
renderInitialReport
(
gadget
,
gadget_list
)
{
function
renderInitialReport
(
gadget
,
gadget_list
)
{
var
gadget_info_list
=
[],
var
row_list
=
[],
row_list
=
[],
column_list
=
[
'
Gadget Name
'
,
'
Declared Interfaces
'
,
'
Validation Status
'
],
column_list
=
[
'
Gadget Name
'
,
'
Declared Interfaces
'
,
'
Validation Status
'
],
cell_list
,
cell_list
,
default_status
=
"
In Progress
"
,
default_status
=
"
In Progress
"
,
content
=
''
,
content
=
''
,
item
;
i
;
for
(
item
in
gadget_list
)
{
for
(
i
=
0
;
i
<
gadget_list
.
length
;
i
+=
1
)
{
cell_list
=
[];
cell_list
=
[{
cell_list
.
push
({
default_class
:
"
gadget_name
"
,
default_class
:
"
gadget_name
"
,
value
:
gadget_list
[
item
]
value
:
gadget_list
[
i
]
});
},
{
cell_list
.
push
({
default_class
:
"
interface_list
"
,
default_class
:
"
interface_list
"
,
value
:
default_status
value
:
default_status
});
},
{
cell_list
.
push
({
default_class
:
"
validation_status
"
,
default_class
:
"
validation_status
"
,
value
:
default_status
value
:
default_status
}
)
;
}
]
;
row_list
.
push
({
row_list
.
push
({
"
cell_list
"
:
cell_list
,
"
cell_list
"
:
cell_list
,
"
default_id
"
:
gadget_list
[
i
tem
].
substr
(
0
,
gadget_list
[
item
].
indexOf
(
'
.
'
))
"
default_id
"
:
gadget_list
[
i
].
substr
(
0
,
gadget_list
[
i
].
indexOf
(
'
.
'
))
});
});
}
}
content
+=
report_widget_table
({
content
+=
report_widget_table
({
column_list
:
column_list
,
column_list
:
column_list
,
...
@@ -40,55 +45,33 @@
...
@@ -40,55 +45,33 @@
$
(
gadget
.
props
.
element
).
trigger
(
"
create
"
);
$
(
gadget
.
props
.
element
).
trigger
(
"
create
"
);
}
}
function
validateAppGadgetList
(
gadget
,
gadget_list
){
var
item
;
for
(
item
in
gadget_list
)
{
updateGadgetData
(
gadget
,
gadget_list
[
item
]);
}
}
function
updateGadgetData
(
gadget
,
verify_gadget_url
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
verifyGadgetImplementation
(
gadget
,
verify_gadget_url
);
})
.
push
(
function
(
verify_result
)
{
var
result_dict
=
{
id
:
verify_gadget_url
.
substr
(
0
,
verify_gadget_url
.
indexOf
(
'
.
'
)),
gadget_name
:
verify_gadget_url
,
interface_list
:
verify_result
[
0
],
validation_status
:
verify_result
[
1
].
result
,
validation_message
:
verify_result
[
1
].
result_message
,
error_detail
:
verify_result
[
1
].
details
};
return
updateReportData
(
gadget
,
result_dict
);
});
}
function
verifyGadgetImplementation
(
gadget
,
verify_gadget_url
)
{
function
verifyGadgetImplementation
(
gadget
,
verify_gadget_url
)
{
var
interface_gadget
,
var
interface_gadget
,
interface_list
=
[],
interface_list
=
[],
default_validation_status
=
{
result
:
"
N/A
"
};
default_validation_status
=
{
result
:
"
N/A
"
};
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
INTERFACE_GADGET_SCOPE
);
return
gadget
.
getDeclaredGadget
(
INTERFACE_GADGET_SCOPE
);
})
})
.
push
(
function
(
i_gadget
)
{
.
push
(
function
(
i_gadget
)
{
interface_gadget
=
i_gadget
;
interface_gadget
=
i_gadget
;
return
interface_gadget
.
getDeclaredGadgetInterfaceList
(
verify_gadget_url
);
return
interface_gadget
.
getDeclaredGadgetInterfaceList
(
verify_gadget_url
);
})
})
.
push
(
function
(
temp_interface_list
)
{
.
push
(
function
(
temp_interface_list
)
{
interface_list
=
temp_interface_list
;
interface_list
=
temp_interface_list
;
if
(
interface_list
.
length
>
0
)
{
if
(
interface_list
.
length
>
0
)
{
return
interface_gadget
.
verifyGadgetInterfaceImplementation
(
verify_gadget_url
);
return
interface_gadget
.
verifyGadgetInterfaceImplementation
(
}
verify_gadget_url
else
{
);
return
default_validation_status
;
}
}
return
default_validation_status
;
})
})
.
push
(
function
(
validation_status
)
{
.
push
(
function
(
validation_status
)
{
return
[
interface_list
,
validation_status
];
return
[
interface_list
,
validation_status
];
},
function
(
error
)
{
},
function
(
error
)
{
default_validation_status
.
result
=
false
;
default_validation_status
.
result
=
false
;
default_validation_status
.
result_message
=
"
Error with gadget loading
"
;
default_validation_status
.
result_message
=
"
Error with gadget loading
"
;
default_validation_status
.
details
=
error
.
message
;
default_validation_status
.
details
=
error
.
message
;
...
@@ -97,62 +80,85 @@
...
@@ -97,62 +80,85 @@
}
}
function
updateReportData
(
gadget
,
report_data
)
{
function
updateReportData
(
gadget
,
report_data
)
{
var
id
=
"
#
"
+
report_data
.
id
.
replace
(
'
/
'
,
'
\\
/
'
),
var
id
=
"
#
"
+
report_data
.
id
.
replace
(
'
/
'
,
'
\\
/
'
),
update_element
=
gadget
.
props
.
content_element
.
querySelector
(
id
),
update_element
=
gadget
.
props
.
content_element
.
querySelector
(
id
),
interface_data
=
''
,
interface_data
=
''
,
validation_status
=
report_data
.
validation_status
,
validation_status
=
report_data
.
validation_status
,
validation_message
=
report_data
.
validation_message
;
validation_message
=
report_data
.
validation_message
,
i
,
interface_name
;
if
(
report_data
.
interface_list
.
length
)
{
if
(
report_data
.
interface_list
.
length
)
{
var
item
,
for
(
i
=
0
;
i
<
report_data
.
interface_list
.
length
;
i
+=
1
)
{
interface_name
;
interface_name
=
report_data
.
interface_list
[
i
].
substr
(
for
(
item
in
report_data
.
interface_list
)
{
report_data
.
interface_list
[
i
].
lastIndexOf
(
'
/
'
)
+
1
interface_name
=
report_data
.
interface_list
[
item
].
substr
(
report_data
.
interface_list
[
item
].
lastIndexOf
(
'
/
'
)
+
1
);
);
interface_data
+=
(
interface_name
+
'
<br />
'
);
interface_data
+=
(
interface_name
+
'
<br />
'
);
}
}
}
else
{
}
else
{
interface_data
=
'
None
'
;
interface_data
=
'
None
'
;
}
}
if
(
report_data
.
validation_status
===
true
)
{
if
(
report_data
.
validation_status
===
true
)
{
validation_status
=
"
Success
"
;
validation_status
=
"
Success
"
;
update_element
.
setAttribute
(
'
style
'
,
'
color: green
'
);
update_element
.
setAttribute
(
'
style
'
,
'
color: green
'
);
}
}
if
(
report_data
.
validation_status
===
false
)
{
if
(
report_data
.
validation_status
===
false
)
{
validation_status
=
(
validation_message
!==
undefined
?
validation_message
:
"
Failure
"
);
validation_status
=
(
validation_message
!==
undefined
?
validation_message
:
"
Failure
"
);
update_element
.
setAttribute
(
'
style
'
,
'
cursor: pointer; color: red
'
);
update_element
.
setAttribute
(
'
style
'
,
'
cursor: pointer; color: red
'
);
update_element
.
className
+=
"
error expand
"
;
update_element
.
className
+=
"
error expand
"
;
}
}
gadget
.
props
.
error_data
[
report_data
.
id
]
=
report_data
.
error_detail
;
gadget
.
props
.
error_data
[
report_data
.
id
]
=
report_data
.
error_detail
;
update_element
.
querySelector
(
"
.validation_status
"
).
innerHTML
=
validation_status
;
update_element
.
querySelector
(
"
.validation_status
"
).
innerHTML
=
validation_status
;
update_element
.
querySelector
(
"
.validation_status
"
).
className
+=
"
final
"
;
update_element
.
querySelector
(
"
.validation_status
"
).
className
+=
"
final
"
;
update_element
.
querySelector
(
"
.interface_list
"
).
innerHTML
=
interface_data
;
update_element
.
querySelector
(
"
.interface_list
"
).
innerHTML
=
interface_data
;
}
}
function
updateGadgetData
(
gadget
,
verify_gadget_url
)
{
return
RSVP
.
Queue
()
.
push
(
function
()
{
return
verifyGadgetImplementation
(
gadget
,
verify_gadget_url
);
})
.
push
(
function
(
verify_result
)
{
var
result_dict
=
{
id
:
verify_gadget_url
.
substr
(
0
,
verify_gadget_url
.
indexOf
(
'
.
'
)),
gadget_name
:
verify_gadget_url
,
interface_list
:
verify_result
[
0
],
validation_status
:
verify_result
[
1
].
result
,
validation_message
:
verify_result
[
1
].
result_message
,
error_detail
:
verify_result
[
1
].
details
};
return
updateReportData
(
gadget
,
result_dict
);
});
}
function
validateAppGadgetList
(
gadget
,
gadget_list
)
{
var
i
;
for
(
i
=
0
;
i
<
gadget_list
.
length
;
i
+=
1
)
{
updateGadgetData
(
gadget
,
gadget_list
[
i
]);
}
}
function
toggleErrorRow
(
gadget
,
source_element
)
{
function
toggleErrorRow
(
gadget
,
source_element
)
{
if
(
source_element
.
className
.
indexOf
(
"
expand
"
)
>
-
1
)
{
if
(
source_element
.
className
.
indexOf
(
"
expand
"
)
>
-
1
)
{
var
error_tr
=
document
.
createElement
(
'
tr
'
),
var
error_tr
=
document
.
createElement
(
'
tr
'
),
error_td
=
error_tr
.
insertCell
(
0
);
error_td
=
error_tr
.
insertCell
(
0
);
error_tr
.
id
=
source_element
.
id
+
'
_errordata
'
;
error_tr
.
id
=
source_element
.
id
+
'
_errordata
'
;
error_td
.
className
=
'
errordata
'
;
error_td
.
className
=
'
errordata
'
;
error_td
.
colSpan
=
"
3
"
;
error_td
.
colSpan
=
"
3
"
;
error_td
.
innerText
=
gadget
.
props
.
error_data
[
source_element
.
id
];
error_td
.
innerText
=
gadget
.
props
.
error_data
[
source_element
.
id
];
source_element
.
parentNode
.
insertBefore
(
error_tr
,
source_element
.
nextSibling
);
source_element
.
parentNode
.
insertBefore
(
error_tr
,
source_element
.
className
=
source_element
.
className
.
replace
(
"
expand
"
,
"
shrink
"
);
source_element
.
nextSibling
);
}
else
if
(
source_element
.
className
.
indexOf
(
"
shrink
"
)
>
-
1
)
{
source_element
.
className
=
source_element
.
className
.
replace
(
"
expand
"
,
"
shrink
"
);
}
else
if
(
source_element
.
className
.
indexOf
(
"
shrink
"
)
>
-
1
)
{
source_element
.
parentNode
.
removeChild
(
source_element
.
nextSibling
);
source_element
.
parentNode
.
removeChild
(
source_element
.
nextSibling
);
source_element
.
className
=
source_element
.
className
.
replace
(
"
shrink
"
,
"
expand
"
);
source_element
.
className
=
source_element
.
className
.
replace
(
"
shrink
"
,
"
expand
"
);
}
}
return
;
return
;
}
}
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var
gadget_klass
=
rJS
(
window
),
templater
=
gadget_klass
.
__template_element
,
report_widget_table
=
Handlebars
.
compile
(
templater
.
getElementById
(
"
report-widget-table
"
).
innerHTML
);
Handlebars
.
registerPartial
(
Handlebars
.
registerPartial
(
"
report-widget-table-partial
"
,
"
report-widget-table-partial
"
,
templater
.
getElementById
(
"
report-widget-table-partial
"
).
innerHTML
templater
.
getElementById
(
"
report-widget-table-partial
"
).
innerHTML
...
@@ -172,7 +178,7 @@
...
@@ -172,7 +178,7 @@
.
ready
(
function
(
g
)
{
.
ready
(
function
(
g
)
{
return
g
.
getElement
()
return
g
.
getElement
()
.
push
(
function
(
element
)
{
.
push
(
function
(
element
)
{
g
.
props
.
element
=
element
,
g
.
props
.
element
=
element
;
g
.
props
.
content_element
=
element
.
querySelector
(
'
.validation_report
'
);
g
.
props
.
content_element
=
element
.
querySelector
(
'
.validation_report
'
);
});
});
})
})
...
@@ -182,26 +188,26 @@
...
@@ -182,26 +188,26 @@
appcache_url
=
options
.
appcache_url
,
appcache_url
=
options
.
appcache_url
,
gadget_list
;
gadget_list
;
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
gadget
.
getDeclaredGadget
(
INTERFACE_GADGET_SCOPE
);
return
gadget
.
getDeclaredGadget
(
INTERFACE_GADGET_SCOPE
);
})
})
.
push
(
function
(
interface_gadget
)
{
.
push
(
function
(
interface_gadget
)
{
return
interface_gadget
.
getGadgetListFromAppcache
(
appcache_url
);
return
interface_gadget
.
getGadgetListFromAppcache
(
appcache_url
);
})
})
.
push
(
function
(
filtered_gadget_list
)
{
.
push
(
function
(
filtered_gadget_list
)
{
gadget_list
=
filtered_gadget_list
;
gadget_list
=
filtered_gadget_list
;
return
renderInitialReport
(
gadget
,
gadget_list
);
return
renderInitialReport
(
gadget
,
gadget_list
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
validateAppGadgetList
(
gadget
,
gadget_list
);
return
validateAppGadgetList
(
gadget
,
gadget_list
);
},
function
(
error
)
{
},
function
(
)
{
return
gadget
.
redirect
({
return
gadget
.
redirect
({
found
:
false
found
:
false
});
});
});
});
})
})
.
declareMethod
(
"
reportPageDummyMethod1
"
,
function
(
param1
)
{
.
declareMethod
(
"
reportPageDummyMethod1
"
,
function
(
)
{
// A dummy method to fulfil the interface implementation requirement.
// A dummy method to fulfil the interface implementation requirement.
return
;
return
;
})
})
...
@@ -219,7 +225,7 @@
...
@@ -219,7 +225,7 @@
function
rowSubmit
(
submit_data
)
{
function
rowSubmit
(
submit_data
)
{
var
parent_element
=
submit_data
.
target
.
parentElement
;
var
parent_element
=
submit_data
.
target
.
parentElement
;
if
(
parent_element
.
className
.
indexOf
(
"
error
"
)
>
-
1
)
{
if
(
parent_element
.
className
.
indexOf
(
"
error
"
)
>
-
1
)
{
return
toggleErrorRow
(
gadget
,
parent_element
);
return
toggleErrorRow
(
gadget
,
parent_element
);
}
}
}
}
...
@@ -232,4 +238,4 @@
...
@@ -232,4 +238,4 @@
);
);
});
});
}(
window
,
rJS
,
RSVP
,
Handlebars
));
}(
window
,
rJS
,
RSVP
,
Handlebars
,
loopEventListener
,
$
,
document
));
\ No newline at end of file
\ No newline at end of file
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_page_report_js.xml
View file @
af3fb549
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
46.54878.32293.23654
</string>
</value>
<value>
<string>
9
68.15263.39947.11758
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
446717974.43
</float>
<float>
1
529051525.57
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_router_js.js
View file @
af3fb549
/*global window, rJS */
/*global window, rJS
, document, loopEventListener, RSVP
*/
/*jslint nomen: true, indent: 2 */
/*jslint nomen: true, indent: 2
, maxlen: 80
*/
(
function
(
window
,
rJS
)
{
(
function
(
window
,
rJS
,
document
,
loopEventListener
,
RSVP
)
{
"
use strict
"
;
"
use strict
"
;
var
MAIN_PAGE_PREFIX
=
"
gadget_interface_validator_
"
,
var
MAIN_PAGE_PREFIX
=
"
gadget_interface_validator_
"
,
DEFAULT_PAGE
=
"
form
"
,
DEFAULT_PAGE
=
"
form
"
,
REDIRECT_TIMEOUT
=
5000
;
REDIRECT_TIMEOUT
=
5000
;
...
@@ -23,7 +23,8 @@
...
@@ -23,7 +23,8 @@
if
(
subhash
!==
''
)
{
if
(
subhash
!==
''
)
{
keyvalue
=
subhash
.
split
(
'
=
'
);
keyvalue
=
subhash
.
split
(
'
=
'
);
if
(
keyvalue
.
length
===
2
)
{
if
(
keyvalue
.
length
===
2
)
{
args
[
decodeURIComponent
(
keyvalue
[
0
])]
=
decodeURIComponent
(
keyvalue
[
1
]);
args
[
decodeURIComponent
(
keyvalue
[
0
])]
=
decodeURIComponent
(
keyvalue
[
1
]);
}
}
}
}
}
}
...
@@ -52,7 +53,7 @@
...
@@ -52,7 +53,7 @@
};
};
})
})
.
declareMethod
(
"
getCommandUrlFor
"
,
function
(
options
)
{
.
declareMethod
(
"
getCommandUrlFor
"
,
function
(
options
)
{
var
prefix
=
''
,
var
prefix
=
''
,
result
,
result
,
key
;
key
;
...
@@ -60,7 +61,8 @@
...
@@ -60,7 +61,8 @@
for
(
key
in
options
)
{
for
(
key
in
options
)
{
if
(
options
.
hasOwnProperty
(
key
)
&&
options
[
key
]
!==
undefined
)
{
if
(
options
.
hasOwnProperty
(
key
)
&&
options
[
key
]
!==
undefined
)
{
// Don't keep empty values
// Don't keep empty values
result
+=
prefix
+
encodeURIComponent
(
key
)
+
"
=
"
+
encodeURIComponent
(
options
[
key
]);
result
+=
prefix
+
encodeURIComponent
(
key
)
+
"
=
"
+
encodeURIComponent
(
options
[
key
]);
prefix
=
'
&
'
;
prefix
=
'
&
'
;
}
}
}
}
...
@@ -79,8 +81,7 @@
...
@@ -79,8 +81,7 @@
})
})
.
declareMethod
(
'
route
'
,
function
(
options
)
{
.
declareMethod
(
'
route
'
,
function
(
options
)
{
var
gadget
=
this
,
var
args
=
options
.
args
,
args
=
options
.
args
,
page
;
page
;
page
=
args
.
page
||
DEFAULT_PAGE
;
page
=
args
.
page
||
DEFAULT_PAGE
;
...
@@ -105,4 +106,4 @@
...
@@ -105,4 +106,4 @@
});
});
});
});
}(
window
,
rJS
));
}(
window
,
rJS
,
document
,
loopEventListener
,
RSVP
));
\ No newline at end of file
\ No newline at end of file
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_validator_router_js.xml
View file @
af3fb549
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
46.58912.52724.48776
</string>
</value>
<value>
<string>
9
68.15281.35451.28142
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -248,7 +248,7 @@
...
@@ -248,7 +248,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
446805302.57
</float>
<float>
1
529052586.11
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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