c4se記:さっちゃんですよ☆

.。oO(さっちゃんですよヾ(〃l _ l)ノ゙☆)

.。oO(此のblogは、主に音樂考察Programming に分類されますよ。ヾ(〃l _ l)ノ゙♬♪♡)

音樂は SoundCloud に公開中です。

考察は現在は主に Scrapbox で公表中です。

Programming は GitHub で開發中です。

CSS → JavaScriptの配列

めんどうでテストしとらんが。

/*
selector{property:value;}selector{property:value;}
[[selector,[[property,value],[property,value]]],[selector,[[property,value],[property,value]]]]
*/
var CSS = function(css){
  var temps = css.split("}").map(function(elm){
    return elm.split("{");
  }).map(function(elm){
    return elm.split(";");
  }).map(function(elm){
    return split(":");
  ]});
  temps = temps.clean();
  return temps;
};


Object.prototype.class = "Object";
Array.prototype.class = "Array";
Array.prototype.clone = function(){
  var a = [];
  for(var i=0; i<this.length; i++){
    if(this[i].class == "Array")
      a[i] = this[i].clone();
    else
      a[i] = this[i];
  }
  return a;
};
Array.prototype.map = function(f){
  var a = this.clone();
  for(var i=0; i<a.length; i++)
    a[i] = f(a[i]);
  return a;
};
Array.prototype.clean = function(){
  var a = this.clone();
  var b = [];
  for(var i=0; i<a.length; i++){
    if(a[i].class == "Array")
      b.push(a[i].clean());
    else
      if(a[i] != [])
        b.push(a[i]);
  }
  return b;
};


動くのかね?