aboutsummaryrefslogtreecommitdiffstats
path: root/uuid.js
blob: 24b84d1996829769d25ed860f167bd2d1eff269b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// PLUGIN_INFO//{{{
var PLUGIN_INFO = xml`
<VimperatorPlugin>
    <name>{NAME}</name>
    <description>UUID generator</description>
    <author mail="konbu.komuro@gmail.com" homepage="http://d.hatena.ne.jp/hogelog/">hogelog</author>
    <version>0.1</version>
    <minVersion>2.0pre</minVersion>
    <maxVersion>2.0pre</maxVersion>
    <updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/uuid.js</updateURL>
    <detail><![CDATA[

== COMMANDS ==
uuid:
    generate and copy UUID

== THANKS ==
http://moz-addon.g.hatena.ne.jp/ZIGOROu/20080417/1208413079
]]></detail>
</VimperatorPlugin>`;
//}}}

(function() {
    const Ci = Components.interfaces;
    services.add("uuid", "@mozilla.org/uuid-generator;1", Ci.nsIUUIDGenerator);
    const UUID = services.get("uuid");

    commands.add(['uuid'], 'generate and copy UUID',
        function(args)
        {
            let uuid = UUID.generateUUID().number;
            util.copyToClipboard(uuid);
            liberator.echo("generate "+uuid);
        },
        {
            argCount: '0',
        });
})();
// vim: fdm=marker sw=4 ts=4 et:
168'>168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
/* NEW BSD LICENSE {{{
Copyright (c) 2009-2010, anekos.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
    3. The names of the authors may not be used to endorse or promote products
       derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.


###################################################################################
# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license       #
# に参考になる日本語訳がありますが、有効なのは上記英文となります。                #
###################################################################################

}}} */

// PLUGIN_INFO {{{
let PLUGIN_INFO =
<VimperatorPlugin>
  <name>No Reading</name>
  <name lang="ja">No Reading</name>
  <description>No reading!</description>
  <description lang="ja">からデータを転送していますなどの表示を消す(またはecho)</description>
  <version>1.2.2</version>
  <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author>
  <license>new BSD License (Please read the source code comments of this plugin)</license>
  <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license>
  <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/no-reading.js</updateURL>
  <minVersion>2.2</minVersion>
  <maxVersion>2.3pre</maxVersion>
  <require type="plugin">_libly.js</require>
  <detail><![CDATA[
    let g:no_reading_do_echo = 1
    let g:no_reading_on_statusline = 1
    let g:no_reading_statusline_limit = 1
  ]]></detail>
  <detail lang="ja"><![CDATA[
    let g:no_reading_do_echo = 1
    let g:no_reading_on_statusline = 1
    let g:no_reading_statusline_limit = 1
  ]]></detail>
</VimperatorPlugin>;
// }}}
// INFO {{{
let INFO =
<>
  <plugin name="No-Reading" version="1.2.1"
          href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/no-reading.js"
          summary="No Reading"
          lang="en-US"
          xmlns="http://vimperator.org/namespaces/liberator">
    <author email="anekos@snca.net">anekos</author>
    <license>New BSD License</license>
    <project name="Vimperator" minVersion="2.3"/>
    <p>
      Remove or move some messages for statusline.
    </p>
    <item>
      <tags>g:no_reading_do_echo</tags>
      <spec>let g:no_reading_do_echo</spec>
      <spec>liberator.globalVariables.no_reading_do_echo</spec>
      <description>
        <p>substitute by echo</p>
      </description>
    </item>
    <item>
      <tags>g:no_reading_on_statusline</tags>
      <spec>let g:no_reading_on_statusline</spec>
      <spec>liberator.globalVariables.no_reading_on_statusline</spec>
      <description>
        <p>Move displays into statusline.</p>
      </description>
    </item>
  </plugin>
  <plugin name="No-Reading" version="1.2.1"
          href="http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/no-reading.js"
          summary="~からデータを転送していますなどの表示を消したり移動したり"
          lang="ja"
          xmlns="http://vimperator.org/namespaces/liberator">
    <author email="anekos@snca.net">anekos</author>
    <license>New BSD License</license>
    <project name="Vimperator" minVersion="2.3"/>
    <p>
      からデータを転送していますなどの表示を消したりステータスラインに移動したりecho したり
    </p>
    <item>
      <tags>g:no_reading_do_echo</tags>
      <spec>let g:no_reading_do_echo</spec>
      <spec>liberator.globalVariables.no_reading_do_echo</spec>
      <description>
        <p>echo で代用</p>
      </description>
    </item>
    <item>
      <tags>g:no_reading_on_statusline</tags>
      <spec>let g:no_reading_on_statusline</spec>
      <spec>liberator.globalVariables.no_reading_on_statusline</spec>
      <description>
        <p>表示をステータスラインに移動</p>
      </description>
    </item>
  </plugin>
</>;
// }}}

(function () {

    let eraseTimerHandle;
    let label;
    let (
      sl = document.getElementById('liberator-statusline'),
      slfu = document.getElementById('liberator-statusline-field-inputbuffer')
    ) {
      label = document.createElement('label');
      label.setAttribute('id', 'vimperator-plugin-no-reading-label');
      sl.insertBefore(label, slfu);
    }

  let $ = {
    get doEcho ()
      liberator.globalVariables.no_reading_do_echo,

    get onStatusLine ()
      !!liberator.globalVariables.no_reading_on_statusline,

    get statuslineLimit ()
      liberator.globalVariables.no_reading_statusline_limit
  };

  let (doErase = true)
    liberator.plugins.libly.$U.around(
      statusline,
      'updateUrl',
      function (next, args) {
        function setLabel (status) {
          label.tooltipText = status;
          label.value = status;
        }

        function updateStatus (status) {
          doErase = true;
          if ($.onStatusLine) {
            eraseTimerHandle && clearTimeout(eraseTimerHandle);
            if ($.statuslineLimit) {
              eraseTimerHandle =
                setTimeout(
                  function () (eraseTimerHandle = null, setLabel('')),
                  $.statuslineLimit
                );
            }
            setLabel(status);
          } else {
            if ($.doEcho)
              liberator.echo(status, commandline.FORCE_SINGLELINE)
          }
        }

        function showURL () {
          if ($.onStatusLine) {
            setLabel('');
          } else {
            if (doErase && $.doEcho)
              liberator.echo('', commandline.FORCE_SINGLELINE)
          }
          doErase = false;
          return next();
        }

        let [url] = args;
        return (url ? updateStatus : showURL)(url);
      }
    );

})();

// vim:sw=2 ts=2 et si fdm=marker: