// Replaces all instances of the given substring.
String.prototype.replaceAll = function(
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
){
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
// Keep looping while an instance of the target string
// still exists in the string.
while (intIndexOfMatch != -1){
// Relace out the current instance.
strText = strText.replace( strTarget, strSubString )
// Get the index of any next matching substring.
intIndexOfMatch = strText.indexOf( strTarget );
}
// Return the updated string with ALL the target strings
// replaced out with the new substring.
return( strText );
}
if(true){
$ = jQuery;
nodelist = [];
$(window).load(function(){
makeDrops();
$(document).ajaxStop(function() {
updateDrops();
});
});
function updateDrops(){
$('.field-widget-node-reference-autocomplete').each(function(){
nodesurl = $(this).attr('id').substring(5).replaceAll('-','_');
$(this).find("input.form-autocomplete").each(function(){
fval = $(this).attr('value');
fid = $(this).attr('id');
fclass = $(this).attr('class');
fname = $(this).attr('name');
dropdown = '';
$(this).replaceWith(dropdown);
});
});
}
function makeDrops(){
$('.field-widget-node-reference-autocomplete').each(function(){
nurl = $(this).attr('id').substring(5).replaceAll('-','_');
fieldbox = $(this);
$.ajax({ url: "/node_reference/autocomplete/node/" + nurl + "/"
, async: false
, success: function(data){
nodesurl = fieldbox.attr('id').substring(5).replaceAll('-','_');
nodelist[nodesurl] = data;
fieldbox.find("input.form-autocomplete").each(function(){
fval = $(this).attr('value');
fid = $(this).attr('id');
fclass = $(this).attr('class');
fname = $(this).attr('name');
dropdown = '';
$(this).replaceWith(dropdown);
});
}});
});
}
}