I have a code that was answered for me in another post which is below. However I have since ran into a new problem that I can't solve easily. I added additional LoadKML functions e.g. Function LoadKML1(), function LoadKML2(). The problem is now I need to click the killKML button to clear LoadKML1 before I can click LoadKML2. I would like to have the LoadKML1 clicked to load the KML and if clicked again LoadKML1 to run the killKML code. basically an on and off button in essence.
Any help is appreciated.
var kmlLoaded = false;
function LoadKML() {
alert('Kill KML');
if (kmlLoaded) {
return
killKML();
}else{
alert('Creating KML');
var nwlink = "http://kml-samples.googlecode.com/svn/trunk/kml/NetworkLink/placemark.kml"
createNetworkLink(nwlink);
kmlLoaded=true;
}
}
function killKML(source) {
ge.getGlobe().getFeatures().removeChild(networkLink);
you could change your code and call the killKML() in the kmlLoaded check like this:
function LoadKML() {
if (kmlLoaded) {
//return
killKML();
}else{
var newlink = "http://www.something.com/test.kml";
createNetworkLink(newlink);
kmlLoaded=true;
}
}
Related
I have a problem where i am trying to disable certain forms fields which use the SelectStatic Widget based on a tick box, i have included the javascript below.
const vlan = document.querySelector('#id_vlan');
const physical_facing = document.querySelector('#id_physical_facing');
const service_type = document.querySelector('#id_service_type');
const bd_function = document.querySelector('#id_function');
function vlan_enable(){
vlan.disabled = false;
};
function vlan_disable(){
vlan.disabled = true;
};
function service_function_enable() {
service_type.disabled = false;
bd_function.disabled = false;
};
function service_function_disable() {
service_type.disabled = true;
bd_function.disabled = true;
};
(function() {
service_function_enable();
vlan_enable();
if(physical_facing.checked){
service_function_disable();
} else {
vlan_disable();
}
})();
function pf_event() {
if(physical_facing.checked) {
vlan_enable();
service_function_disable();
} else {
vlan_disable();
service_function_enable();
}
};
physical_facing.addEventListener('change', pf_event)
When on the Page, the VLAN field is a DynamicModelFormField and will never disable, but when toggling the switch on and off the fields do not re-enable, i know the event is getting fired because i can see it in the developer tools, the disabled tag gets applied and removed with no change on the page, This may be a simple mistake but would like if someone can point me in the right direction.
below is what the page looks like
Netbox Page
Has anybody had any success doing this with the new version of netbox as it worked fine in V2 with the SelectStatic2 widget.
I have a page that will open a popup and after something is done on that popup and user close it I want to get data from table / tds. Here is my calling function:
function clicked() {
windowOpener("SiteMap.html");
popupWin.onbeforeunload = function () {
var a = $("#drawTable", popupWin.document);
var tds = $(a).find("td");
tds.each(function () {
var p = $(this).data('point');
if (JSON.stringify(p.values) !== JSON.stringify(point.values)) { //here comes error, to this line
console.log(p.values);
}
})
};
}
.data('point') is created and populated already on that popup page, but still I am getting that $(this).data('point') is undefined. So, is it possible that in that point data is already destroyed? What is your recommendation how to deal with this?
thanks
Writing the code i am stuck with one thing. I am loading variable string through jQuery load function and there is where trouble starts. I want my code to check if string loaded through text file had any changes and if that is true make some actions. How do I set my variable as a string to compare it with the one in file? Part of the code
var follow, donate;
var auto_refresh = setInterval(function() {
follow = $('#followerid').load("../Muxy/most_recent_follower.txt");
donate = $('#donatorid').load("../Muxy/most_recent_donator.txt");
}, 100);
and then I want to make something like this:
someUpdateFunction() {
if($(#'followerid').get("innerHTML") != follow)
// actions (animations, div changes etc.)
}
That is probably totally wrong but I wasnt able to find any tips here. Thanks in advance
Try something like this:
$.get('../Muxy/most_recent_follower.txt', function (data) {
var followerid = $('#followerid').html();
if( followerid == data ){
// They are the same
}else{
// They are not the same
}
});
The .html() method will get the HTML inside #followerid. It sounds like that's what you want.
The jQuery.load function doesn't return the loaded file, it returns the element. Try out this:
var auto_refresh = setInterval(function() {
oldFollow = $('#followerid').html();
$('#followerid').load("../Muxy/most_recent_follower.txt");
oldDonate = $('#donatorid').html();
$('#donatorid').load("../Muxy/most_recent_donator.txt");
}, 100);
someUpdateFunction() {
if($('#followerid').html() !== oldFollow)
// actions (animations, div changes etc.)
}
}
I have integrated 'Embed Layout' comet chat on my site. Now I want to open particular friend chat on page load.
In the documentation, I've found below code to do the same. REF : Documentation Link
jqcc.cometchat.chatWith(user_id)
I have included in custom js from admin panel. However, it is showing below error in console
jqcc.cometchat.chatWith is not a function
But If I use same after friends list loaded from the console it is working fine.
How can I fix this issue?
Currently for time being I have fixed this issue by adding below code in custom js
var first_chat_loaded = false;
var first_chat = setInterval(function () {
try {
if (first_chat_loaded === false) {
// Function to get other user id defined in parent html page
var other_userid = parent.get_other_user_id();
jqcc.cometchat.chatWith(other_userid);
first_chat_loaded = true;
clear_first_load();
}
} catch (e) {
}
}, 1000);
function clear_first_load() {
clearInterval(first_chat);
}
Please let me know, If there is any proper way to do the same.
Kindly make use of this code snippet for the above mentioned issue
var checkfn = setInterval(
function(){
if(typeof jqcc.cometchat.chatWith == 'function'){
jqcc.cometchat.chatWith(user_id);
clearInterval(checkfn);
}
},
500);
I posted a very much similar question yesterday but no one answerd so far. Now I have changed the functionality and stuck with the following problem. In this scenario, I have a RadWindow that i am opening from code behind file (.aspx page) on a button click. On this rad window I have a hidden field where I am setting value and now OnClientBeforeClose event I want to get the value from hidden field and assign it to a text box on my .ASPX page which is the parent page of this Rad Window. Could please anyone give me any idea how to do that. I have looked inot many examples on Telerik and StackOverflow but nothing working for me. Thanks in advance.
Rad Window Diclaration in my .Aspx.cs page
RadWindow window = new RadWindow();
window.Title = "Comments Pick List";
window.ID = "CommentsListPopUpRadWindow";
window.NavigateUrl = "CommentsList.aspx";
window.OnClientBeforeClose = "CommentsListPopUpRadWindowBeforeClose";
window.Skin = "Metro";
window.Behaviors = WindowBehaviors.Close;
window.KeepInScreenBounds = true;
window.VisibleStatusbar = false;
window.Modal = true;
window.Width = 750;
window.MinHeight = 510;
window.VisibleOnPageLoad = true;
window.EnableViewState = false;
RadWindowManager1.Windows.Add(window);
JavaScript function on RadWindow .ASPX page where I am setting value to the hidden field
function displayItem(id) {
var selectedText = document.getElementById(id);
document.getElementById('hiddenSelectedTextField').value = selectedText.innerText;
}
JavaScript OnClientBeforeClose function on my .ASPX parent page (to close the RadWindow) where I am trying to get value from the hidden field and set in the TextBox of parent page
function CommentsListPopUpRadWindowBeforeClose(oWnd, args) {
}
You can easily pass arguments to the RadWindow's Close function, from the child page:
function GetRadWindow() {
if (window.radWindow) {
return window.radWindow;
}
if (window.frameElement && window.frameElement.radWindow) {
return window.frameElement.radWindow;
}
return null;
}
function ChildClose() {
GetRadWindow().Close(document.getElementById('hiddenSelectedTextField').value);
}
and then retrieve the argument in the parent page by specifiying its OnClose function:
Add, in the aspx.cs file:
window.OnClientClose = "CommentsListPopUpRadWindow_OnClose";
and in the aspx parent page:
function CommentsListPopUpRadWindow_OnClose(radWindow, args) {
var arg = args.get_argument();
}