123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>work/out form</title>
-
-
- <!-- libs, do not modify. When local than load local libs. -->
- <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
- <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
- <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
- <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
- <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
- <script type="text/javascript" src="/js_libs/util.js"></script>
- <script type="text/javascript" src="/js_libs/printf.js"></script>
- <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
- <script type="text/javascript" src="/js_libs/parsequery.js"></script>
- <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
- <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
- <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
- <link rel="stylesheet" href="/js_libs/custommenu.css" type="text/css"/>
- <link rel="stylesheet" href="/js_libs/ui.css" type="text/css"/>
- <link rel="stylesheet" href="/js_libs/relaxngui.css" type="text/css"/>
-
-
- <!-- custom stuff, play arround -->
- <script src='../js/form-render.min.js'></script>
- <script>
- if (location.href.match(/\/$/) == null) {
- //location.href = location.href + '/';
- }
- </script>
- </head>
- <body>
-
- <form id="fb-render">
-
- <script>
- //https://stackoverflow.com/questions/5448545/how-to-retrieve-get-parameters-from-javascript
- function getSearchParameters() {
- var prmstr = window.location.search.substr(1);
- return prmstr != null && prmstr != "" ? transformToAssocArray(prmstr) : {};
- }
- function transformToAssocArray( prmstr ) {
- var params = {};
- var prmarr = prmstr.split("&");
- for ( var i = 0; i < prmarr.length; i++) {
- var tmparr = prmarr[i].split("=");
- params[tmparr[0]] = tmparr[1];
- }
- return params;
- }
- function openlink(menuitem){
- var menu = { name: menuitem };
- $.ajax({
- type: "PUT",
- url: window.name,
- contentType: "application/json",
- data: JSON.stringify(menu),
- success: function (data) {
-
- }
- });
- }
- var formRenderInstance;
- //https://stackoverflow.com/questions/1184624/convert-form-data-to-javascript-object-with-jquery
- function objectifyForm(formArray) {
- //serialize data function
- var returnArray = {};
- for (var i = 0; i < formArray.length; i++){
- returnArray[formArray[i]['name']] = formArray[i]['value'];
- }
- return returnArray;
- }
- //return json data that should be sent when frames button is pressed
- function buttonPressed(){
-
- //does not allow for multi select boxes
- //getting formdata: https://gomakethings.com/serializing-form-data-with-the-vanilla-js-formdata-object/ */
- //var myForm = document.getElementById('fb-render');
- //return Object.fromEntries(new FormData(myForm));
-
- objectifyForm($("#fb-render").serializeArray())
- return objectifyForm($("#fb-render").serializeArray());
-
- //return formRenderInstance.userData;
- }
-
- jQuery(function($) {
- $.ajax({
- type: "GET",
- url: "./json",
- dataType: "json",
- success: function(json) {
- formRenderInstance = $('#fb-render').formRender({
- formData: json,
- });
-
- //necesarry as input fields do not have unique names resulting in overriding when the data is serialized
- $("#fb-render input[type=checkbox]").each(function(){
- this.name = this.value
- this.value = "true"
- });
-
- //Fill out inputs
- var urlpara = getSearchParameters();
- for (var key in urlpara) {
- if (urlpara.hasOwnProperty(key)) {
-
- $( "input[name*='" + key + "']" ).val( urlpara[key] );
- }
- }
-
- //$( "input[value*]" ).val( urlpara[key] );
- $(":input").each(function(){
- $(this).attr("onclick", $(this).attr("value"))
- });
-
-
-
- },
- error: function (request, status, error) {
- }
- });
-
-
-
- });
- </script>
- </body>
- </html>
|