{"action":"created","issue":{"url":"https://api.github.com/repos/howardjones/network-weathermap/issues/126","repository_url":"https://api.github.com/repos/howardjones/network-weathermap","labels_url":"https://api.github.com/repos/howardjones/network-weathermap/issues/126/labels{/name}","comments_url":"https://api.github.com/repos/howardjones/network-weathermap/issues/126/comments","events_url":"https://api.github.com/repos/howardjones/network-weathermap/issues/126/events","html_url":"https://github.com/howardjones/network-weathermap/issues/126","id":293065978,"number":126,"title":"Editor on Cacti not working (PHP Weathermap version 1.0.0dev)","user":{"login":"pautiina","id":11805503,"avatar_url":"https://avatars0.githubusercontent.com/u/11805503?v=4","gravatar_id":"","url":"https://api.github.com/users/pautiina","html_url":"https://github.com/pautiina","followers_url":"https://api.github.com/users/pautiina/followers","following_url":"https://api.github.com/users/pautiina/following{/other_user}","gists_url":"https://api.github.com/users/pautiina/gists{/gist_id}","starred_url":"https://api.github.com/users/pautiina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pautiina/subscriptions","organizations_url":"https://api.github.com/users/pautiina/orgs","repos_url":"https://api.github.com/users/pautiina/repos","events_url":"https://api.github.com/users/pautiina/events{/privacy}","received_events_url":"https://api.github.com/users/pautiina/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-01-31T08:09:35Z","updated_at":"2018-02-02T10:44:57Z","closed_at":null,"author_association":"NONE","body":"Hello.\r\nEditor not work correctly.\r\nWhen I open editor, browser console have next error:\r\n```\r\nncaught SyntaxError: Unexpected token <\r\njquery.min.js:2 jQuery.Deferred exception: fromplug is not defined ReferenceError: fromplug is not defined\r\n    at attach_click_events (http://noc/cacti/plugins/weathermap/editor-resources/editor.js:83:5)\r\n    at HTMLDocument.initJS (http://noc/cacti/plugins/weathermap/editor-resources/editor.js:59:9)\r\n    at j (http://noc/cacti/plugins/weathermap/vendor/jquery/dist/jquery.min.js:2:29999)\r\n    at k (http://noc/cacti/plugins/weathermap/vendor/jquery/dist/jquery.min.js:2:30313) undefined\r\nr.Deferred.exceptionHook @ jquery.min.js:2\r\njquery.min.js:2 jQuery.Deferred exception: imlist is not defined ReferenceError: imlist is not defined\r\n    at HTMLDocument.initJS16 (http://noc/cacti/plugins/weathermap/editor-resources/editor16.js:13:17)\r\n    at j (http://noc/cacti/plugins/weathermap/vendor/jquery/dist/jquery.min.js:2:29999)\r\n    at k (http://noc/cacti/plugins/weathermap/vendor/jquery/dist/jquery.min.js:2:30313) undefined\r\nr.Deferred.exceptionHook @ jquery.min.js:2\r\njquery.min.js:2 Uncaught ReferenceError: fromplug is not defined\r\n    at attach_click_events (editor.js:83)\r\n    at HTMLDocument.initJS (editor.js:59)\r\n    at j (jquery.min.js:2)\r\n    at k (jquery.min.js:2)\r\njquery.min.js:2 Uncaught ReferenceError: imlist is not defined\r\n    at HTMLDocument.initJS16 (editor16.js:13)\r\n    at j (jquery.min.js:2)\r\n    at k (jquery.min.js:2)\r\n```\r\n\r\nand on cacti log:\r\n\r\n```\r\n2018/01/31 10:02:35 - CMDPHP PHP ERROR NOTICE Backtrace: (/plugins/weathermap/weathermap-cacti10-plugin-editor.php: 25 require_once)(/plugins/weathermap/editor.php: 34 main)(/plugins/weathermap/lib/Weathermap/Editor/EditorUI.php: 932 showMainPage)(/plugins/weathermap/lib/Weathermap/Editor/EditorUI.php: 1123 fetch)(/plugins/weathermap/lib/Weathermap/UI/SimpleTemplate.php: 48 include)(/plugins/weathermap/editor-resources/templates/main-oldstyle.php: 28 CactiErrorHandler)(/lib/functions.php: 4516 cacti_debug_backtrace)\r\n--\r\n2018/01/31 10:02:35 - ERROR PHP NOTICE in Plugin 'weathermap': Use of undefined constant host_url - assumed 'host_url' in file: /var/www/data/cacti/plugins/weathermap/editor-resources/templates/main-oldstyle.php on line: 28\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/howardjones/network-weathermap/issues/comments/362552265","html_url":"https://github.com/howardjones/network-weathermap/issues/126#issuecomment-362552265","issue_url":"https://api.github.com/repos/howardjones/network-weathermap/issues/126","id":362552265,"user":{"login":"netniV","id":9052188,"avatar_url":"https://avatars0.githubusercontent.com/u/9052188?v=4","gravatar_id":"","url":"https://api.github.com/users/netniV","html_url":"https://github.com/netniV","followers_url":"https://api.github.com/users/netniV/followers","following_url":"https://api.github.com/users/netniV/following{/other_user}","gists_url":"https://api.github.com/users/netniV/gists{/gist_id}","starred_url":"https://api.github.com/users/netniV/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netniV/subscriptions","organizations_url":"https://api.github.com/users/netniV/orgs","repos_url":"https://api.github.com/users/netniV/repos","events_url":"https://api.github.com/users/netniV/events{/privacy}","received_events_url":"https://api.github.com/users/netniV/received_events","type":"User","site_admin":false},"created_at":"2018-02-02T10:44:57Z","updated_at":"2018-02-02T10:44:57Z","author_association":"NONE","body":"imlist comes from EditorUI.php:\r\n```php\r\n$imagesJSON = \"\\nvar imlist = \" . json_encode($imageList) . \";\\n\";\r\n$tpl->set(\"images_json\", $imagesJSON);\r\n```\r\n\r\neditor-resources/template/main-oldstyle.php and main.php output $images_json:\r\n```html\r\n    <script type=\"text/javascript\">\r\n        <?php echo $map_json; ?>\r\n        <?php echo $images_json; ?>\r\n        <?php echo $fonts_json; ?>\r\n        <?php echo $editor_settings; ?>\r\n\r\n        var $global_settings = <?php echo $global; ?>;\r\n        var $global_settings2 = <?php echo $global2; ?>;\r\n        var editor_url = '<?php echo $editor_name; ?>';\r\n        var fromplug = <?php echo $fromplug ?>;\r\n        var host_url = <?php echo host_url ?>;\r\n    </script>\r\n```\r\nThe `editor-resources/editor16.js` should probably check whether imlist is null before looping through it though:\r\n\r\n```javascript\r\nfunction initJS16() {\r\n\r\n    jQuery.each(imlist, function (index, value) {\r\n        // slot in the list of images in:\r\n        //    node icon selectbox\r\n        //    map background image\r\n        var newitem = jQuery(\"<option />\").attr(\"value\", value).text(value);\r\n        jQuery(\".imlist\").append(newitem);\r\n    });\r\n\r\n    jQuery.each(fontlist, function (index, value) {\r\n        // slot in the list of fonts in each of the select boxes where they are expected\r\n        var newitem = jQuery(\"<option />\").attr(\"value\", value).text(value);\r\n        jQuery(\".fontlist\").append(newitem);\r\n    });\r\n```\r\n\r\nShould become:\r\n\r\n```javascript\r\nfunction initJS16() {   \r\n\r\n    if (imlist != null) \r\n    jQuery.each(imlist, function (index, value) {\r\n        // slot in the list of images in:\r\n        //    node icon selectbox\r\n        //    map background image\r\n        var newitem = jQuery(\"<option />\").attr(\"value\", value).text(value);\r\n        jQuery(\".imlist\").append(newitem);\r\n    });\r\n\r\n    if (fontlist != null)\r\n    jQuery.each(fontlist, function (index, value) {\r\n        // slot in the list of fonts in each of the select boxes where they are expected\r\n        var newitem = jQuery(\"<option />\").attr(\"value\", value).text(value);\r\n        jQuery(\".fontlist\").append(newitem);\r\n    });\r\n```\r\n\r\nThough @howardjones may find that this is a problem elsewhere since they shouldn't actually be null.  You could add a `debugger;` statement as the first line of `initJS16()` to check that \r\n"}}
{"actor":{"display_login":"netniV"}}