initial commit
This commit is contained in:
19
javascript/again_utils.js
Normal file
19
javascript/again_utils.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function get_top_level_patcher()
|
||||
{
|
||||
var p = this.patcher;
|
||||
while (p.parentpatcher) // If I have a parent, keep going up
|
||||
{
|
||||
p = p.parentpatcher;
|
||||
}
|
||||
return p;
|
||||
|
||||
// var prev = 0;
|
||||
// var owner = this.patcher.box;
|
||||
// while (owner) {
|
||||
// prev = owner;
|
||||
// owner = owner.patcher.box;
|
||||
// }
|
||||
// if (prev)
|
||||
// // post("top patcher is",prev.patcher.name);
|
||||
// return prev.patcher;
|
||||
}
|
65
javascript/agn_host.js
Normal file
65
javascript/agn_host.js
Normal file
@@ -0,0 +1,65 @@
|
||||
// One day this might handle most of the [agn.host] mechanism.
|
||||
include("again_utils.js")
|
||||
autowatch = 1;
|
||||
|
||||
inlets = 1;
|
||||
outlets = 1;
|
||||
|
||||
var host_name = null;
|
||||
var top_level_patcher = null;
|
||||
|
||||
function loadbang() {
|
||||
|
||||
top_level_patcher = get_top_level_patcher();
|
||||
host_name = jsarguments[1];
|
||||
|
||||
if (top_level_patcher) {
|
||||
// post("toplevel patcher: " + top_level_patcher.name); post();
|
||||
// outlet(0, host_name);
|
||||
|
||||
// check_for_other_host();
|
||||
|
||||
set_all_agn_host_name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function set_all_agn_host_name() {
|
||||
if (top_level_patcher) {
|
||||
top_level_patcher.applydeep(send_agn_host_name);
|
||||
}
|
||||
}
|
||||
// set_all_agn_host_name.local = 0;
|
||||
|
||||
function send_agn_host_name (obj) {
|
||||
if (obj.maxclass === "js") {
|
||||
// post("js obj:" + obj.maxclass); post();
|
||||
var patcher_name = obj.patcher.getattr("name");
|
||||
if (["agn.remote","agn.convert"].indexOf(patcher_name) > -1) {
|
||||
// post(obj.varname); post();
|
||||
obj.message("set_agn_host_name", host_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// send_agn_host_name.local = 0;
|
||||
|
||||
function request_host_name() {
|
||||
set_all_agn_host_name();
|
||||
}
|
||||
// request_host_name.local = 0;
|
||||
|
||||
|
||||
function check_for_other_host() {
|
||||
top_level_patcher.applydeep(check_is_agn_host);
|
||||
}
|
||||
|
||||
|
||||
// Need some logic to detect if the currently check agn.host is this agn.host
|
||||
function check_is_agn_host (obj) {
|
||||
if (obj.maxclass === "js") {
|
||||
var patcher_name = obj.patcher.getattr("name");
|
||||
if (patcher_name === "agn.host") {
|
||||
error("An agn.host object already exist in the patcher hierarchy. Please delete one."); post();
|
||||
}
|
||||
}
|
||||
}
|
60
javascript/agn_remote.js
Normal file
60
javascript/agn_remote.js
Normal file
@@ -0,0 +1,60 @@
|
||||
include("again_utils.js")
|
||||
outlets = 2;
|
||||
|
||||
|
||||
var top_level_patcher = null;
|
||||
// var agn_host_js = null;
|
||||
var host_name = null;
|
||||
|
||||
var remote_args = [];
|
||||
// var patcherargs = null;
|
||||
|
||||
|
||||
function loadbang() {
|
||||
// post("this: " + this.box.maxclass);
|
||||
// patcherargs = this.patcher.newdefault(400, 25, "patcherargs", "test");
|
||||
// this.patcher.connect(patcherargs, 0, this.box, 0);
|
||||
// patcherargs.bang();
|
||||
|
||||
top_level_patcher = get_top_level_patcher();
|
||||
|
||||
top_level_patcher.applydeep(get_host_name);
|
||||
|
||||
}
|
||||
|
||||
// function anything() {
|
||||
// remote_args = arrayfromargs(messagename,arguments);
|
||||
// post("number of args: " + remote_args.length);
|
||||
// if (remote_args.length == 0) {
|
||||
// outlet(1, "dump");
|
||||
// } else {
|
||||
// outlet(1, remote_args);
|
||||
// }
|
||||
// }
|
||||
|
||||
function get_host_name(obj) {
|
||||
if (obj.maxclass === "js") {
|
||||
// post(obj.varname); post();
|
||||
if (obj.patcher.getattr("name") === "agn.host") {
|
||||
// post("troué !! " + obj.value); post();
|
||||
obj.message("request_host_name");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function set_agn_host_name(param) {
|
||||
// post("set host name: " + param); post();
|
||||
if (host_name !== param) {
|
||||
host_name = param;
|
||||
outlet(0, param);
|
||||
|
||||
// if (remote_args.length == 0) {
|
||||
// outlet(1, "dump");
|
||||
// } else {
|
||||
// outlet(1, remote_args);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user