Commit 0499415f authored by Vivek's avatar Vivek

gadget_interface_validator: moved interface based gadget rendering to router gadget.

parent c677314d
...@@ -105,18 +105,6 @@ ...@@ -105,18 +105,6 @@
/*jslint nomen: true, indent: 2, maxerr: 3 */\n /*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, RSVP, Handlebars) {\n (function (window, rJS, RSVP, Handlebars) {\n
"use strict";\n "use strict";\n
\n
var INTERFACE_GADGET_SCOPE = "interface_gadget";\n
\n
function fetchPageType(gadget_url) {\n
var page_type = \'\',\n
key = \'_page_\';\n
if(gadget_url.indexOf(key) > -1) {\n
page_type = gadget_url.substring(gadget_url.indexOf(key) + key.length,\n
gadget_url.lastIndexOf(\'.\'));\n
}\n
return page_type;\n
}\n
\n \n
/////////////////////////////////////////////////////////////////\n /////////////////////////////////////////////////////////////////\n
// Handlebars\n // Handlebars\n
...@@ -182,11 +170,7 @@ ...@@ -182,11 +170,7 @@
\n \n
.declareMethod("submitForm", function(options) {\n .declareMethod("submitForm", function(options) {\n
var gadget = this,\n var gadget = this,\n
interface_gadget,\n appcache_url;\n
appcache_url,\n
required_interface,\n
page_type,\n
gadget_source_url = \'gadget_interface_validator.appcache\';\n
return new RSVP.Queue()\n return new RSVP.Queue()\n
.push(function () {\n .push(function () {\n
gadget.props.content_element.querySelector("input[type=submit]")\n gadget.props.content_element.querySelector("input[type=submit]")\n
...@@ -195,41 +179,10 @@ ...@@ -195,41 +179,10 @@
})\n })\n
.push(function(submit_url) {\n .push(function(submit_url) {\n
appcache_url = submit_url;\n appcache_url = submit_url;\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n return gadget.redirect({\n
})\n interface_type: \'report\',\n
.push(function(i_gadget) {\n appcache_url: appcache_url\n
required_interface = \'gadget_interface_validator_interface_report.html\';\n });\n
interface_gadget = i_gadget;\n
return interface_gadget.getGadgetListImplementingInterface(required_interface, gadget_source_url);\n
})\n
.push(function(gadget_list) {\n
if(gadget_list.length > 0) {\n
page_type = fetchPageType(gadget_list[0]);\n
return gadget.redirect({\n
page: page_type,\n
appcache_url: appcache_url\n
});\n
} else {\n
required_interface = \'gadget_interface_validator_interface_form.html\';\n
return new RSVP.Queue()\n
.push(function() {\n
return interface_gadget.getGadgetListImplementingInterface(required_interface, gadget_source_url);\n
})\n
.push(function(gadget_list) {\n
console.log("gadget_list");\n
if(gadget_list.length > 0) {\n
page_type = fetchPageType(gadget_list[0]);\n
return gadget.redirect({\n
page: page_type,\n
found: false\n
});\n
} else {\n
return gadget.redirect({\n
found: false\n
});\n
}\n
});\n
}\n
});\n });\n
})\n })\n
\n \n
...@@ -387,7 +340,7 @@ ...@@ -387,7 +340,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>947.11076.45303.33126</string> </value> <value> <string>947.18869.9624.56115</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -405,7 +358,7 @@ ...@@ -405,7 +358,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1447781632.75</float> <float>1448263988.6</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -123,7 +123,10 @@ ...@@ -123,7 +123,10 @@
\n \n
</head>\n </head>\n
<body>\n <body>\n
<div data-gadget-url="gadget_jio.html" data-gadget-scope="jio_selection"></div>\n <div data-gadget-url="gadget_interface.html"\n
data-gadget-scope="interface_gadget"\n
data-gadget-sandbox="public"></div>\n
<div data-gadget-url="gadget_jio.html" data-gadget-scope="jio_selection"></div>\n
</body>\n </body>\n
</html> </html>
...@@ -262,7 +265,7 @@ ...@@ -262,7 +265,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>947.9498.60930.44168</string> </value> <value> <string>947.14679.48387.8908</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -280,7 +283,7 @@ ...@@ -280,7 +283,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1447996304.28</float> <float>1448247105.54</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
...@@ -108,7 +108,9 @@ ...@@ -108,7 +108,9 @@
\n \n
var MAIN_PAGE_PREFIX = "gadget_interface_validator_",\n var MAIN_PAGE_PREFIX = "gadget_interface_validator_",\n
DEFAULT_PAGE = "form",\n DEFAULT_PAGE = "form",\n
REDIRECT_TIMEOUT = 5000;\n DEFAULT_GADGET_SOURCE = \'gadget_interface_validator.appcache\',\n
REDIRECT_TIMEOUT = 30000,\n
INTERFACE_GADGET_SCOPE = "interface_gadget";\n
\n \n
function listenHashChange(gadget) {\n function listenHashChange(gadget) {\n
function extractHashAndDispatch(evt) {\n function extractHashAndDispatch(evt) {\n
...@@ -147,6 +149,16 @@ ...@@ -147,6 +149,16 @@
window.dispatchEvent(event);\n window.dispatchEvent(event);\n
return result;\n return result;\n
}\n }\n
\n
function fetchPageType(gadget_url) {\n
var page_type = \'\',\n
key = \'_page_\';\n
if(gadget_url.indexOf(key) > -1) {\n
page_type = gadget_url.substring(gadget_url.indexOf(key) + key.length,\n
gadget_url.lastIndexOf(\'.\'));\n
}\n
return page_type;\n
}\n
\n \n
rJS(window)\n rJS(window)\n
.ready(function (gadget) {\n .ready(function (gadget) {\n
...@@ -184,13 +196,42 @@ ...@@ -184,13 +196,42 @@
.declareMethod(\'route\', function (options) {\n .declareMethod(\'route\', function (options) {\n
var gadget = this,\n var gadget = this,\n
args = options.args,\n args = options.args,\n
page;\n page,\n
page_type = \'\',\n
interface_name = \'\',\n
gadget_source;\n
if (args.interface_type) {\n
interface_name = MAIN_PAGE_PREFIX + "interface_" + args.interface_type + ".html";\n
} else if(args.interface_name) {\n
interface_name = args.interface_name;\n
}\n
\n \n
page = args.page || DEFAULT_PAGE;\n if(interface_name) {\n
return {\n gadget_source = args.gadget_source || DEFAULT_GADGET_SOURCE;\n
url: MAIN_PAGE_PREFIX + "page_" + page + ".html",\n return new RSVP.Queue()\n
options: args\n .push(function() {\n
};\n return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
})\n
.push(function(interface_gadget) {\n
return interface_gadget.getGadgetListImplementingInterface(interface_name, gadget_source);\n
})\n
.push(function(gadget_list) {\n
if(gadget_list.length > 0) {\n
page_type = fetchPageType(gadget_list[0]);\n
}\n
page = page_type || DEFAULT_PAGE;\n
return ({\n
url: MAIN_PAGE_PREFIX + "page_" + page + ".html",\n
options: args\n
});\n
});\n
} else {\n
page = args.page || DEFAULT_PAGE;\n
return {\n
url: MAIN_PAGE_PREFIX + "page_" + page + ".html",\n
options: args\n
};\n
}\n
})\n })\n
\n \n
.declareAcquiredMethod(\'renderApplication\', \'renderApplication\')\n .declareAcquiredMethod(\'renderApplication\', \'renderApplication\')\n
...@@ -345,7 +386,7 @@ ...@@ -345,7 +386,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>947.14517.45318.16230</string> </value> <value> <string>947.19086.45042.34679</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -363,7 +404,7 @@ ...@@ -363,7 +404,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1447986581.85</float> <float>1448260821.21</float>
<string>GMT</string> <string>GMT</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment