<commit_before>var pdxAirport = {
  name : 'PDX Airport',
  minCustomers : 23,
  maxCustomers : 65,
  avgCookiesPerCust : 6.3,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },

  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },

  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }

//   savedCookieArray: function(){ ---This doesn't work and I don't know why. How do i use .this in an object property???
//       return this.cookieDataArray();
//   }

}; // end of object

pdxAirport.addToDom();

var pioneerSquare = {
  name : 'Pioneer Square',
  minCustomers : 3,
  maxCustomers : 24,
  avgCookiesPerCust : 1.2,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },
  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }
    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }
    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );
  }
};

pioneerSquare.addToDom();

var powells = {
name : 'Powells',
  minCustomers : 11,
  maxCustomers : 38,
  avgCookiesPerCust : 3.7,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }
};

powells.addToDom();

var stJohns = {
  name : 'St. Johns',
  minCustomers : 20,
  maxCustomers : 38,
  avgCookiesPerCust : 2.3,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }
};

stJohns.addToDom();

var waterfront = {
  name : 'Waterfront',
  minCustomers : 2,
  maxCustomers : 16,
  avgCookiesPerCust : 4.6,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }
};

waterfront.addToDom();

// First, create a separate JS object literal (no constructor functions... yet) for each shop location that does the following:

// Stores the min/max hourly customers, and the average cookies per customer, in object properties

// Uses a method of that object to generate a random number of customers per hour. Objects/Math/random

// Calculate and store the simulated amounts of cookies purchased for each hour at each location using average cookies purchased and the random number of customers generated

// Store the results for each location in a separate array... perhaps as a property of the object representing that location

// Display the values of each array as unordered lists in the browser

// Calculating the sum of these hourly totals; your output for each location should look like this:

// 1st and Pike

// 6am: 16 cookies
// 7am: 20 cookies
// 8am: 35 cookies
// 9am: 48 cookies
// 10am: 56 cookies
// 11am: 77 cookies
// 12pm: 93 cookies
// 1pm: 144 cookies
// 2pm: 119 cookies
// 3pm: 84 cookies
// 4pm: 61 cookies
// 5pm: 23 cookies
// 6pm: 42 cookies
// 7pm: 57 cookies
// 8pm: 29 cookies
// Total: 657 cookies
// Display the lists on sales.html. We will be adding features to this application and working with its layout throughout the week.<commit_msg>remove unnecessary comments, fix indents<commit_after>var pdxAirport = {
  name : 'PDX Airport',
  minCustomers : 23,
  maxCustomers : 65,
  avgCookiesPerCust : 6.3,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },

  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },

  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }

//   savedCookieArray: function(){ ---This doesn't work and I don't know why. How do i use .this in an object property???
//       return this.cookieDataArray();
//   }

}; // end of object

pdxAirport.addToDom();

var pioneerSquare = {
  name : 'Pioneer Square',
  minCustomers : 3,
  maxCustomers : 24,
  avgCookiesPerCust : 1.2,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },
  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }
    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }
    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );
  }
};

pioneerSquare.addToDom();

var powells = {
  name : 'Powells',
  minCustomers : 11,
  maxCustomers : 38,
  avgCookiesPerCust : 3.7,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }
};

powells.addToDom();

var stJohns = {
  name : 'St. Johns',
  minCustomers : 20,
  maxCustomers : 38,
  avgCookiesPerCust : 2.3,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }
};

stJohns.addToDom();

var waterfront = {
  name : 'Waterfront',
  minCustomers : 2,
  maxCustomers : 16,
  avgCookiesPerCust : 4.6,
  randomCust : function() {
    return (Math.floor(Math.random() * (this.maxCustomers - this.minCustomers)) + this.minCustomers);
  },
  avgCookiesPerHour : function() {
    return this.randomCust() * this.avgCookiesPerCust;
  },
  staticCookies : [],//required empty array

  cookieDataArray : function() { //pushes a static sample of random numbers to staticCookies variable
    for (i = 0;i < 15;i++){
      this.staticCookies.push(Math.floor(this.avgCookiesPerHour()));
    }
  },

  addToDom : function() {
    var openHours = ['6am','7am','8am','9am','10am','11am','12am','1pm','2pm','3pm','4pm','5pm','6pm','7pm','8pm'];
    this.cookieDataArray();
    var container = document.getElementById('list');
    var createHeader = document.createElement('lh');
    createHeader.innerHTML = ('' + this.name + '');
    container.appendChild( createHeader);

    for (var i = 0; i < 15; i++) {
      var createList = document.createElement('li');
      createList.innerHTML = (openHours[i] + ': ' + this.staticCookies[i] + ' of cookie');
      container.appendChild( createList );
    }

    var cookieSum = 0;
    for (var i = 0; i < this.staticCookies.length; i++){
      cookieSum = cookieSum + this.staticCookies[i];
    }

    createList.innerHTML = ('Total Cookies: ' + cookieSum);
    container.appendChild( createList );

  }
};

waterfront.addToDom()<|endoftext|>


<commit_before>//<script src="vexflow-min.js"></script>

(function(Score) {

Score.Stave = function(canvasId, clef_name, time_signature) {
   var self = this;

   self._clef_name = clef_name;
   self._canvas = document.getElementById(canvasId);
   self._renderer = new Vex.Flow.Renderer(self._canvas, Vex.Flow.Renderer.Backends.CANVAS);
   self._ctx = self._renderer.getContext();
   self._width = self._canvas.width-10;
   self._stave = new Vex.Flow.Stave(0, 0, self._width);
   self._stave.addClef(clef_name);
   if (time_signature) {
      self._stave.addTimeSignature(time_signature);
   }
   self._stave.setContext(self._ctx);
   self._stave.draw();
};

Score.Stave.prototype.clear = function() {
   var self = this;
   self._ctx.clearRect(0, 0, self._canvas.width, self._canvas.height);
   self._stave.draw();
};

Score.Stave.prototype.drawBeat = function(notes, duration) {
   var self = this;

   var voice_notes = new Vex.Flow.Voice({ num_beats: 1, beat_value: duration, resolution: Vex.Flow.RESOLUTION });
   voice_notes.addTickables([self._makeBeat(notes, duration)]);
   self._draw(voice_notes);
};

Score.Stave.prototype.drawSequence = function(beats) {
   var self = this;

   var seq = self._makeSequence(beats);
   var voice_notes = new Vex.Flow.Voice({ num_beats: seq.num_beats, beat_value: seq.beat_value, resolution: Vex.Flow.RESOLUTION });
   voice_notes.addTickables(seq.notes);
   self._draw(voice_notes);
};

Score.Stave.prototype._draw = function(voice) {
   var self = this;
   self._ctx.clearRect(0, 0, self._canvas.width, self._canvas.height);
   var formatter = new Vex.Flow.Formatter().joinVoices([voice]).format([voice], self._width);
   self._stave.draw();
   voice.draw(self._ctx, self._stave);
};

Score.Stave.prototype._makeBeat = function(notes, duration) {
   var self = this;

   var keys = [];
   notes.forEach(function (note_info) {
      keys.push(note_info.name+"/"+(note_info.octave || '4'));
   });

   var note = new Vex.Flow.StaveNote({ keys: keys, duration: duration.toString(), clef: self._clef_name, auto_stem: true });

   for (var i = 0; i < notes.length; ++i) {
      if (notes[i].accidental) {
         note.addAccidental(i, new Vex.Flow.Accidental(notes[i].accidental));
      }
   }
   return note;
};

Score.Stave.prototype._makeSequence = function(beats) {
   var self = this;

   var stave_notes = [];
   var total_duration = 0;
   beats.forEach(function (beat_info) {
      stave_notes.push(self._makeBeat(beat_info.notes, beat_info.duration));
      total_duration += 32/beat_info.duration;
   });

   return {notes: stave_notes, num_beats: total_duration, beat_value: 32};
};

}(window.Score = window.Score || {}));

<commit_msg>notes annotation<commit_after>//<script src="vexflow-min.js"></script>

(function(Score) {

Score.Stave = function(canvasId, clef_name, time_signature) {
   var self = this;

   self._clef_name = clef_name;
   self._canvas = document.getElementById(canvasId);
   self._renderer = new Vex.Flow.Renderer(self._canvas, Vex.Flow.Renderer.Backends.CANVAS);
   self._ctx = self._renderer.getContext();
   self._width = self._canvas.width-10;
   self._stave = new Vex.Flow.Stave(0, 0, self._width);
   self._stave.addClef(clef_name);
   if (time_signature) {
      self._stave.addTimeSignature(time_signature);
   }
   self._stave.setContext(self._ctx);
   self._stave.draw();
};

Score.Stave.prototype.clear = function() {
   var self = this;
   self._ctx.clearRect(0, 0, self._canvas.width, self._canvas.height);
   self._stave.draw();
};

Score.Stave.prototype.drawBeat = function(notes, duration, annotation) {
   var self = this;

   var voice_notes = new Vex.Flow.Voice({ num_beats: 1, beat_value: duration, resolution: Vex.Flow.RESOLUTION });
   voice_notes.addTickables([self._makeBeat(notes, duration)]);

   var text_notes = new Vex.Flow.Voice({ num_beats: 1, beat_value: duration, resolution: Vex.Flow.RESOLUTION });
   text_notes.addTickables([self._beatAnnotation(duration, annotation)]);

   self._draw(voice_notes, text_notes);
};

Score.Stave.prototype.drawSequence = function(beats) {
   var self = this;

   var seq = self._makeSequence(beats);

   var voice_notes = new Vex.Flow.Voice({ num_beats: seq.num_beats, beat_value: seq.beat_value, resolution: Vex.Flow.RESOLUTION });
   voice_notes.addTickables(seq.notes);

   var text_notes = new Vex.Flow.Voice({ num_beats: seq.num_beats, beat_value: seq.beat_value, resolution: Vex.Flow.RESOLUTION });
   text_notes.addTickables(seq.annotation);

   self._draw(voice_notes, text_notes);
};

Score.Stave.prototype._draw = function(voice, annotation) {
   var self = this;
   self._ctx.clearRect(0, 0, self._canvas.width, self._canvas.height);
   var formatter = new Vex.Flow.Formatter().joinVoices([voice, annotation]).format([voice, annotation], self._width);
   self._stave.draw();
   voice.draw(self._ctx, self._stave);
   annotation.draw(self._ctx, self._stave);
};

Score.Stave.prototype._makeBeat = function(notes, duration) {
   var self = this;

   var keys = [];
   notes.forEach(function (note_info) {
      keys.push(note_info.name+"/"+(note_info.octave || '4'));
   });

   var stave_note = new Vex.Flow.StaveNote({ keys: keys, duration: duration.toString(), clef: self._clef_name, auto_stem: true });

   for (var i = 0; i < notes.length; ++i) {
      if (notes[i].accidental) {
         stave_note.addAccidental(i, new Vex.Flow.Accidental(notes[i].accidental));
      }
   }
   return stave_note;
};

Score.Stave.prototype._beatAnnotation = function(duration, annotation) {
   var self = this;
   var annotation = annotation || {text: '', position: 0};
   var text_note = new Vex.Flow.TextNote({ text: annotation.text,
                                           font: {family: 'Arial', size: 10, weight: ''},
                                           duration: duration.toString() }).setLine(annotation.position).setJustification(Vex.Flow.TextNote.Justification.LEFT).setContext(self._ctx);
   return text_note;
};

Score.Stave.prototype._makeSequence = function(beats) {
   var self = this;

   var stave_notes = [];
   var text_notes = [];
   var total_duration = 0;
   beats.forEach(function (beat_info) {
      stave_notes.push(self._makeBeat(beat_info.notes, beat_info.duration));
      text_notes.push(self._beatAnnotation(beat_info.duration, beat_info.annotation));
      total_duration += 32/beat_info.duration;
   });

   return {notes: stave_notes, num_beats: total_duration, beat_value: 32, annotation: text_notes};
};

}(window.Score = window.Score || {}));

