-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·196 lines (179 loc) · 6.83 KB
/
index.html
File metadata and controls
executable file
·196 lines (179 loc) · 6.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!doctype html>
<html>
<head>
<title>fmxj</title>
<script src="fmxj.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/fmxj.css">
<script src="libraries/prism.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="libraries/prism.css">
<link rel="shortcut icon" href="http://www.seedcode.com/wp-content/uploads/2012/10/favicon.gif" type="image/x-icon">
</head>
<body>
<div style="float:right">
<a href="http://SeedCode.com" style="cursor:pointer"><img src="logowhite.png" alt="SeedCode Logo" style="width:290px;height:93px;display:block"></a>
</div>
<p>
<br>
</p>
<div class="title">
fmxj.js
</div>
<div class="sub-title">
a JavaScript approach to FileMaker Custom Web Publishing™
</div>
<div class="sidebar" id="sb">
<ul style="margin-top:0px;">
<li class="sidebaritem">
<a href="index.html">Home</a>
</li>
<li class="sidebaritem">Data Functions
<ul>
<li class="smallitem">
<a href="examples/findRecords.html">findRecordsURL()</a>
</li>
<li class="smallitem">
<a href="examples/editRecord.html">editRecordURL()</a>
</li>
<li class="smallitem">
<a href="examples/deleteRecord.html">deleteRecordURL()</a>
</li>
</ul>
</li>
<li class="sidebaritem">Design Functions
<ul>
<li class="smallitem">
<a href="examples/fileNames.html">fileNamesURL()</a>
</li>
<li class="smallitem">
<a href="examples/layoutNames.html">layoutNamesURL()</a>
</li>
<li class="smallitem">
<a href="examples/layoutFields.html">layoutFieldsURL()</a>
</li>
</ul>
</li>
<li class="sidebaritem">Server Functions
<ul>
<li class="smallitem" id="pql">
<a href="examples/postQuery.html">postQueryFMS()</a>
</li>
</ul>
</li>
<li class="sidebaritem">Object Functions
<ul>
<li class="smallitem">
<a href="examples/filterObjects.html">filterObjects()</a>
</li>
<li class="smallitem">
<a href="examples/sortObjects.html">sortObjects()</a>
</li>
<li class="smallitem">
<a href="examples/nestObjects.html">nestObjects()</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="content">
<h3 class="contentTitle">
<a href="https://github.com/seedcode/fmxj" target="_blank"><img src="gh.png" alt="gh Logo" style="width:22px;height:22px;padding-right:6px;vertical-align:bottom;">Download on GitHub</a>
</h3>
<p><div class="divSeparator"></div></p>
<h3>
Do the data interchange work with JavaScript.
</h3>
<ul class="type">
<li>Build complex queries and perform HTPP POSTs to your FileMaker Server
</li>
<li>Return FileMaker parent and child records as JavaScript Objects/JSON
</li>
<li>Create, edit and delete FileMaker records with JavaScript objects
</li>
<li>Filter and sort Javascript objects locally with complex criteria.
</li>
</ul>
<p class="text">
Query strings are created from JavaScript Objects and then sent as an HTTP POST to FileMaker's XML Web Publishing Engine. An XML FMPXMLRESULT is returned and converted into JavaScript Objects/JSON by fmxj.<br>
<br>
HTTP POSTS can be done directly to the FileMaker Server's XML WPE or a simple PHP relay can be used to get around cross-domain issues and provide more authentication options. See more on the PHP relay in the <span class="func">postQueryFMS()</span> function.
</p>
<p><div class="divSeparator"></div></p>
<h3>Example</h3>
<div class="text">Create a HTTP request to the hosted filemaker file "Events". Target layout in the specified file is "Events". Query is created by the <span class="func">findRecordsURL()</span> function and passed as the query argument to the <span class="func">postQueryFMS()</span> function. The required handler for onreadystateexchange is defined as well as the optional onprogress handler.
</div>
<pre class="line-numbers pad shadow">
<code class="language-javascript">
var requests = [ //create find requests for query. each object is request.
{ "DateStart" : "<=2/28/2014" , "DateEnd" : ">=2/1/2014" },
{ "DateStart" : "2/1/2014...2/28/2014" }
];
var query = fmxj.findRecordsURL("Events", "Events", requests) ; // create query
function onReadyFuntion(js){ //define handler for onready
document.getElementById("example1") = JSON.stringify(js, null, 4);
} ;
function onProgressFuntion(n){ //define handler for onprogress
document.getElementById("example1") += n + " bytes downloaded\n";
} ;
fmxj.postQueryFMS(query, onReadyFunction, onProgressFunction); //make call</code></pre>
<button id="btn1">try this example</button>
<pre id="example1" class="result tall"></pre>
</div>
</body>
<footer>
<script>
var relay = {"php":"fmxjRelay.php","server":"sc-fms13-fms.fmsdb.com","protocol":"https","port":"443"};
var requests =
[
{"DateStart":"<=2/28/2014", "DateEnd":">=2/1/2014"},
{"DateStart":"2/1/2014...2/28/2014"}
] ;
//button for running query and converting xml results to javascript objects
var btn = document.getElementById("btn1");
btn.addEventListener("click",function(){
function updateElement(id, value, append){
if(append){document.getElementById(id).innerHTML += value;}
else{document.getElementById(id).innerHTML = value;}
};
function createMessage(js, utc, start, num){
var end = new Date().getTime();
var dlc = utc - start;
var cc = end - utc;
var tt = end - start;
var total = js.length;
if(!num){var num= total};
var message = "<span class=\"resultHeader\">" + total +
" FileMaker records downloaded in " + dlc + " milliseconds</span>\n" +
"<span class=\"resultHeader\">" +
"FMPXMLRESULT converted to JS objects in " + cc + " milliseconds</span>\n" +
"<span class=\"resultHeader\">Displaying the first " + num + " \"stringified\" objects.</span>\n" +
"<span class=\"resultHeader\">" + (end - start) + " total milliseconds.</span>\n\n";
return message;
};
function createDisplay(js, utc, start, num){
var indent = 4; // JSON indent
var display = JSON.stringify(js.slice(0,num), null, indent);
var message = createMessage(js,utc,start,num);
return message+display ;
};
var num = 500; // number of objects to stringify and display
var start = new Date().getTime();
var query = fmxj.findRecordsURL("Events", "Events", requests);
//callback functions for writing results to pre
var writeDownload = function(n){
document.getElementById("example1").innerHTML += "<span class=\"resultHeader\">" + n + " bytes downloaded</span>\n" ;
} ;
//callback functions for writing results to pre
var writeResults = function(js,utc){
source = js;
//preserve the original message
var sourceMessage = createMessage(js, utc, start, num);
var sourceDisplay = createDisplay(js, utc, start, num);
updateElement("example1",sourceDisplay);
};
updateElement("example1", "");
updateElement("example1","<span class=\"resultHeader\">POST: " + query + "</span>\n\n");
fmxj.postQueryFMS(query, writeResults, writeDownload, relay);
});
</script>
</footer>
</html>