forked from MattStultz/extrusiongen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmerchant_tools.js~
70 lines (53 loc) · 1.92 KB
/
merchant_tools.js~
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
/**
* This is a customizable javascript collection for the merchants.
*
* Store here whatever you need.
*
*
* @author Ikaros Kappler
* @date 2014-06-10
* @version 1.0.0
**/
/**
* The url param may contain the %json_data% placeholder.
*
* It will be replace by a JSON object that describes the current settings for the
* dildo generator.
*
**/
var seen = [];
function _order_send_to_server( url ) {
// This is a mandatory size check.
// Each printer has a max X-Y-sized printing bed. This function call
// checks if the created mesh would be out of bounds and asks the user
// if he/she would like to continue though (if too large).
// If everything is fine (size OK, or user wants to continue) the
// function returns true.
if( !checkSizeBeforeSaving() )
return false;
// This function returns a JSON object containing all essential
// settings. See ZipFileImporter.js for details.
// Actually all form settings a stored into a JSON object, thus
// makes it possible to restore the settings the user made each
// time it's needed (part of the save/load cycle).
var json_object = ZipFileExporter._build_export_data();
// This replaces the configured placeholder from the passed URL.
// Usually the URL is specified in the config.js in
// _DILDO_CONFIG.ORDER_PRINT_ACTION (near line 37).
seen = [];
var tmp = JSON.stringify(json_object, function(key, val) {
if (typeof val == "object") {
if (seen.indexOf(val) >= 0)
return;
seen.push(val);
}
return JSON.stringify( val );
});
//window.alert( JSON.stringify(json_object) );
var x = JSON.stringify(json_data);
var newURL = url.replace( new RegExp("%json_string%", 'g'),
JSON.stringify(json_object) // The JSON object is browser built-in
);
// Now call the URL (might be a remote server)
window.alert( "new url: " + newURL );
}