<|endoftext|>


<commit_before>///import core
///import commands/inserthtml.js
///commands 插入公式
///commandsName  formula
///commandsTitle  插入公式
///commandsDialog  dialogs\formula\formula.html

UE.plugins['formula'] = function () {
    var me = this;
    me._formulaid = 0;

    var filter = function (node) {
        return domUtils.findParent(node, function (node) {
            return node.nodeType == 1 && node.tagName.toLowerCase() == 'span' && domUtils.hasClass(node, 'mathquill-rendered-math')
        }, true);
    };

    var setCursorPos = function (range, start, end, callback) {
        if (start && end && start === end) {
            if (start.nextSibling) {
                range.setStart(start.nextSibling, 0)
            } else {
                if (start.previousSibling) {
                    range.setStartAtLast(start.previousSibling)
                } else {
                    var p = me.document.createElement('p');
                    domUtils.fillNode(me.document, p);
                    range.setStart(p, 0)
                }
            }
            range.setCursor(false, true);
            callback();
        }
    };

    function addFillChar(node) {
        var previous = node.previousSibling,
            next = node.nextSibling;

        if (!previous || !domUtils.isFillChar(previous)) {
            node.parentNode.insertBefore(document.createTextNode(domUtils.fillChar), node);
        }
        if (!next || !domUtils.isFillChar(next)) {
            domUtils.insertAfter(node, document.createTextNode(domUtils.fillChar));
        }
    }

    me.addListener("ready", function () {
        utils.loadFile(me.document, {
            id:"mathquill_css",
            tag:"link",
            rel:"stylesheet",
            type:"text/css",
            href:me.options.formulaCssUrl || me.options.UEDITOR_HOME_URL + "third-party/mathquill/mathquill.css"
        });
        utils.loadFile(me.document, {
            id:"jquery.min_js",
            src:me.options.jqueryUrl || me.options.UEDITOR_HOME_URL + "third-party/mathquill/jquery.min.js",
            tag:"script",
            type:"text/javascript",
            defer:"defer"
        }, function () {
            utils.loadFile(me.document, {
                id:"mathquill_js",
                src:me.options.formulaJsUrl || me.options.UEDITOR_HOME_URL + "third-party/mathquill/mathquill.min.js",
                tag:"script",
                type:"text/javascript",
                defer:"defer"
            });
        });
    });

    me.addListener("afterbackspace", function (types, evt) {
        var rng = me.selection.getRange();
        var formula = rng.startContainer.childNodes[rng.startOffset - 1];
        if (formula) {
            if (domUtils.hasClass(formula, "mathquill-rendered-math")) {
                var bk = rng.createBookmark();
                domUtils.remove(formula);
                rng.moveToBookmark(bk).select();
                evt.preventDefault();
            }
        }
    });

    me.addListener("keydown", function (types, evt) {
        var keyCode = evt.keyCode || evt.which;
        if (keyCode == 46) {
            var rng = me.selection.getRange();
            var formula = domUtils.getNextDomNode(rng.startContainer);
            if (formula) {
                if (domUtils.hasClass(formula, "mathquill-rendered-math")) {
                    var bk = rng.createBookmark();
                    domUtils.remove(formula);
                    rng.moveToBookmark(bk).select();
                    evt.preventDefault();
                }
            }
        }
    });

    function queryState() {
        try {
            var rng = this.selection.getRange();
            var start = filter(rng.startContainer);
            var end = filter(rng.endContainer);
            if (start && end && start == end) {
                addFillChar(start);
                return 1;
            } else {
                return 0;
            }
        }
        catch (e) {
            return 0;
        }
    }

    //不需要判断highlight的command列表
    me.notNeedmathQuery = {
        help:1,
        undo:1,
        redo:1,
        source:1,
        print:1,
        searchreplace:1,
        fullscreen:1,
        autotypeset:1,
        pasteplain:1,
        preview:1,
        insertparagraph:1,
        elementpath:1,
        formula:1,
        formuladelete:1,
        formualmergeup:1
    };

    //将queyCommamndState重置
    var orgQuery = me.queryCommandState;
    me.queryCommandState = function (cmd) {
        if (!me.notNeedmathQuery[cmd.toLowerCase()] && queryState.call(this) == 1) {
            return -1;
        }
        return orgQuery.apply(this, arguments)
    };

    me.addListener("beforegetcontent beforegetscene", function () {
        if (!me.window || !me.window.$)return;
        utils.each(domUtils.getElementsByTagName(me.body, 'span', 'mathquill-rendered-math'), function (di) {
            var id = di.getAttribute("formulaid");
            var txt = me.window.$("[formulaid=" + id + "]").mathquill("latex");
            var span = domUtils.createElement(me.document, 'math', {
                'class':'mathquill-embedded-latex',
                'formulaid':id
            });
            span.appendChild(me.document.createTextNode(txt));
            di.parentNode.replaceChild(span, di);
        });
    });
    me.addListener("aftergetcontent aftersetcontent aftergetscene", function () {
        if (!me.window || !me.window.$)return;
        var list = me.window.$("math"), obj = {};
        if (list.length) {
            for (var i = 0, len = list.length; i < len; i++) {
                obj[list[i].getAttribute("formulaid")] = list[i].innerText || list[i].textContent || list[i].nodeValue;
            }
            for (var attr in obj) {
                var node = me.window.$("[formulaid=" + attr + "]")[0];
                var span = domUtils.createElement(me.document, 'span', {
                    'class':'mathquill-embedded-latex',
                    'formulaid':node.getAttribute("formulaid")
                });
                node.parentNode.replaceChild(span, node);

                me.window.$("[formulaid=" + attr + "]").html("").mathquill("editable")
                    .mathquill("write", obj[attr].replace("{/}", "\\"));
            }
        }
    });

    me.addListener("beforepaste", function (type, obj) {
        obj.html = obj.html.replace(/formulaid=(["'])(\d)*\1/ig, function () {
            me._formulaid += 1;
            return "formulaid='" + me._formulaid + "'";
        });
    });
    me.addListener("afterpaste", function (type, obj) {
        if (!me.window || !me.window.$)return;
        var list = [];
        obj.html.replace(/formulaid=(["'])(\d*)\1/ig, function (all, char, id) {
            list.push(id);
        });
        if (list.length) {
            for (var i = 0, id; id = list[i++];) {
                var nodes = me.window.$("[formulaid=" + id + "]");
                var txt = nodes[0].mathquill("latex");
                var span = domUtils.createElement(me.document, "span", {
                    'class':'mathquill-editable',
                    formulaid:id
                });
                span.appendChild(me.document.createTextNode(txt));
                nodes[0].parentNode.replaceChild(span, nodes[0]);
                me.window.$("[formulaid=" + id + "]").mathquill("editable");
            }
        }
    });

    me.commands['formula'] = {
        execCommand:function (cmdName, txt) {
            var rng = me.selection.getRange();
            var start = filter(rng.startContainer);
            var end = filter(rng.endContainer);
            var id = 0;

            if (start && end && start == end) {
                id = start.getAttribute("formulaid");
            } else {
                var doc = me.document;
                var span = domUtils.createElement(doc, "span", {
                    'class':'mathquill-editable',
                    formulaid:me._formulaid
                });
                span.appendChild(doc.createTextNode(txt));
                me.execCommand('inserthtml', span.outerHTML);

                id = me._formulaid;
                me.window.$("[formulaid=" + id + "]").html("").mathquill('editable');
                me._formulaid += 1;
            }

            var list = me.window.$("[formulaid=" + id + "]");
            list.mathquill("write", txt.replace("{/}", "\\"));

            rng.setStartAfter(list[0]).collapse(true);
            rng.setCursor();
        },
        queryCommandState:function () {
            return queryState.call(me);
        }
    };

    me.commands["formuladelete"] = {
        execCommand:function () {
            var range = me.selection.getRange();
            var start = filter(range.startContainer),
                end = filter(range.endContainer);

            setCursorPos(range, start, end, function () {
                domUtils.remove(start);
            });
        },
        queryCommandState:function () {
            try {
                var rng = me.selection.getRange();
                var start = filter(rng.startContainer);
                var end = filter(rng.endContainer);
                return start && end && start == end ? 0 : -1;
            } catch (e) {
                return -1;
            }

        }
    };

    me.commands["formualmergeup"] = {
        execCommand:function () {
            var range = me.selection.getRange();
            var start = filter(range.startContainer),
                end = filter(range.endContainer);

            setCursorPos(range, start, end, function () {
                var p = domUtils.findParent(start, function (node) {
                    return node.nodeType == 1 && node.tagName.toLowerCase() == 'p';
                });
                var cur = start.previousSibling;
                while (cur) {
                    if (!domUtils.isFillChar(cur) && domUtils.isBr(cur)) {
                        domUtils.remove(cur);
                        break;
                    } else {
                        cur = cur.previousSibling;
                    }
                }

                domUtils.mergeSibling(p, false, true);
            });
        },
        queryCommandState:function () {
            try {
                var rng = me.selection.getRange();
                var li = domUtils.findParent(rng.startContainer, function (node) {
                    return node.nodeType == 1 && node.tagName.toLowerCase() == 'li';
                }, true);

                if (!li) {
                    var start = filter(rng.startContainer);
                    var end = filter(rng.endContainer);
                    return start && end && start == end ? 0 : 1;
                }

            } catch (e) {
                return -1;
            }

        }
    };
};<commit_msg>[fixed] by xuheng<commit_after>///import core
///import commands/inserthtml.js
///commands 插入公式
///commandsName  formula
///commandsTitle  插入公式
///commandsDialog  dialogs\formula\formula.html

UE.plugins['formula'] = function () {
    var me = this;
    me._formulaid = 0;

    var filter = function (node) {
        return domUtils.findParent(node, function (node) {
            return node.nodeType == 1 && node.tagName.toLowerCase() == 'span' && domUtils.hasClass(node, 'mathquill-rendered-math')
        }, true);
    };

    var setCursorPos = function (range, start, end, callback) {
        if (start && end && start === end) {
            if (start.nextSibling) {
                range.setStart(start.nextSibling, 0)
            } else {
                if (start.previousSibling) {
                    range.setStartAtLast(start.previousSibling)
                } else {
                    var p = me.document.createElement('p');
                    domUtils.fillNode(me.document, p);
                    range.setStart(p, 0)
                }
            }
            range.setCursor(false, true);
            callback();
        }
    };

    function addFillChar(node) {
        var previous = node.previousSibling,
            next = node.nextSibling;

        if (!previous || !domUtils.isFillChar(previous)) {
            node.parentNode.insertBefore(document.createTextNode(domUtils.fillChar), node);
        }
        if (!next || !domUtils.isFillChar(next)) {
            domUtils.insertAfter(node, document.createTextNode(domUtils.fillChar));
        }
    }

    me.addListener("ready", function () {
        utils.loadFile(me.document, {
            id:"mathquill_css",
            tag:"link",
            rel:"stylesheet",
            type:"text/css",
            href:me.options.formulaCssUrl || me.options.UEDITOR_HOME_URL + "third-party/mathquill/mathquill.css"
        });
        utils.loadFile(me.document, {
            id:"jquery.min_js",
            src:me.options.jqueryUrl || me.options.UEDITOR_HOME_URL + "third-party/mathquill/jquery.min.js",
            tag:"script",
            type:"text/javascript",
            defer:"defer"
        }, function () {
            utils.loadFile(me.document, {
                id:"mathquill_js",
                src:me.options.formulaJsUrl || me.options.UEDITOR_HOME_URL + "third-party/mathquill/mathquill.min.js",
                tag:"script",
                type:"text/javascript",
                defer:"defer"
            });
        });
    });

    me.addListener("afterbackspace", function (types, evt) {
        var rng = me.selection.getRange();
        var formula = rng.startContainer.childNodes[rng.startOffset - 1];
        if (formula) {
            if (domUtils.hasClass(formula, "mathquill-rendered-math")) {
                var bk = rng.createBookmark();
                domUtils.remove(formula);
                rng.moveToBookmark(bk).select();
                evt.preventDefault();
            }
        }
    });

    me.addListener("keydown", function (types, evt) {
        var keyCode = evt.keyCode || evt.which;
        if (keyCode == 46) {
            var rng = me.selection.getRange();
            var formula = domUtils.getNextDomNode(rng.startContainer);
            if (formula) {
                if (domUtils.hasClass(formula, "mathquill-rendered-math")) {
                    var bk = rng.createBookmark();
                    domUtils.remove(formula);
                    rng.moveToBookmark(bk).select();
                    evt.preventDefault();
                }
            }
        }
    });

    function queryState() {
        try {
            var rng = this.selection.getRange();
            var start = filter(rng.startContainer);
            var end = filter(rng.endContainer);
            if (start && end && start == end) {
                addFillChar(start);
                return 1;
            } else {
                return 0;
            }
        }
        catch (e) {
            return 0;
        }
    }

    //不需要判断highlight的command列表
    me.notNeedmathQuery = {
        help:1,
        undo:1,
        redo:1,
        source:1,
        print:1,
        searchreplace:1,
        fullscreen:1,
        autotypeset:1,
        pasteplain:1,
        preview:1,
        insertparagraph:1,
        elementpath:1,
        formula:1,
        formuladelete:1,
        formualmergeup:1
    };

    //将queyCommamndState重置
    var orgQuery = me.queryCommandState;
    me.queryCommandState = function (cmd) {
        if (!me.notNeedmathQuery[cmd.toLowerCase()] && queryState.call(this) == 1) {
            return -1;
        }
        return orgQuery.apply(this, arguments)
    };

    me.addListener("beforegetcontent beforegetscene", function () {
        if (!me.window || !me.window.$)return;
        utils.each(domUtils.getElementsByTagName(me.body, 'span', 'mathquill-rendered-math'), function (di) {
            var id = di.getAttribute("formulaid");
            var txt = me.window.$("[formulaid=" + id + "]").mathquill("latex");
            var span = domUtils.createElement(me.document, 'math', {
                'class':'mathquill-embedded-latex',
                'formulaid':id
            });
            span.appendChild(me.document.createTextNode(txt));
            di.parentNode.replaceChild(span, di);
        });
    });
    me.addListener("aftergetcontent aftersetcontent aftergetscene", function () {
        if (!me.window || !me.window.$)return;
        var list = me.window.$("math"), obj = {};
        if (list.length) {
            for (var i = 0, len = list.length; i < len; i++) {
                obj[list[i].getAttribute("formulaid")] = list[i].innerText || list[i].textContent || list[i].nodeValue;
            }
            for (var attr in obj) {
                var node = me.window.$("[formulaid=" + attr + "]")[0];
                var span = domUtils.createElement(me.document, 'span', {
                    'class':'mathquill-embedded-latex',
                    'formulaid':node.getAttribute("formulaid")
                });
                node.parentNode.replaceChild(span, node);

                me.window.$("[formulaid=" + attr + "]").html("").mathquill("editable")
                    .mathquill("write", obj[attr].replace("{/}", "\\"));
            }
        }
    });

    me.addListener("beforepaste", function (type, obj) {
        obj.html = obj.html.replace(/formulaid=(["'])(\d)*\1/ig, function () {
            me._formulaid += 1;
            return "formulaid='" + me._formulaid + "'";
        });
    });
    me.addListener("afterpaste", function (type, obj) {
        if (!me.window || !me.window.$)return;
        var list = [];
        obj.html.replace(/formulaid=(["'])(\d*)\1/ig, function (all, char, id) {
            list.push(id);
        });
        if (list.length) {
            for (var i = 0, id; id = list[i++];) {
                var nodes = me.window.$("[formulaid=" + id + "]");
                var txt = nodes.mathquill("latex");
                var span = domUtils.createElement(me.document, "span", {
                    'class':'mathquill-editable',
                    formulaid:id
                });
                span.appendChild(me.document.createTextNode(txt));
                nodes[0].parentNode.replaceChild(span, nodes[0]);
                me.window.$("[formulaid=" + id + "]").mathquill("editable");
            }
        }
    });

    me.commands['formula'] = {
        execCommand:function (cmdName, txt) {
            var rng = me.selection.getRange();
            var start = filter(rng.startContainer);
            var end = filter(rng.endContainer);
            var id = 0;

            if (start && end && start == end) {
                id = start.getAttribute("formulaid");
            } else {
                var doc = me.document;
                var span = domUtils.createElement(doc, "span", {
                    'class':'mathquill-editable',
                    formulaid:me._formulaid
                });
                span.appendChild(doc.createTextNode(txt));
                me.execCommand('inserthtml', span.outerHTML);

                id = me._formulaid;
                me.window.$("[formulaid=" + id + "]").html("").mathquill('editable');
                me._formulaid += 1;
            }

            var list = me.window.$("[formulaid=" + id + "]");
            list.mathquill("write", txt.replace("{/}", "\\"));

            rng.setStartAfter(list[0]).collapse(true);
            rng.setCursor();
        },
        queryCommandState:function () {
            return queryState.call(me);
        }
    };

    me.commands["formuladelete"] = {
        execCommand:function () {
            var range = me.selection.getRange();
            var start = filter(range.startContainer),
                end = filter(range.endContainer);

            setCursorPos(range, start, end, function () {
                domUtils.remove(start);
            });
        },
        queryCommandState:function () {
            try {
                var rng = me.selection.getRange();
                var start = filter(rng.startContainer);
                var end = filter(rng.endContainer);
                return start && end && start == end ? 0 : -1;
            } catch (e) {
                return -1;
            }

        }
    };

    me.commands["formualmergeup"] = {
        execCommand:function () {
            var range = me.selection.getRange();
            var start = filter(range.startContainer),
                end = filter(range.endContainer);

            setCursorPos(range, start, end, function () {
                var p = domUtils.findParent(start, function (node) {
                    return node.nodeType == 1 && node.tagName.toLowerCase() == 'p';
                });
                var cur = start.previousSibling;
                while (cur) {
                    if (!domUtils.isFillChar(cur) && domUtils.isBr(cur)) {
                        domUtils.remove(cur);
                        break;
                    } else {
                        cur = cur.previousSibling;
                    }
                }

                domUtils.mergeSibling(p, false, true);
            });
        },
        queryCommandState:function () {
            try {
                var rng = me.selection.getRange();
                var li = domUtils.findParent(rng.startContainer, function (node) {
                    return node.nodeType == 1 && node.tagName.toLowerCase() == 'li';
                }, true);

                if (!li) {
                    var start = filter(rng.startContainer);
                    var end = filter(rng.endContainer);
                    return start && end && start == end ? 0 : 1;
                }

            } catch (e) {
                return -1;
            }

        }
    };
};<|endoftext|>


<commit_before>// source: http://lab.sulko.co/designer-bio

(function(){
	var mundanes = ['Kinda feminist, ', 'Not vegan, ', 'Zombie aficionado, ', 'Dad of 2 dogs, ', 'Creator of stuff, ', 'Nature enthusiast, ', 'Civil servant, ', 'Ska band member, ', 'Fiber artist, '];
	var vintages = ['drummer, ', 'ukulelist, ', 'hand letterer, ', 'graffiti writer, ', 'capoeirista, ', 'skateboarder, ', 'Liverpool fan, ', 'hot cheetos connoisseur, ', 'DJ, '];
	var pros = ['furniture maker. ', 'unicorn. ', 'double-stack designer. ', 'teacher. ', 'experience artist. ', 'visual poet. ', 'enjoys poetry, sunshine, and carbs. '];
	var ops = ['Working on stuff ', 'Designing stuff ', 'Developing stuff ', 'Producing stuff ', 'Building stuff ', 'Crafting stuff ', 'Making stuff '];
	var inters = ['at the intersection of ', 'at the junction of ', 'at the crossroads of ', 'at the sweet spot between ', 'at the nexus of '];
	var beautys = ['beauty and ', 'art and ', 'aesthetics and ', 'elegance to ', 'modernism and ', 'minimalism and ', 'fantasy and ', 'sci-fi and ', 'simplicity and ', 'form and '];
	var funcs = ['function to ', 'purpose to ', 'intellectual purity to ', 'programming to ', 'science to ', 'language to', 'technology to ', 'design and ', 'mathematics to ', 'sustainability to ', 'magic to ', 'hyperreality to '];
	var exps = [
		'express ideas through art & design.', 'craft delightful human experiences.', 'create beloved and lasting experience.',
		'create not just a logo, but feelings and emotions.', 'solving design problems with honest solutions.',
		'craft experiences that go beyond transcendence.', 'shape an inspiring narrative.',
		'visualize human experiences both online and IRL.', 'build service for the humankind.'];
	var wilds = [
		'My opinions belong to the void.'.link('javascript:window.location.reload(true)'),
		'All are equal.'.link('javascript:window.location.reload(true)'),
		'World Peace.'.link('javascript:window.location.reload(true)'),
		'Spacing, Kerning, Typesetting.'.link('javascript:window.location.reload(true)'),
		'I enjoy doing things that demand patience and precision.'.link('javascript:window.location.reload(true)'),
		'It’s okay to be happy, even in your imperfections and failures because that’s what makes you human. And being human is messy and beautiful.'.link('javascript:window.location.reload(true)'),
		'I want you to know that happiness is okay, even when the world is aching. Because what the world desperately needs is positivity, and it starts with a smile.'.link('javascript:window.location.reload(true)'),
		'Deadline is the source of my inspiration.'.link('javascript:window.location.reload(true)'),
		'Opinions belong to my dogs.'.link('javascript:window.location.reload(true)'),
		'Imagining mermaids since 1984.'.link('javascript:window.location.reload(true)'),
		'Less is less, more is more. Not less not more is not more not less.'.link('javascript:window.location.reload(true)'),
		'Furniture designer turned UX and I create my own typefaces.'.link('javascript:window.location.reload(true)'),
		'I am 6 years old.'.link('javascript:window.location.reload(true)'),
		'I need a coffee.'.link('javascript:window.location.reload(true)'),
		'Let’s get coffee?'.link('javascript:window.location.reload(true)'),
		'Coffee?'.link('javascript:window.location.reload(true)'),
		'I am.'.link('javascript:window.location.reload(true)'),
		'Lorem Ipsum.'.link('javascript:window.location.reload(true)'),
		'Aluminium.'.link('javascript:window.location.reload(true)'),
		'I study master’s degrees as a hobby.'.link('javascript:window.location.reload(true)'),
		'We can do better.'.link('javascript:window.location.reload(true)'),
		'Profound.'.link('javascript:window.location.reload(true)'),
		'Pure passion.'.link('javascript:window.location.reload(true)'),
		'I love sushi.'.link('javascript:window.location.reload(true)'),
		'Love is worth everything. Everything.'.link('javascript:window.location.reload(true)'),
		'The secret to creativity is knowing how to hide your sources.'.link('javascript:window.location.reload(true)'),
		'I want you to know that it is okay to suck at something.'.link('javascript:window.location.reload(true)'),
		'Time is irrelevant.'.link('javascript:window.location.reload(true)'),
		'Making the world a better place better than any one else.'.link('javascript:window.location.reload(true)'),
		'Turtle is my spirit animal.'.link('javascript:window.location.reload(true)'),
		'Don’t try to be original. Just try to be nice.'.link('javascript:window.location.reload(true)'),
		'Simplicity.'.link('javascript:window.location.reload(true)'),
		'Humanity.'.link('javascript:window.location.reload(true)'),
		'Polymath.'.link('javascript:window.location.reload(true)'),
		'Generate.'.link('javascript:window.location.reload(true)'),
		'Charrette.'.link('javascript:window.location.reload(true)'),
		'Reload.'.link('javascript:window.location.reload(true)'),
		'Refresh.'.link('javascript:window.location.reload(true)'),
		'Process.'.link('javascript:window.location.reload(true)'),
		'Disrupt.'.link('javascript:window.location.reload(true)'),
		'Ephemeral.'.link('javascript:window.location.reload(true)'),
		'Frankenstein.'.link('javascript:window.location.reload(true)'),
		'FTUX.'.link('javascript:window.location.reload(true)'),
		'Insight.'.link('javascript:window.location.reload(true)'),
		'Magic.'.link('javascript:window.location.reload(true)'),
		'Dank.'.link('javascript:window.location.reload(true)'),
		'Synergize.'.link('javascript:window.location.reload(true)'),
		'Pizza.'.link('javascript:window.location.reload(true)'),
		'Kale.'.link('javascript:window.location.reload(true)'),
		'Next.'.link('javascript:window.location.reload(true)'),
		'Kombucha.'.link('javascript:window.location.reload(true)'),
		'Sriracha.'.link('javascript:window.location.reload(true)'),
		'Helvetica.'.link('javascript:window.location.reload(true)'),
		'Restart.'.link('javascript:window.location.reload(true)'),
		'Continue.'.link('javascript:window.location.reload(true)'),
		'More.'.link('javascript:window.location.reload(true)'),
		'Advance.'.link('javascript:window.location.reload(true)'),
		'Optimize.'.link('javascript:window.location.reload(true)'),
		'Random.'.link('javascript:window.location.reload(true)'),
		'Randomize.'.link('javascript:window.location.reload(true)'),
		'Randomization.'.link('javascript:window.location.reload(true)'),
		'Peace.'.link('javascript:window.location.reload(true)'),
		'Love.'.link('javascript:window.location.reload(true)'),
		'Cool.'.link('javascript:window.location.reload(true)'),
		'Rad.'.link('javascript:window.location.reload(true)'),
		':)'.link('javascript:window.location.reload(true)'),
		'Let’s chat 💬'.link('javascript:window.location.reload(true)'),
		'Okay, bye ☃'.link('javascript:window.location.reload(true)'),
		'❌⭕❌⭕'.link('javascript:window.location.reload(true)'),
		'❤'.link('javascript:window.location.reload(true)'),
		'💩'.link('javascript:window.location.reload(true)'),
		'😘'.link('javascript:window.location.reload(true)'),
		'🌝'.link('javascript:window.location.reload(true)'),
		'☕'.link('javascript:window.location.reload(true)'),
		'🎈'.link('javascript:window.location.reload(true)'),
		'💯'.link('javascript:window.location.reload(true)'),
		'🍆'.link('javascript:window.location.reload(true)'),
		'🐢'.link('javascript:window.location.reload(true)'),
		'🌵'.link('javascript:window.location.reload(true)'),
		'🍕'.link('javascript:window.location.reload(true)'),
		'🚀'.link('javascript:window.location.reload(true)'),
		'🐳'.link('javascript:window.location.reload(true)')
	];

	var mundane = mundanes[Math.floor(Math.random()*mundanes.length)];
	var vintage = vintages[Math.floor(Math.random()*vintages.length)];
	var pro = pros[Math.floor(Math.random()*pros.length)];
	var op = ops[Math.floor(Math.random()*ops.length)];
	var inter = inters[Math.floor(Math.random()*inters.length)];
	var beauty = beautys[Math.floor(Math.random()*beautys.length)];
	var func = funcs[Math.floor(Math.random()*funcs.length)];
	var exp = exps[Math.floor(Math.random()*exps.length)];
	var wild = wilds[Math.floor(Math.random()*wilds.length)];

	// init
	document.getElementById("bio").innerHTML = '
' + mundane + vintage + pro + op + inter + beauty + func + exp + '
';
	document.getElementById("bio-wild").innerHTML = '
' + wild + '
';
})();
<commit_msg>Update bio.js<commit_after>// source: http://lab.sulko.co/designer-bio

(function(){
	var mundanes = ['Kinda feminist, ', 'Not vegan, ', 'Zombie aficionado, ', 'Dad of 2 dogs, ', 'Creator of stuff, ', 'Nature enthusiast, ', 'Civil servant, ', 'Ska band member, ', 'Fiber artist, '];
	var vintages = ['drummer, ', 'ukulelist, ', 'hand letterer, ', 'graffiti writer, ', 'capoeirista, ', 'skateboarder, ', 'Liverpool fan, ', 'hot cheetos connoisseur, ', 'DJ, '];
	var pros = ['furniture maker. ', 'unicorn. ', 'double-stack designer. ', 'teacher. ', 'experience artist. ', 'visual poet. ', 'enjoys poetry, sunshine, and carbs. '];
	var ops = ['Working on stuff ', 'Designing stuff ', 'Developing stuff ', 'Producing stuff ', 'Building stuff ', 'Crafting stuff ', 'Making stuff '];
	var inters = ['at the intersection of ', 'at the junction of ', 'at the crossroads of ', 'at the sweet spot between ', 'at the nexus of '];
	var beautys = ['beauty and ', 'art and ', 'aesthetics and ', 'elegance to ', 'modernism and ', 'minimalism and ', 'fantasy and ', 'sci-fi and ', 'simplicity and ', 'form and '];
	var funcs = ['function to ', 'purpose to ', 'intellectual purity to ', 'programming to ', 'science to ', 'language to', 'technology to ', 'design and ', 'mathematics to ', 'sustainability to ', 'magic to ', 'hyperreality to '];
	var exps = [
		'craft delightful human experiences.', 'create beloved and lasting experience.',
		'create not just a logo, but feelings and emotions.', 'solving design problems with honest solutions.',
		'craft experiences that go beyond transcendence.', 'shape an inspiring narrative.',
		'visualize human experiences both online and IRL.', 'build service for the humankind.'];
	var wilds = [
		'My opinions belong to the void.'.link('javascript:window.location.reload(true)'),
		'All are equal.'.link('javascript:window.location.reload(true)'),
		'World Peace.'.link('javascript:window.location.reload(true)'),
		'Spacing, Kerning, Typesetting.'.link('javascript:window.location.reload(true)'),
		'I enjoy doing things that demand patience and precision.'.link('javascript:window.location.reload(true)'),
		'It’s okay to be happy, even in your imperfections and failures because that’s what makes you human. And being human is messy and beautiful.'.link('javascript:window.location.reload(true)'),
		'I want you to know that happiness is okay, even when the world is aching. Because what the world desperately needs is positivity, and it starts with a smile.'.link('javascript:window.location.reload(true)'),
		'Deadline is the source of my inspiration.'.link('javascript:window.location.reload(true)'),
		'Opinions belong to my dogs.'.link('javascript:window.location.reload(true)'),
		'Imagining mermaids since 1984.'.link('javascript:window.location.reload(true)'),
		'Less is less, more is more. Not less not more is not more not less.'.link('javascript:window.location.reload(true)'),
		'Furniture designer turned UX and I create my own typefaces.'.link('javascript:window.location.reload(true)'),
		'I am 6 years old.'.link('javascript:window.location.reload(true)'),
		'I need a coffee.'.link('javascript:window.location.reload(true)'),
		'Let’s get coffee?'.link('javascript:window.location.reload(true)'),
		'Coffee?'.link('javascript:window.location.reload(true)'),
		'I am.'.link('javascript:window.location.reload(true)'),
		'Lorem Ipsum.'.link('javascript:window.location.reload(true)'),
		'Aluminium.'.link('javascript:window.location.reload(true)'),
		'I study master’s degrees as a hobby.'.link('javascript:window.location.reload(true)'),
		'We can do better.'.link('javascript:window.location.reload(true)'),
		'Profound.'.link('javascript:window.location.reload(true)'),
		'Pure passion.'.link('javascript:window.location.reload(true)'),
		'I love sushi.'.link('javascript:window.location.reload(true)'),
		'Love is worth everything. Everything.'.link('javascript:window.location.reload(true)'),
		'The secret to creativity is knowing how to hide your sources.'.link('javascript:window.location.reload(true)'),
		'I want you to know that it is okay to suck at something.'.link('javascript:window.location.reload(true)'),
		'Time is irrelevant.'.link('javascript:window.location.reload(true)'),
		'Making the world a better place better than any one else.'.link('javascript:window.location.reload(true)'),
		'Turtle is my spirit animal.'.link('javascript:window.location.reload(true)'),
		'Don’t try to be original. Just try to be nice.'.link('javascript:window.location.reload(true)'),
		'Simplicity.'.link('javascript:window.location.reload(true)'),
		'Humanity.'.link('javascript:window.location.reload(true)'),
		'Polymath.'.link('javascript:window.location.reload(true)'),
		'Generate.'.link('javascript:window.location.reload(true)'),
		'Charrette.'.link('javascript:window.location.reload(true)'),
		'Reload.'.link('javascript:window.location.reload(true)'),
		'Refresh.'.link('javascript:window.location.reload(true)'),
		'Process.'.link('javascript:window.location.reload(true)'),
		'Disrupt.'.link('javascript:window.location.reload(true)'),
		'Ephemeral.'.link('javascript:window.location.reload(true)'),
		'Frankenstein.'.link('javascript:window.location.reload(true)'),
		'FTUX.'.link('javascript:window.location.reload(true)'),
		'Insight.'.link('javascript:window.location.reload(true)'),
		'Magic.'.link('javascript:window.location.reload(true)'),
		'Dank.'.link('javascript:window.location.reload(true)'),
		'Synergize.'.link('javascript:window.location.reload(true)'),
		'Pizza.'.link('javascript:window.location.reload(true)'),
		'Kale.'.link('javascript:window.location.reload(true)'),
		'Next.'.link('javascript:window.location.reload(true)'),
		'Kombucha.'.link('javascript:window.location.reload(true)'),
		'Sriracha.'.link('javascript:window.location.reload(true)'),
		'Helvetica.'.link('javascript:window.location.reload(true)'),
		'Restart.'.link('javascript:window.location.reload(true)'),
		'Continue.'.link('javascript:window.location.reload(true)'),
		'More.'.link('javascript:window.location.reload(true)'),
		'Advance.'.link('javascript:window.location.reload(true)'),
		'Optimize.'.link('javascript:window.location.reload(true)'),
		'Random.'.link('javascript:window.location.reload(true)'),
		'Randomize.'.link('javascript:window.location.reload(true)'),
		'Randomization.'.link('javascript:window.location.reload(true)'),
		'Peace.'.link('javascript:window.location.reload(true)'),
		'Love.'.link('javascript:window.location.reload(true)'),
		'Cool.'.link('javascript:window.location.reload(true)'),
		'Rad.'.link('javascript:window.location.reload(true)'),
		':)'.link('javascript:window.location.reload(true)'),
		'Let’s chat 💬'.link('javascript:window.location.reload(true)'),
		'Okay, bye ☃'.link('javascript:window.location.reload(true)'),
		'❌⭕❌⭕'.link('javascript:window.location.reload(true)'),
		'❤'.link('javascript:window.location.reload(true)'),
		'💩'.link('javascript:window.location.reload(true)'),
		'😘'.link('javascript:window.location.reload(true)'),
		'🌝'.link('javascript:window.location.reload(true)'),
		'☕'.link('javascript:window.location.reload(true)'),
		'🎈'.link('javascript:window.location.reload(true)'),
		'💯'.link('javascript:window.location.reload(true)'),
		'🍆'.link('javascript:window.location.reload(true)'),
		'🐢'.link('javascript:window.location.reload(true)'),
		'🌵'.link('javascript:window.location.reload(true)'),
		'🍕'.link('javascript:window.location.reload(true)'),
		'🚀'.link('javascript:window.location.reload(true)'),
		'🐳'.link('javascript:window.location.reload(true)')
	];

	var mundane = mundanes[Math.floor(Math.random()*mundanes.length)];
	var vintage = vintages[Math.floor(Math.random()*vintages.length)];
	var pro = pros[Math.floor(Math.random()*pros.length)];
	var op = ops[Math.floor(Math.random()*ops.length)];
	var inter = inters[Math.floor(Math.random()*inters.length)];
	var beauty = beautys[Math.floor(Math.random()*beautys.length)];
	var func = funcs[Math.floor(Math.random()*funcs.length)];
	var exp = exps[Math.floor(Math.random()*exps.length)];
	var wild = wilds[Math.floor(Math.random()*wilds.length)];

	// init
	document.getElementById("bio").innerHTML = '
' + mundane + vintage + pro + op + inter + beauty + func + exp + '
';
	document.getElementById("bio-wild").innerHTML = '
' + wild + '
';
})();
<|endoftext|>


<commit_before>
 /*
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
      This file is part of the Smart Developer Hub Project:
        http://www.smartdeveloperhub.org/
      Center for Open Middleware
            http://www.centeropenmiddleware.com/
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
      Copyright (C) 2015 Center for Open Middleware.
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
                http://www.apache.org/licenses/LICENSE-2.0
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
*/

 'use strict';

 var config = require('./config.json');
 var request = require('sync-request');
 var rdfstore = require('rdfstore');
 // var sparql_parser = require('sparqljs').Parser;

 // Parse Information and send to Callback
 var parseTree = function parseTree (e, returnCallback) {
     if (e.status === 'OK') {
         var r = e.results;
         var re = {};
         for (var i = 0; i < r.length; i++) {
             if(typeof re[r[i].s.value] === 'undefined') {
                 re[r[i].s.value] = [];
             }
             else{
                 var v = {};
                 v[r[i].p.value] = r[i].o.value;
                 re[r[i].s.value].push(v);
             }
         }
         returnCallback({
             "status": "OK",
             "results": re
         });
     }
     else {
         returnCallback(e);
     }
 };

 var generate_error = function generate_error (c) {
     return {
         "status": "ERROR",
         "component": c
     };
 };

exports.get_fragment = function get_fragment (gp) {
     var http_path = config.services.fragmenter.url + ":" +
         config.services.fragmenter.port + config.services.fragmenter.path +
         config.services.fragmenter.query_param + '{';
     var gpe = '';
     if (typeof gp === 'string') {
         gpe += gp;
     }
     else if (Array.isArray(gp)) {
         for (var i = 0; i < gp.length; i++) {
             gpe += gp[i] + ". ";
         }
     }
     else {
         return generate_error("Agora Fragment");
     }
     http_path += encodeURIComponent(gpe) + '}';
     try {
         var req = request('GET', http_path, {
             "headers": config.headers
         });
         if (req.statusCode === 200) {
             return {
                 "status": "OK",
                 "fragment": req.getBody().toString('utf-8')
             };
         }
         else {
             return generate_error("Agora Fragment");
         }
     }
     catch (err) {
         return generate_error("Agora Fragment");
     }
 };

 /* var get_patterns_from_query = function get_patterns_from_query (query) {
     try {
         var parsed = new sparql_parser().parse(query);
         var bgps = parsed.where;
         var patterns = [];
         for (var i = 0; i < bgps.length; i++) {
             if (bgps[i].type === 'bgp') {
                 for (var j = 0; j < bgps[i].triples.length; j++) {
                     var t = '';
                     if (bgps[i].triples[j].subject.indexOf("http") >= 0) {
                         t += '<' + bgps[i].triples[j].subject + '> ';
                     }
                     else {
                         t += bgps[i].triples[j].subject + ' ';
                     }
                     if (bgps[i].triples[j].predicate.indexOf("http") >= 0) {
                         t += '<' + bgps[i].triples[j].predicate + '> ';
                     }
                     else {
                         t += bgps[i].triples[j].predicate + ' ';
                     }
                     if (bgps[i].triples[j].object.indexOf("http") >= 0) {
                         t += '<' + bgps[i].triples[j].object + '>';
                     }
                     else {
                         t += bgps[i].triples[j].object;
                     }
                     patterns.push(t);
                 }
             }
         }
         return {
             "status": "OK",
             "patterns": patterns
         }
     }
     catch (err) {
         return generate_error("SPARQL Parse");
     }
 };*/

exports.get_results_from_fragment = function get_results_from_fragment(fg, q, callback) {
     rdfstore.create(function(err, store) {
         store.load("text/turtle", fg, function(err, results) {
             if(err) {
                 callback(generate_error("SPARQL Query"));
             }
             else {
                 store.execute(q, function (err, results) {
                     if (err) {
                         callback(generate_error("SPARQL Query"));
                     }
                     else {
                         callback({
                             "status": "OK",
                             "results": results
                         });
                     }
                 });
             }
         });
     });
 };

 // module.exports.get_results_from_query = function get_results_from_query(query, callback) {
 /*var get_results_from_query = function get_results_from_query(query, callback) {
     var p = get_patterns_from_query(query);
     if (p.status === "ERROR") {
         callback(p);
     }
     else {
         var fg = get_fragment(p.patterns);
         get_results_from_fragment(fg, query, function(e) {
            callback(e);
         });
     }
 };*/

exports.get_parsed_result = function get_parsed_result(f,q,retCall) {
    this.get_results_from_fragment(f, q, function(e) {
        parseTree(e, retCall);
    });
};

<commit_msg>clean<commit_after>
 /*
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
      This file is part of the Smart Developer Hub Project:
        http://www.smartdeveloperhub.org/
      Center for Open Middleware
            http://www.centeropenmiddleware.com/
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
      Copyright (C) 2015 Center for Open Middleware.
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
      Licensed under the Apache License, Version 2.0 (the "License");
      you may not use this file except in compliance with the License.
      You may obtain a copy of the License at
                http://www.apache.org/licenses/LICENSE-2.0
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
*/

 'use strict';

 var config = require('./config.json');
 var request = require('sync-request');
 var rdfstore = require('rdfstore');
 // var sparql_parser = require('sparqljs').Parser;

 var generate_error = function generate_error (c) {
     return {
         "status": "ERROR",
         "component": c
     };
 };

exports.get_fragment = function get_fragment (gp) {
     var http_path = config.services.fragmenter.url + ":" +
         config.services.fragmenter.port + config.services.fragmenter.path +
         config.services.fragmenter.query_param + '{';
     var gpe = '';
     if (typeof gp === 'string') {
         gpe += gp;
     }
     else if (Array.isArray(gp)) {
         for (var i = 0; i < gp.length; i++) {
             gpe += gp[i] + ". ";
         }
     }
     else {
         return generate_error("Agora Fragment");
     }
     http_path += encodeURIComponent(gpe) + '}';
     try {
         var req = request('GET', http_path, {
             "headers": config.headers
         });
         if (req.statusCode === 200) {
             return {
                 "status": "OK",
                 "fragment": req.getBody().toString('utf-8')
             };
         }
         else {
             return generate_error("Agora Fragment");
         }
     }
     catch (err) {
         return generate_error("Agora Fragment");
     }
 };

 /* var get_patterns_from_query = function get_patterns_from_query (query) {
     try {
         var parsed = new sparql_parser().parse(query);
         var bgps = parsed.where;
         var patterns = [];
         for (var i = 0; i < bgps.length; i++) {
             if (bgps[i].type === 'bgp') {
                 for (var j = 0; j < bgps[i].triples.length; j++) {
                     var t = '';
                     if (bgps[i].triples[j].subject.indexOf("http") >= 0) {
                         t += '<' + bgps[i].triples[j].subject + '> ';
                     }
                     else {
                         t += bgps[i].triples[j].subject + ' ';
                     }
                     if (bgps[i].triples[j].predicate.indexOf("http") >= 0) {
                         t += '<' + bgps[i].triples[j].predicate + '> ';
                     }
                     else {
                         t += bgps[i].triples[j].predicate + ' ';
                     }
                     if (bgps[i].triples[j].object.indexOf("http") >= 0) {
                         t += '<' + bgps[i].triples[j].object + '>';
                     }
                     else {
                         t += bgps[i].triples[j].object;
                     }
                     patterns.push(t);
                 }
             }
         }
         return {
             "status": "OK",
             "patterns": patterns
         }
     }
     catch (err) {
         return generate_error("SPARQL Parse");
     }
 };*/

exports.get_results_from_fragment = function get_results_from_fragment(fg, q, callback) {
     rdfstore.create(function(err, store) {
         store.load("text/turtle", fg, function(err, results) {
             if(err) {
                 callback(generate_error("SPARQL Query"));
             }
             else {
                 store.execute(q, function (err, results) {
                     if (err) {
                         callback(generate_error("SPARQL Query"));
                     }
                     else {
                         callback({
                             "status": "OK",
                             "results": results
                         });
                     }
                 });
             }
         });
     });
 };

 // module.exports.get_results_from_query = function get_results_from_query(query, callback) {
 /*var get_results_from_query = function get_results_from_query(query, callback) {
     var p = get_patterns_from_query(query);
     if (p.status === "ERROR") {
         callback(p);
     }
     else {
         var fg = get_fragment(p.patterns);
         get_results_from_fragment(fg, query, function(e) {
            callback(e);
         });
     }
 };*/

<|endoftext|>


<commit_before>'use strict';

/*
 *  Scrolling Loader
 *  Sl.js v1.0.5
 *
 *  Copyright (C) izure.org 2017. All rights reserved.
 *  MIT LICENSE
 */

/**
 *
 * @param {String} tagname
 * @param {Object} option
 * @param {Function} callback
 */
var Sl = function (tagname, option) {
	if (this instanceof Sl === false) return new Sl(tagname, option);
	this.tagname = tagname;
	this.option = option;
	this.target = [];
	this.callback = [];
	return this;
};

Sl.prototype.observe = function (elemTar) {
	if (document.readyState === 'complete') this.__attach(elemTar);
	else Sl.root.queue.push({
		sl: this, target: elemTar
	});
	return this;
};

Sl.prototype.remove = function (elemTar) {
	var items = elemTar || this.target, self = this;
	for (var i = 0, len = this.target.length; i < len; i++) {
		var index = items.indexOf(this.target[i]), isExist = index !== -1;
		if (isExist) this.target.splice(i, 1);
	}
	if (this.target.length === 0) {
		Sl.root.list.splice(Sl.root.list.indexOf(this), 1);
	}
};

Sl.prototype.then = function (callback) {
	this.callback.push(callback);
	return this;
};

Sl.prototype.__attach = function (elemTar) {
	var items = Sl.root.fn.getNodeList(elemTar), self = this;
	items.forEach(function (item) {
		self.target.push({
			index: 0,
			element: item,
			active: true,
			value: undefined,
			throw: function (value) {
				this.index++;
				this.value = value;
				this.active = true;
				self.__append.call(self, this);
			}
		});
	});
	Sl.root.list.push(self);
};

Sl.prototype.__accept = function (parent) {
	parent.active = false;
	this.callback.forEach(function (fn) {
		fn.call(parent, parent.element, parent.index);
	});
};

Sl.prototype.__append = function (parent) {
	if (parent.active === false) return;
	//
	var element = document.createElement(this.tagname.toLowerCase());
	for (var i in this.option) {
		var res, opt = this.option[i];
		if (typeof opt === 'function') {
			res = opt.call(element, parent.value, parent.index);
		}
		else res = opt;
		//
		if (i === 'text') element.textContent = res;
		else if (i === 'html') {
			if (res instanceof HTMLElement) element.appendChild(res);
			else element.innerHTML = res;
		}
		else {
			element.setAttribute(i, res);
		}
	}
	parent.element.parentNode.insertBefore(element, parent.element);
	setTimeout(Sl.check, 1);
};

Sl.root = {};
Sl.root.fn = {};
Sl.root.list = [];
Sl.root.queue = [];

Sl.check = function () {
	if (document.readyState !== 'complete') return;
	// timer delay for performance
	if (Sl.root.timer) {
		clearTimeout(Sl.root.timer);
	}
	Sl.root.timer = setTimeout(Sl.__fire, 100);
};

Sl.__fire = function () {
	var list = Sl.root.list;
	var scrollY = window.scrollY + document.documentElement.clientHeight;
	for (var i = 0, len = list.length; i < len; i++) {
		var sl = list[i];
		var j = sl.target.length;
		while (j--) {
			var parent = sl.target[j];
			if (parent.element.offsetTop > scrollY) continue;
			else sl.__accept(parent);
		}
	}
};

Sl.root.fn.getNodeList = function (elemTar) {
	var items;
	if (elemTar instanceof Array) items = elemTar;
	else if (elemTar instanceof NodeList) items = Array.prototype.slice.call(elemTar);
	else if (elemTar instanceof HTMLElement) items = [elemTar];
	else items = Array.prototype.slice.call(document.querySelectorAll(elemTar));
	return items;
};

window.addEventListener('scroll', Sl.check);
window.addEventListener('load', function () {
	Sl.root.queue.forEach(function (item) {
		item.sl.__attach(item.target);
	});
	delete Sl.root.queue;
	Sl.check();
});<commit_msg>Fixed an error that all resources were invoked even when not scrolling in ie.<commit_after>'use strict';

/*
 *  Scrolling Loader
 *  Sl.js v1.0.5
 *
 *  Copyright (C) izure.org 2017. All rights reserved.
 *  MIT LICENSE
 */

/**
 *
 * @param {String} tagname
 * @param {Object} option
 * @param {Function} callback
 */
var Sl = function (tagname, option) {
	if (this instanceof Sl === false) return new Sl(tagname, option);
	this.tagname = tagname;
	this.option = option;
	this.target = [];
	this.callback = [];
	return this;
};

Sl.prototype.observe = function (elemTar) {
	if (document.readyState === 'complete') this.__attach(elemTar);
	else Sl.root.queue.push({
		sl: this, target: elemTar
	});
	return this;
};

Sl.prototype.remove = function (elemTar) {
	var items = elemTar || this.target, self = this;
	for (var i = 0, len = this.target.length; i < len; i++) {
		var index = items.indexOf(this.target[i]), isExist = index !== -1;
		if (isExist) this.target.splice(i, 1);
	}
	if (this.target.length === 0) {
		Sl.root.list.splice(Sl.root.list.indexOf(this), 1);
	}
};

Sl.prototype.then = function (callback) {
	this.callback.push(callback);
	return this;
};

Sl.prototype.__attach = function (elemTar) {
	var items = Sl.root.fn.getNodeList(elemTar), self = this;
	items.forEach(function (item) {
		self.target.push({
			index: 0,
			element: item,
			active: true,
			value: undefined,
			throw: function (value) {
				this.index++;
				this.value = value;
				this.active = true;
				self.__append.call(self, this);
			}
		});
	});
	Sl.root.list.push(self);
};

Sl.prototype.__accept = function (parent) {
	parent.active = false;
	this.callback.forEach(function (fn) {
		fn.call(parent, parent.element, parent.index);
	});
};

Sl.prototype.__append = function (parent) {
	if (parent.active === false) return;
	//
	var element = document.createElement(this.tagname.toLowerCase());
	for (var i in this.option) {
		var res, opt = this.option[i];
		if (typeof opt === 'function') {
			res = opt.call(element, parent.value, parent.index);
		}
		else res = opt;
		//
		if (i === 'text') element.textContent = res;
		else if (i === 'html') {
			if (res instanceof HTMLElement) element.appendChild(res);
			else element.innerHTML = res;
		}
		else {
			element.setAttribute(i, res);
		}
	}
	parent.element.parentNode.insertBefore(element, parent.element);
	setTimeout(Sl.check, 1);
};

Sl.root = {};
Sl.root.fn = {};
Sl.root.list = [];
Sl.root.queue = [];

Sl.check = function () {
	if (document.readyState !== 'complete') return;
	// timer delay for performance
	if (Sl.root.timer) {
		clearTimeout(Sl.root.timer);
	}
	Sl.root.timer = setTimeout(Sl.__fire, 100);
};

Sl.__fire = function () {
	var list = Sl.root.list, docElem = document.documentElement;
	var scrollY = docElem.scrollTop + docElem.clientHeight;
	for (var i = 0, len = list.length; i < len; i++) {
		var sl = list[i];
		var j = sl.target.length;
		while (j--) {
			var parent = sl.target[j];
			if (parent.element.offsetTop > scrollY) continue;
			else sl.__accept(parent);
		}
	}
};

Sl.root.fn.getNodeList = function (elemTar) {
	var items;
	if (elemTar instanceof Array) items = elemTar;
	else if (elemTar instanceof NodeList) items = Array.prototype.slice.call(elemTar);
	else if (elemTar instanceof HTMLElement) items = [elemTar];
	else items = Array.prototype.slice.call(document.querySelectorAll(elemTar));
	return items;
};

window.addEventListener('scroll', Sl.check);
window.addEventListener('load', function () {
	Sl.root.queue.forEach(function (item) {
		item.sl.__attach(item.target);
	});
	delete Sl.root.queue;
	Sl.check();
});<|endoftext|>


<commit_before>dojo.provide("dijit._Widget");

dojo.require("dijit._base");

dojo.declare("dijit._Widget", null, {
	constructor: function(params, srcNodeRef){
		this.create(params, srcNodeRef);
	},
	// id: String
	//		a unique, opaque ID string that can be assigned by users or by the
	//		system. If the developer passes an ID which is known not to be
	//		unique, the specified ID is ignored and the system-generated ID is
	//		used instead.
	id: "",

	// lang: String
	//	Language to display this widget in (like en-us).
	//	Defaults to brower's specified preferred language (typically the language of the OS)
	lang: "",

	// dir: String
	//  Bi-directional support, as defined by the HTML DIR attribute. Either left-to-right "ltr" or right-to-left "rtl".
	dir: "",

	// srcNodeRef: DomNode
	//		pointer to original dom node
	srcNodeRef: null,

	// domNode DomNode:
	//		this is our visible representation of the widget! Other DOM
	//		Nodes may by assigned to other properties, usually through the
	//		template system's dojoAttachPonit syntax, but the domNode
	//		property is the canonical "top level" node in widget UI.
	domNode: null,

	//////////// INITIALIZATION METHODS ///////////////////////////////////////

	create: function(params, srcNodeRef) {
		// summary:
		//		To understand the process by which widgets are instantiated, it
		//		is critical to understand what other methods create calls and
		//		which of them you'll want to override. Of course, adventurous
		//		developers could override create entirely, but this should
		//		only be done as a last resort.
		//
		//		Below is a list of the methods that are called, in the order
		//		they are fired, along with notes about what they do and if/when
		//		you should over-ride them in your widget:
		//
		//			postMixInProperties:
		//				a stub function that you can over-ride to modify
		//				variables that may have been naively assigned by
		//				mixInProperties
		//			# widget is added to manager object here
		//			buildRendering
		//				Subclasses use this method to handle all UI initialization
		//				Sets this.domNode.  Templated widgets do this automatically
		//				and otherwise it just uses the source dom node.
		//			postCreate
		//				a stub function that you can over-ride to modify take
		//				actions once the widget has been placed in the UI

		// store pointer to original dom tree
		this.srcNodeRef = dojo.byId(srcNodeRef);

		// For garbage collection.  An array of handles returned by Widget.connect()
		// Each handle returned from Widget.connect() is an array of handles from dojo.connect()
		this._connects=[];

		// _attaches: String[]
		// 		names of all our dojoAttachPoint variables
		this._attaches=[];

		//mixin our passed parameters
		if(this.srcNodeRef && (typeof this.srcNodeRef.id == "string")){ this.id = this.srcNodeRef.id; }
		if(params){
			dojo.mixin(this,params);
		}
		this.postMixInProperties();

		// generate an id for the widget if one wasn't specified
		// (be sure to do this before buildRendering() because that function might
		// expect the id to be there.
		if(!this.id){
			this.id=dijit.getUniqueId(this.declaredClass.replace(/\./g,"_"));
		}
		dijit.registry.add(this);

		this.buildRendering();
		if(this.domNode){
			this.domNode.setAttribute("widgetId", this.id);
			if(this.srcNodeRef && this.srcNodeRef.dir){
				this.domNode.dir = this.srcNodeRef.dir;
			}
		}
		this.postCreate();

		// If srcNodeRef has been processed and removed from the DOM (e.g. TemplatedWidget) then delete it to allow GC.
		if(this.srcNodeRef && !this.srcNodeRef.parentNode){
			delete this.srcNodeRef;
		}
	},

	postMixInProperties: function(){
		// summary
		//	Called after the parameters to the widget have been read-in,
		//	but before the widget template is instantiated.
		//	Especially useful to set properties that are referenced in the widget template.
	},

	buildRendering: function(){
		// summary:
		//		Construct the UI for this widget, setting this.domNode.
		//		Most widgets will mixin TemplatedWidget, which overrides this method.
		this.domNode = this.srcNodeRef;
	},

	postCreate: function(){
		// summary:
		//		Called after a widget's dom has been setup
	},

	startup: function(){
		// summary:
		//		Called after a widget's children, and other widgets on the page, have been created.
		//		Provides an opportunity to manipulate any children before they are displayed
		//		This is useful for composite widgets that need to control or layout sub-widgets
		//		Many layout widgets can use this as a wiring phase
	},

	//////////// DESTROY FUNCTIONS ////////////////////////////////

	destroyRecursive: function(/*Boolean*/ finalize){
		// summary:
		// 		Destroy this widget and it's descendants. This is the generic
		// 		"destructor" function that all widget users should call to
		// 		cleanly discard with a widget. Once a widget is destroyed, it's
		// 		removed from the manager object.
		// finalize: Boolean
		//		is this function being called part of global environment
		//		tear-down?

		this.destroyDescendants();
		this.destroy();
	},

	destroy: function(/*Boolean*/ finalize){
		// summary:
		// 		Destroy this widget, but not its descendants
		// finalize: Boolean
		//		is this function being called part of global environment
		//		tear-down?
		this.uninitialize();
		dojo.forEach(this._connects, function(array){
			dojo.forEach(array, dojo.disconnect);
		});
		dojo.forEach(this._attaches, function(name){
			delete this[name];
		});
		this.destroyRendering(finalize);
		dijit.registry.remove(this.id);
	},

	destroyRendering: function(/*Boolean*/ finalize){
		// summary:
		//		Destroys the DOM nodes associated with this widget
		// finalize: Boolean
		//		is this function being called part of global environment
		//		tear-down?

		if(this.bgIframe){
			this.bgIframe.destroy();
			delete this.bgIframe;
		}

		if(this.domNode){
			dojo._destroyElement(this.domNode);
			delete this.domNode;
		}

		if(this.srcNodeRef){
			dojo._destroyElement(this.srcNodeRef);
			delete this.srcNodeRef;
		}
	},

	destroyDescendants: function(){
		// summary:
		//		Recursively destroy the children of this widget and their
		//		descendants.

		// TODO: should I destroy in the reverse order, to go bottom up?
		dojo.forEach(this.getDescendants(), function(widget){ widget.destroy(); });
	},

	uninitialize: function(){
		// summary:
		//		stub function. Over-ride to implement custom widget tear-down
		//		behavior.
		return false;
	},

	////////////////// MISCELLANEOUS METHODS ///////////////////

	toString: function(){
		// summary:
		//		returns a string that represents the widget. When a widget is
		//		cast to a string, this method will be used to generate the
		//		output. Currently, it does not implement any sort of reversable
		//		serialization.
		return '[Widget ' + this.declaredClass + ', ' + (this.id || 'NO ID') + ']'; // String
	},

	getDescendants: function(){
		// summary:
		//	return all the descendant widgets
		var list = dojo.query('[widgetId]', this.domNode);
		return list.map(dijit.byNode);		// Array
	},

	nodesWithKeyClick : ["input", "button"],

	connect: function(
			/*Object|null*/ obj,
			/*String*/ event,
			/*String|Function*/ method){

		// summary:
		//		Connects specified obj/event to specified method of this object
		//		and registers for disconnect() on widget destroy.
		//		Special event: "ondijitclick" triggers on a click or enter-down or space-up
		//		Similar to dojo.connect() but takes three arguments rather than four.
		var handles =[];
		if(event == "ondijitclick"){
			var w = this;
			// add key based click activation for unsupported nodes.
			if(!this.nodesWithKeyClick[obj.nodeName]){
				handles.push(dojo.connect(obj, "onkeydown", this,
					function(e){
						if(e.keyCode == dojo.keys.ENTER){
							return (dojo.isString(method))?
								w[method](e) : method.call(w, e);
						}else if(e.keyCode == dojo.keys.SPACE){
							// stop space down as it causes IE to scroll
							// the browser window
							dojo.stopEvent(e);
						}
			 		}));
				handles.push(dojo.connect(obj, "onkeyup", this,
					function(e){
						if(e.keyCode == dojo.keys.SPACE){
							return dojo.isString(method) ?
								w[method](e) : method.call(w, e);
						}
			 		}));
			}
			event = "onclick";
		}
		handles.push(dojo.connect(obj, event, this, method));

		// return handles for FormElement and ComboBox
		this._connects.push(handles);
		return handles;
	},

	disconnect: function(/*Object*/ handles){
		// summary:
		//		Disconnects handle created by this.connect.
		//		Also removes handle from this widget's list of connects
		for(var i=0; i<this._connects.length; i++){
			if(this._connects[i]==handles){
				dojo.forEach(handles, dojo.disconnect);
				this._connects.splice(i, 1);
				return;
			}
		}
	},

	isLeftToRight: function(){
		// summary:
		//		Checks the DOM to for the text direction for bi-directional support
		// description:
		//		This method cannot be used during widget construction because the widget
		//		must first be connected to the DOM tree.  Parent nodes are searched for the
		//		'dir' attribute until one is found, otherwise left to right mode is assumed.
		//		See HTML spec, DIR attribute for more information.

		if(typeof this._ltr == "undefined"){
			this._ltr = (this.dir || dojo.getComputedStyle(this.domNode).direction) != "rtl";
		}
		return this._ltr; //Boolean
	}
});
<commit_msg>Revert last change to track attach points.  Didn't really make sense.  Refs #4047.<commit_after>dojo.provide("dijit._Widget");

dojo.require("dijit._base");

dojo.declare("dijit._Widget", null, {
	constructor: function(params, srcNodeRef){
		this.create(params, srcNodeRef);
	},
	// id: String
	//		a unique, opaque ID string that can be assigned by users or by the
	//		system. If the developer passes an ID which is known not to be
	//		unique, the specified ID is ignored and the system-generated ID is
	//		used instead.
	id: "",

	// lang: String
	//	Language to display this widget in (like en-us).
	//	Defaults to brower's specified preferred language (typically the language of the OS)
	lang: "",

	// dir: String
	//  Bi-directional support, as defined by the HTML DIR attribute. Either left-to-right "ltr" or right-to-left "rtl".
	dir: "",

	// srcNodeRef: DomNode
	//		pointer to original dom node
	srcNodeRef: null,

	// domNode DomNode:
	//		this is our visible representation of the widget! Other DOM
	//		Nodes may by assigned to other properties, usually through the
	//		template system's dojoAttachPonit syntax, but the domNode
	//		property is the canonical "top level" node in widget UI.
	domNode: null,

	//////////// INITIALIZATION METHODS ///////////////////////////////////////

	create: function(params, srcNodeRef) {
		// summary:
		//		To understand the process by which widgets are instantiated, it
		//		is critical to understand what other methods create calls and
		//		which of them you'll want to override. Of course, adventurous
		//		developers could override create entirely, but this should
		//		only be done as a last resort.
		//
		//		Below is a list of the methods that are called, in the order
		//		they are fired, along with notes about what they do and if/when
		//		you should over-ride them in your widget:
		//
		//			postMixInProperties:
		//				a stub function that you can over-ride to modify
		//				variables that may have been naively assigned by
		//				mixInProperties
		//			# widget is added to manager object here
		//			buildRendering
		//				Subclasses use this method to handle all UI initialization
		//				Sets this.domNode.  Templated widgets do this automatically
		//				and otherwise it just uses the source dom node.
		//			postCreate
		//				a stub function that you can over-ride to modify take
		//				actions once the widget has been placed in the UI

		// store pointer to original dom tree
		this.srcNodeRef = dojo.byId(srcNodeRef);

		// For garbage collection.  An array of handles returned by Widget.connect()
		// Each handle returned from Widget.connect() is an array of handles from dojo.connect()
		this._connects=[];

		// _attaches: String[]
		// 		names of all our dojoAttachPoint variables
		this._attaches=[];

		//mixin our passed parameters
		if(this.srcNodeRef && (typeof this.srcNodeRef.id == "string")){ this.id = this.srcNodeRef.id; }
		if(params){
			dojo.mixin(this,params);
		}
		this.postMixInProperties();

		// generate an id for the widget if one wasn't specified
		// (be sure to do this before buildRendering() because that function might
		// expect the id to be there.
		if(!this.id){
			this.id=dijit.getUniqueId(this.declaredClass.replace(/\./g,"_"));
		}
		dijit.registry.add(this);

		this.buildRendering();
		if(this.domNode){
			this.domNode.setAttribute("widgetId", this.id);
			if(this.srcNodeRef && this.srcNodeRef.dir){
				this.domNode.dir = this.srcNodeRef.dir;
			}
		}
		this.postCreate();

		// If srcNodeRef has been processed and removed from the DOM (e.g. TemplatedWidget) then delete it to allow GC.
		if(this.srcNodeRef && !this.srcNodeRef.parentNode){
			delete this.srcNodeRef;
		}
	},

	postMixInProperties: function(){
		// summary
		//	Called after the parameters to the widget have been read-in,
		//	but before the widget template is instantiated.
		//	Especially useful to set properties that are referenced in the widget template.
	},

	buildRendering: function(){
		// summary:
		//		Construct the UI for this widget, setting this.domNode.
		//		Most widgets will mixin TemplatedWidget, which overrides this method.
		this.domNode = this.srcNodeRef;
	},

	postCreate: function(){
		// summary:
		//		Called after a widget's dom has been setup
	},

	startup: function(){
		// summary:
		//		Called after a widget's children, and other widgets on the page, have been created.
		//		Provides an opportunity to manipulate any children before they are displayed
		//		This is useful for composite widgets that need to control or layout sub-widgets
		//		Many layout widgets can use this as a wiring phase
	},

	//////////// DESTROY FUNCTIONS ////////////////////////////////

	destroyRecursive: function(/*Boolean*/ finalize){
		// summary:
		// 		Destroy this widget and it's descendants. This is the generic
		// 		"destructor" function that all widget users should call to
		// 		cleanly discard with a widget. Once a widget is destroyed, it's
		// 		removed from the manager object.
		// finalize: Boolean
		//		is this function being called part of global environment
		//		tear-down?

		this.destroyDescendants();
		this.destroy();
	},

	destroy: function(/*Boolean*/ finalize){
		// summary:
		// 		Destroy this widget, but not its descendants
		// finalize: Boolean
		//		is this function being called part of global environment
		//		tear-down?
		this.uninitialize();
		dojo.forEach(this._connects, function(array){
			dojo.forEach(array, dojo.disconnect);
		});
		this.destroyRendering(finalize);
		dijit.registry.remove(this.id);
	},

	destroyRendering: function(/*Boolean*/ finalize){
		// summary:
		//		Destroys the DOM nodes associated with this widget
		// finalize: Boolean
		//		is this function being called part of global environment
		//		tear-down?

		if(this.bgIframe){
			this.bgIframe.destroy();
			delete this.bgIframe;
		}

		if(this.domNode){
			dojo._destroyElement(this.domNode);
			delete this.domNode;
		}

		if(this.srcNodeRef){
			dojo._destroyElement(this.srcNodeRef);
			delete this.srcNodeRef;
		}
	},

	destroyDescendants: function(){
		// summary:
		//		Recursively destroy the children of this widget and their
		//		descendants.

		// TODO: should I destroy in the reverse order, to go bottom up?
		dojo.forEach(this.getDescendants(), function(widget){ widget.destroy(); });
	},

	uninitialize: function(){
		// summary:
		//		stub function. Over-ride to implement custom widget tear-down
		//		behavior.
		return false;
	},

	////////////////// MISCELLANEOUS METHODS ///////////////////

	toString: function(){
		// summary:
		//		returns a string that represents the widget. When a widget is
		//		cast to a string, this method will be used to generate the
		//		output. Currently, it does not implement any sort of reversable
		//		serialization.
		return '[Widget ' + this.declaredClass + ', ' + (this.id || 'NO ID') + ']'; // String
	},

	getDescendants: function(){
		// summary:
		//	return all the descendant widgets
		var list = dojo.query('[widgetId]', this.domNode);
		return list.map(dijit.byNode);		// Array
	},

	nodesWithKeyClick : ["input", "button"],

	connect: function(
			/*Object|null*/ obj,
			/*String*/ event,
			/*String|Function*/ method){

		// summary:
		//		Connects specified obj/event to specified method of this object
		//		and registers for disconnect() on widget destroy.
		//		Special event: "ondijitclick" triggers on a click or enter-down or space-up
		//		Similar to dojo.connect() but takes three arguments rather than four.
		var handles =[];
		if(event == "ondijitclick"){
			var w = this;
			// add key based click activation for unsupported nodes.
			if(!this.nodesWithKeyClick[obj.nodeName]){
				handles.push(dojo.connect(obj, "onkeydown", this,
					function(e){
						if(e.keyCode == dojo.keys.ENTER){
							return (dojo.isString(method))?
								w[method](e) : method.call(w, e);
						}else if(e.keyCode == dojo.keys.SPACE){
							// stop space down as it causes IE to scroll
							// the browser window
							dojo.stopEvent(e);
						}
			 		}));
				handles.push(dojo.connect(obj, "onkeyup", this,
					function(e){
						if(e.keyCode == dojo.keys.SPACE){
							return dojo.isString(method) ?
								w[method](e) : method.call(w, e);
						}
			 		}));
			}
			event = "onclick";
		}
		handles.push(dojo.connect(obj, event, this, method));

		// return handles for FormElement and ComboBox
		this._connects.push(handles);
		return handles;
	},

	disconnect: function(/*Object*/ handles){
		// summary:
		//		Disconnects handle created by this.connect.
		//		Also removes handle from this widget's list of connects
		for(var i=0; i<this._connects.length; i++){
			if(this._connects[i]==handles){
				dojo.forEach(handles, dojo.disconnect);
				this._connects.splice(i, 1);
				return;
			}
		}
	},

	isLeftToRight: function(){
		// summary:
		//		Checks the DOM to for the text direction for bi-directional support
		// description:
		//		This method cannot be used during widget construction because the widget
		//		must first be connected to the DOM tree.  Parent nodes are searched for the
		//		'dir' attribute until one is found, otherwise left to right mode is assumed.
		//		See HTML spec, DIR attribute for more information.

		if(typeof this._ltr == "undefined"){
			this._ltr = (this.dir || dojo.getComputedStyle(this.domNode).direction) != "rtl";
		}
		return this._ltr; //Boolean
	}
});
<|endoftext|>