Skip to content

Commit 3e45fe3

Browse files
author
kaestel
committed
updated js-include api parameters
1 parent 0620cf4 commit 3e45fe3

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

src/api/js-include/index.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@
1616
$ua = getVar("ua");
1717

1818
// include _include in path - for development
19-
$test = getVar("test");
19+
$dev = getVar("dev");
20+
21+
// general path
2022
$path = getVar("path");
2123

24+
// specific paths
25+
$css_path = getVar("css_path");
26+
$js_path = getVar("js_path");
27+
2228
$deviceClass = new DeviceCore();
2329
$identification = $deviceClass->identifyDevice($ua ? $ua : $_SERVER["HTTP_USER_AGENT"]);
2430
if($identification && isset($identification["device_id"])) {
@@ -35,6 +41,19 @@
3541
#<script type="text/javascript" src="http://devices.dearapi.com/js-include/"></script>
3642
#<script type="text/javascript" src="http://devices.dearapi.com/js-include/?test=true"></script>
3743

44+
// what file to include?
45+
$file = ($dev ? "lib/" : "")."seg_".$device["segment"].($dev ? "_include" : "");
46+
3847
?>
39-
document.write('<link type="text/css" rel="stylesheet" media="all" href="<?= $path ? $path : "" ?>/css/<?= ($test ? "lib/" : "") ?>seg_<?= $device["segment"] ?><?= ($test ? "_include" : "") ?>.css" />');
40-
document.write('<script type="text/javascript" src="<?= $path ? $path : "" ?>/js/<?= ($test ? "lib/" : "") ?>seg_<?= $device["segment"] ?><?= ($test ? "_include" : "") ?>.js"></script>');
48+
49+
<? if($css_path): ?>
50+
document.write('<link type="text/css" rel="stylesheet" media="all" href="<?= $css_path ?>/<?= $file ?>.css" />');
51+
<? else: ?>
52+
document.write('<link type="text/css" rel="stylesheet" media="all" href="<?= $path ? $path : "" ?>/css/<?= $file ?>.css" />');
53+
<? endif; ?>
54+
55+
<? if($js_path): ?>
56+
document.write('<script type="text/javascript" src="<?= $js_path ?>/<?= $file ?>.js"></script>');
57+
<? else: ?>
58+
document.write('<script type="text/javascript" src="<?= $path ? $path : "" ?>/js/<?= $file ?>.js"></script>');
59+
<? endif; ?>

0 commit comments

Comments
 (0)