Example #1
0
BCD.addEvent('draw_qr', function (ele, option, data) {
  m_util.load('./source/lib/qrcode.js', function () {
    let qrcodedraw = new QRCodeLib.QRCodeDraw();
    qrcodedraw.draw(ele[0], option.url, function (error, canvas) {
      if (error) {
        return console.log('Error =( ', error);
      }
    });
  });
});
Example #2
0
 initPage: function(key, next) {
     m_loading.show();
     var page = this;
     switch (key) {
         /**书城*/
         case 'qrcode':
             require.ensure(['page/tool/qrcode'], function(require) {
                 next(require('page/tool/qrcode')(page, key));
             });
             break;
         case 'edit':
             require.ensure(['page/tool/edit'], function(require) {
                 next(require('page/tool/edit')(page, key));
             });
             break;
         case 'link':
             require.ensure(['page/tool/link'], function(require) {
                 next(require('page/tool/link')(page, key));
             });
             break;
         case 'benchmark':
             require.ensure(['page/tool/benchmark_link'], function(require) {
                 next(require('page/tool/benchmark_link')(page, key));
             });
             // require.ensure(['page/tool/benchmark'], function(require) {
             //     next(require('page/tool/benchmark')(page, key));
             // });
             break;
         case 'console':
             page.setView(o_navigator({
               title: '命令行'
             }));
             next();
             m_util.load('./source/lib/eruda.min.js', function(){
               // setTimeout(function(){
               //   vConsole.show();
               // }, 100);
               eruda.init();
             });
             break;
         default:
             BCD.replaceHash('#!/link');
             next(-1);
             break;
     }
 }
Example #3
0
m_util.load(["./source/lib/codemirror/lib/codemirror.css",
    "./source/lib/codemirror/addon/hint/show-hint.css",
    "./source/lib/codemirror/lib/codemirror.js",
    "./source/lib/codemirror/addon/hint/show-hint.js",
    "./source/lib/codemirror/addon/hint/xml-hint.js",
    "./source/lib/codemirror/addon/hint/html-hint.js",
    "./source/lib/codemirror/mode/xml/xml.js",
    "./source/lib/codemirror/mode/javascript/javascript.js",
    "./source/lib/codemirror/mode/css/css.js",
    "./source/lib/codemirror/mode/htmlmixed/htmlmixed.js",
    "./source/lib/zeroclipboard/ZeroClipboard.js"
  ],
  function () {
    ZeroClipboard.config({
      swfPath: "./source/lib/zeroclipboard/ZeroClipboard.swf",
      moviePath: "./source/lib/zeroclipboard/ZeroClipboard.swf"
    });
    var clip = new ZeroClipboard(domMod[0]);

    clip.on("ready", function () {
      this.on('copy', function (event) {
        refreshMod();
        event.clipboardData.setData('text/plain', domDis.val());
      });
      this.on("aftercopy", function (event) {
        m_util.toast('已复制到粘贴板');
      });
    });


    ZeroClipboard.setData("text/plain", 'txt');
    view.setView({
      end: function () {
        if (!editor) {
          editor = CodeMirror(domCode[0], {
            mode: "text/html",
            styleActiveLine: true,
            lineNumbers: true,
            lineWrapping: true,
            autofocus: true,
            extraKeys: {
              "Ctrl-1": "autocomplete"
            }
          });
        }
      }
    });
    view.reset();
  });