function apiGen_Template(template) { var pos; switch( template.toLowerCase() ) { case "siliconen_kinder": pos = { holderWidth: 0, holderHeight: 0, areaLeft: 0, areaTop: 0, areaWidth: 0, areaHeight: 0, template: "Siliconen_Kinder" }; break; case "siliconen_volwassen": pos = { holderWidth: 0, holderHeight: 0, areaLeft: 0, areaTop: 0, areaWidth: 0, areaHeight: 0, template: "Siliconen_Volwassen" }; break; case "stoffen_15x350": pos = { holderWidth: 1323, holderHeight: 57, areaLeft: 1, areaTop: 1, areaWidth: 1319, areaHeight: 53, template: "Stoffen_15x350" }; break; case "stoffen_15x400": pos = { holderWidth: 1512, holderHeight: 57, areaLeft: 1, areaTop: 1, areaWidth: 1508, areaHeight: 53, template: "Stoffen_15x400" }; break; case "stoffen_20x350": pos = { holderWidth: 1323, holderHeight: 76, areaLeft: 1, areaTop: 1, areaWidth: 1319, areaHeight: 72, template: "Stoffen_20x350" }; break; case "stoffen_20x400": pos = { holderWidth: 1512, holderHeight: 76, areaLeft: 1, areaTop: 1, areaWidth: 1508, areaHeight: 72, template: "Stoffen_20x400" }; break; case "tyvek_19_hl": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_19_HL" }; break; case "tyvek_19uv_hl": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_19UV_HL" }; break; case "tyvek_25_hl": pos = { holderWidth: 962, holderHeight: 96, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 82, template: "Tyvek_25_HL" }; break; case "tyvek_budget": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_budget" }; break; case "vinyl_breed": pos = { holderWidth: 962, holderHeight: 127, areaLeft: 60, areaTop: 33, areaWidth: 230, areaHeight: 85, template: "Vinyl_Breed" }; break; case "vinyl_smal": pos = { holderWidth: 962, holderHeight: 120, areaLeft: 75, areaTop: 63, areaWidth: 382, areaHeight: 49, template: "Vinyl_Smal" }; break; case "tyvek_19": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_19" }; break; case "tyvek_19uv": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_19UV" }; break; case "tyvek_25": pos = { holderWidth: 962, holderHeight: 96, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 82, template: "Tyvek_25" }; break; case "tyvek_19_mx": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_19_MX" }; break; case "tyvek_19uv_mx": pos = { holderWidth: 962, holderHeight: 74, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 60, template: "Tyvek_19UV_MX" }; break; case "tyvek_25_mx": pos = { holderWidth: 962, holderHeight: 96, areaLeft: 106, areaTop: 6, areaWidth: 756, areaHeight: 82, template: "Tyvek_25_MX" }; break; } return pos; } function apiGen_SRC(settings) { var param = "", tempInfo; var options = { template : "", addTemplate: true, ratio: null, imgBG: "", design: null, withURL: false }; $.extend(options, settings); tempInfo = apiGen_Template(options.template); if( options.design ) param = apiGen_DesignToParam(options.design); param += (param ? "&" : ""); if( tempInfo ) { if( options.addTemplate ) param += 'area=' + tempInfo.areaLeft + ',' + tempInfo.areaTop + ',' + (tempInfo.areaLeft + tempInfo.areaWidth) + "," + (tempInfo.areaTop + tempInfo.areaHeight) + '&tmp=' + tempInfo.template; else param += 'imgB=' + tempInfo.areaWidth + '&imgH=' + tempInfo.areaHeight; } if( options.ratio ) param += '&ratio=' + options.ratio; if( options.imgBG ) param += '&imgBG=' + options.imgBG; return (options.withURL ? "/apiGen/apiGen.asp?" : "") + param; }; /*-------------------------------------------------------------------------------------------------*/ /* Alle designs in parameters omvormen /*-------------------------------------------------------------------------------------------------*/ function apiGen_DesignToParam(arrD) { var type = "", arrParam = {}; $.each( $.grep(arrD, function(design){ return design; }), function(i, design) { if( design.t ) { design = arrMiniToBig(design, arrConvertDesign); } type += (type ? ";" : "") + design.type.substr(0, 1); if( design.type == "text" ) { arrParam[i] = { tT: design.text, tF: design.fntF, tS: design.fntS, tC: design.fntC, tB: design.fntB, tI: design.fntI }; } else if( design.type == "file" || design.type == "icon" ) { arrParam[i] = { fF: design.file, fS: design.submap, fZ: design.zoom, fW: design.keepWhite, fC: design.convert }; } arrParam[i]["pT"] = design.top; arrParam[i]["pL"] = design.left; }); if( type ) arrParam["type"] = type; return $.param(arrParam).replace(/%E2%82%AC/g, "%80"); } /*-------------------------------------------------------------------------------------------------*/ /* Alle designs converteren /*-------------------------------------------------------------------------------------------------*/ var arrConvertDesign = { type: "t", left: "pL", top: "pT", text: "tT", fntF: "tF", fntB: "tB", fntI: "tI", fntC: "tC", fntS: "tS", file: "fF", submap: "fS", keepWhite: "fW", convert: "fC", origWidth: "fB", origHeight: "fH", zoom: "fZ" }; function arrDesignsToMini(arrToMini) { var arrMini = []; if( !arrToMini ) arrToMini = arrDesigns; $.each( $.grep(arrToMini, function(design){ return design; }), function(i, item) { arrMini.push( arrBigToMini(item, arrConvertDesign) ); }); return arrMini; } function miniToArrDesigns(arrMini) { var arrBig = []; $.each(arrMini, function(i, item) { arrBig.push( arrMiniToBig(item, arrConvertDesign) ); }); return arrBig; }