inkweb.js revision def5406396f26475a7c2280cbcc7607a89f1af4b
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński/*
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** InkWeb - Inkscape's Javscript features for the open vector web
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński**
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** Copyright (C) 2009 Aurelio A. Heckert, aurium (a) gmail dot com
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński**
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** This program is free software: you can redistribute it and/or modify
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** it under the terms of the GNU General Public License as published by
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** the Free Software Foundation, either version 3 of the License, or
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** (at your option) any later version.
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński**
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** This program is distributed in the hope that it will be useful,
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** but WITHOUT ANY WARRANTY; without even the implied warranty of
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** GNU General Public License for more details.
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński**
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** You should have received a copy of the GNU General Public License
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński** along with this program. If not, see <http://www.gnu.org/licenses/>.
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński*/
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosińskivar InkWeb = {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński version: 0.01,
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński NS: {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński svg: "http://www.w3.org/2000/svg",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński sodipodi: "http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński inkscape: "http://www.inkscape.org/namespaces/inkscape",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński cc: "http://creativecommons.org/ns#",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński dc: "http://purl.org/dc/elements/1.1/",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński xlink: "http://www.w3.org/1999/xlink",
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński xml: "http://www.w3.org/XML/1998/namespace"
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński }
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński};
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof KosińskiInkWeb.transmitAtt = function (conf) {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński if ( typeof(conf.from) == "string" )
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński conf.from = document.getElementById(conf.from);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński if ( typeof(conf.to) == "string" )
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński conf.to = document.getElementById(conf.to);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński var s = conf.from.getAttribute("style")
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński var re = new RegExp("(^|.*;)[ ]*"+conf.att+":([^;]*)(;.*|$)")
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński if ( re.test(s) ) {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński var val = s.replace( re, "$2" );
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński } else {
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński var val = conf.from.getAttribute(conf.att);
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński }
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński conf.to.setAttribute( conf.att, val );
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński}
40742313779ee5e43be93a9191f1c86412cf183bKrzysztof Kosiński