WazeWrap Beta

A base library for WME script writers

当前为 2016-11-22 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/24870/159284/WazeWrap%20Beta.js

  1. // ==UserScript==
  2. // @name WazeWrap Beta
  3. // @namespace https://gf.qytechs.cn/users/30701-justins83-waze
  4. // @version 0.1.8c
  5. // @description A base library for WME script writers
  6. // @author JustinS83/MapOMatic
  7. // @include https://beta.waze.com/*editor/*
  8. // @include https://www.waze.com/*editor/*
  9. // @exclude https://www.waze.com/*user/editor/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. /* global W */
  14. /* global WazeWrap */
  15. var WazeWrap = {};
  16.  
  17. (function() {
  18.  
  19. function bootstrap(tries) {
  20. tries = tries || 1;
  21. if (W &&
  22. W.map &&
  23. W.model &&
  24. W.loginManager &&
  25. $) {
  26. init();
  27. } else if (tries < 1000) {
  28. setTimeout(function () { bootstrap(tries++); }, 200);
  29. } else {
  30. console.log('WazeWrap failed to load');
  31. }
  32. }
  33.  
  34. bootstrap();
  35.  
  36. function init(){
  37. console.log("WazeWrap initializing...");
  38. var oldLib = window.WazeWrap;
  39.  
  40. var root = this;
  41.  
  42. WazeWrap.Version = "0.1.8c";
  43. WazeWrap.isBetaEditor = /beta/.test(location.href);
  44.  
  45. SetUpRequire();
  46.  
  47. WazeWrap.test = "test";
  48. WazeWrap.Geometry = new Geometry;
  49. WazeWrap.Model = new Model;
  50. WazeWrap.Interface = new Interface;
  51. WazeWrap.User = new User;
  52. WazeWrap.Util = new Util;
  53. root.WazeWrap = WazeWrap;
  54.  
  55. console.log('WazeWrap Loaded');
  56. };
  57.  
  58.  
  59. function SetUpRequire(){
  60. if(this.isBetaEditor || typeof window.require !== "undefined")
  61. return;
  62.  
  63. console.log("Setting d2's require fix...");
  64. // setup one global var and put all in
  65. var WMEAPI = {};
  66.  
  67. // detect URL of WME source code
  68. WMEAPI.scripts = document.getElementsByTagName('script');
  69. WMEAPI.url=null;
  70. for (i=0;i<WMEAPI.scripts.length;i++){
  71. if (WMEAPI.scripts[i].src.indexOf('/assets-editor/js/app')!=-1)
  72. {
  73. WMEAPI.url=WMEAPI.scripts[i].src;
  74. break;
  75. }
  76. }
  77. if (WMEAPI.url==null)
  78. throw new Error("WME Hack: can't detect WME main JS");
  79.  
  80.  
  81. // setup a fake require and require.define
  82. WMEAPI.require=function (e) {
  83. if (WMEAPI.require.define.modules.hasOwnProperty(e))
  84. return WMEAPI.require.define.modules[e];
  85. else
  86. console.error('Require failed on ' + e, WMEAPI.require.define.modules);
  87. return null;
  88. };
  89.  
  90. WMEAPI.require.define=function (m) {
  91. if (WMEAPI.require.define.hasOwnProperty('modules')==false)
  92. WMEAPI.require.define.modules={};
  93. for (var p in m){
  94. WMEAPI.require.define.modules[p]=m[p];
  95. }
  96. };
  97.  
  98. // save the original webpackJsonp function
  99. WMEAPI.tmp = window.webpackJsonp;
  100.  
  101. // taken from WME code: this function is a wrapper that setup the API and may call recursively other functions
  102. WMEAPI.t = function (n) {
  103. if (WMEAPI.s[n]) return WMEAPI.s[n].exports;
  104. var r = WMEAPI.s[n] = {
  105. exports: {},
  106. id: n,
  107. loaded: !1
  108. };
  109. return WMEAPI.e[n].call(r.exports, r, r.exports, WMEAPI.t), r.loaded = !0, r.exports;
  110. };
  111.  
  112. // e is a copy of all WME funcs because function t need to access to this list
  113. WMEAPI.e=[];
  114.  
  115. // the patch
  116. window.webpackJsonp = function(a, i) {
  117. // our API but we will use it only to build the require stuffs
  118. var api={};
  119. // taken from WME code. a is [1], so...
  120. for (var o, d, u = 0, l = []; u < a.length; u++) d = a[u], WMEAPI.r[d] && l.push.apply(l, WMEAPI.r[d]), WMEAPI.r[d] = 0;
  121. var unknownCount=0;
  122. var classname, funcStr;
  123. // copy i in e and keep a link from classname to index in e
  124. for (o in i){
  125. WMEAPI.e[o] = i[o];
  126. funcStr = i[o].toString();
  127. classname = funcStr.match(/CLASS_NAME:\"([^\"]*)\"/);
  128. if (classname){
  129. // keep the link.
  130. api[classname[1].replace(/\./g,'/').replace(/^W\//, 'Waze/')]={index: o, func: WMEAPI.e[o]};
  131. }
  132. else{
  133. api['Waze/Unknown/' + unknownCount]={index: o, func: WMEAPI.e[o]};
  134. unknownCount++;
  135. }
  136. }
  137. // taken from WME code: it calls the original webpackJsonp and do something else, but I don't really know what.
  138. // removed the call to the original webpackJsonp: still works...
  139. //for (tmp && tmp(a, i); l.length;) l.shift().call(null, t);
  140. for (; l.length;) l.shift().call(null, WMEAPI.t);
  141. WMEAPI.s[0] = 0;
  142. // run the first func of WME. This first func will call recusrsively all funcs needed to setup the API.
  143. // After this call, s will contain all instanciables classes.
  144. //var ret = WMEAPI.t(0);
  145. // now, build the requires thanks to the link we've built in var api.
  146. var module={};
  147. var apiFuncName;
  148. unknownCount=0;
  149. for (o in i){
  150. funcStr = i[o].toString();
  151. classname = funcStr.match(/CLASS_NAME:\"([^\"]*)\"/);
  152. if (classname){
  153. module={};
  154. apiFuncName = classname[1].replace(/\./g,'/').replace(/^W\//, 'Waze/');
  155. module[apiFuncName]=WMEAPI.t(api[apiFuncName].index);
  156. WMEAPI.require.define(module);
  157. }
  158. else{
  159. var matches = funcStr.match(/SEGMENT:"segment",/);
  160. if (matches){
  161. module={};
  162. apiFuncName='Waze/Model/ObjectType';
  163. module[apiFuncName]=WMEAPI.t(api['Waze/Unknown/' + unknownCount].index);
  164. WMEAPI.require.define(module);
  165. }
  166. unknownCount++;
  167. }
  168. }
  169.  
  170. // restore the original func
  171. window.webpackJsonp=WMEAPI.tmp;
  172.  
  173. // set the require public if needed
  174. // if so: others scripts must wait for the window.require to be available before using it.
  175. window.require = WMEAPI.require;
  176. // all available functions are in WMEAPI.require.define.modules
  177. // console.debug this variable to read it:
  178. // console.debug('Modules: ', WMEAPI.require.define.modules);
  179. // run your script here:
  180. // setTimeout(yourscript);
  181. // again taken from WME code. Not sure about what it does.
  182. //if (i[0]) return ret;
  183. };
  184.  
  185. // some kind of global vars and init
  186. WMEAPI.s = {};
  187. WMEAPI.r = {
  188. 0: 0
  189. };
  190.  
  191. // hacking finished
  192.  
  193. // load again WME through our patched func
  194. WMEAPI.WMEHACK_Injected_script = document.createElement("script");
  195. WMEAPI.WMEHACK_Injected_script.setAttribute("type", "application/javascript");
  196. WMEAPI.WMEHACK_Injected_script.src = WMEAPI.url;
  197. document.body.appendChild(WMEAPI.WMEHACK_Injected_script);
  198. console.log("d2 fix complete");
  199. }
  200.  
  201. function Geometry(){
  202. //var geometry = WazeWrap.Geometry;
  203.  
  204. //Converts to "normal" GPS coordinates
  205. this.ConvertTo4326 = function (long, lat){
  206. var projI=new OpenLayers.Projection("EPSG:900913");
  207. var projE=new OpenLayers.Projection("EPSG:4326");
  208. return (new OpenLayers.LonLat(long, lat)).transform(projI,projE);
  209. };
  210. this.ConvertTo900913 = function (long, lat){
  211. var projI=new OpenLayers.Projection("EPSG:900913");
  212. var projE=new OpenLayers.Projection("EPSG:4326");
  213. return (new OpenLayers.LonLat(long, lat)).transform(projE,projI);
  214. };
  215.  
  216. //Converts the Longitudinal offset to an offset in 4326 gps coordinates
  217. this.CalculateLongOffsetGPS = function(longMetersOffset, long, lat)
  218. {
  219. var R= 6378137; //Earth's radius
  220. var dLon = longMetersOffset / (R * Math.cos(Math.PI * lat / 180)); //offset in radians
  221. var lon0 = dLon * (180 / Math.PI); //offset degrees
  222.  
  223. return lon0;
  224. };
  225.  
  226. //Converts the Latitudinal offset to an offset in 4326 gps coordinates
  227. this.CalculateLatOffsetGPS = function(latMetersOffset, lat)
  228. {
  229. var R= 6378137; //Earth's radius
  230. var dLat = latMetersOffset/R;
  231. var lat0 = dLat * (180 /Math.PI); //offset degrees
  232.  
  233. return lat0;
  234. };
  235. this.isLonLatInMapExtent = function (lonLat) {
  236. 'use strict';
  237. return lonLat && W.map.getExtent().containsLonLat(lonLat);
  238. };
  239. this.isGeometryInMapExtent = function (geometry) {
  240. 'use strict';
  241. return geometry && geometry.getBounds &&
  242. W.map.getExtent().intersectsBounds(geometry.getBounds());
  243. };
  244. };
  245.  
  246. function Model(){
  247. //var model = WazeWrap.Model;
  248.  
  249. this.getPrimaryStreetID = function(segmentID){
  250. return W.model.segments.get(segmentID).attributes.primaryStreetID;
  251. };
  252.  
  253. this.getStreetName = function(primaryStreetID){
  254. return W.model.streets.get(PrimaryStreetID).name;
  255. };
  256.  
  257. this.getCityID = function(primaryStreetID){
  258. return W.model.streets.get(primaryStreetID).cityID;
  259. };
  260.  
  261. this.getCityName = function(primaryStreetID){
  262. return W.model.cities.get(this.getCityID(primaryStreetID)).attributes.Name;
  263. };
  264.  
  265. this.getStateName = function(primaryStreetID){
  266. return W.model.states.get(getStateID(primaryStreetID)).Name;
  267. };
  268.  
  269. this.getStateID = function(primaryStreetID){
  270. return W.model.cities.get(primaryStreetID).attributes.stateID;
  271. };
  272.  
  273. this.getCountryID = function(primaryStreetID){
  274. return W.model.cities.get(this.getCityID(primaryStreetID)).attributes.CountryID;
  275. };
  276.  
  277. this.getCountryName = function(primaryStreetID){
  278. return W.model.countries.get(getCountryID(primaryStreetID)).name;
  279. };
  280.  
  281. this.getCityNameFromSegmentObj = function(segObj){
  282. return this.getCityName(segObj.attributes.primaryStreetID);
  283. };
  284.  
  285. this.getStateNameFromSegmentObj = function(segObj){
  286. return this.getStateName(segObj.attributes.primaryStreetID);
  287. };
  288.  
  289. //returns an array of segmentIDs for all segments that are part of the same roundabout as the passed segment
  290. this.getAllRoundaboutSegmentsFromObj = function(segObj){
  291. if(segObj.model.attributes.junctionID === null)
  292. return null;
  293.  
  294. return W.model.junctions.objects[segObj.model.attributes.junctionID].segIDs;
  295. };
  296.  
  297. this.getAllRoundaboutJunctionNodesFromObj = function(segObj){
  298. var RASegs = this.getAllRoundaboutSegmentsFromObj(segObj);
  299. var RAJunctionNodes = [];
  300. for(i=0; i< RASegs.length; i++){
  301. RAJunctionNodes.push(W.model.nodes.objects[W.model.segments.get(RASegs[i]).attributes.toNodeID]);
  302.  
  303. }
  304. return RAJunctionNodes;
  305. };
  306.  
  307. this.isRoundaboutSegmentID = function(segmentID){
  308. if(W.model.segments.get(segmentID).attributes.junctionID === null)
  309. return false;
  310. else
  311. return true;
  312. };
  313.  
  314. this.isRoundaboutSegmentObj = function(segObj){
  315. if(segObj.model.attributes.junctionID === null)
  316. return false;
  317. else
  318. return true;
  319. };
  320.  
  321. /**
  322. * Defers execution of a callback function until the WME map and data
  323. * model are ready. Call this function before calling a function that
  324. * causes a map and model reload, such as W.map.moveTo(). After the
  325. * move is completed the callback function will be executed.
  326. * @function WazeWrap.Model.onModelReady
  327. * @param {Function} callback The callback function to be executed.
  328. * @param {Boolean} now Whether or not to call the callback now if the
  329. * model is currently ready.
  330. * @param {Object} context The context in which to call the callback.
  331. */
  332. this.onModelReady = function (callback, now, context) {
  333. var deferModelReady = function () {
  334. return $.Deferred(function (dfd) {
  335. var resolve = function () {
  336. dfd.resolve();
  337. W.model.events.unregister('mergeend', null, resolve);
  338. };
  339. W.model.events.register('mergeend', null, resolve);
  340. }).promise();
  341. };
  342. var deferMapReady = function () {
  343. return $.Deferred(function (dfd) {
  344. var resolve = function () {
  345. dfd.resolve();
  346. W.vent.off('operationDone', resolve);
  347. };
  348. W.vent.on('operationDone', resolve);
  349. }).promise();
  350. };
  351.  
  352. if (typeof callback === 'function') {
  353. context = context || callback;
  354. if (now && WazeWrap.Util.mapReady() && WazeWrap.Util.modelReady()) {
  355. callback.call(context);
  356. } else {
  357. $.when(deferMapReady() && deferModelReady()).
  358. then(function () {
  359. callback.call(context);
  360. });
  361. }
  362. }
  363. };
  364. };
  365. function User(){
  366. this.Rank = function(){
  367. return W.loginManager.user.normalizedLevel;
  368. };
  369.  
  370. this.Username = function(){
  371. return W.loginManager.user.userName;
  372. };
  373.  
  374. this.isCM = function(){
  375. if(W.loginManager.user.editableCountryIDs.length > 0)
  376. return true;
  377. else
  378. return false;
  379. };
  380. this.isAM = function(){
  381. return W.loginManager.user.isAreaManager;
  382. };
  383. };
  384. function Util(){
  385. /**
  386. * Function to defer function execution until an element is present on
  387. * the page.
  388. * @function WazeWrap.Util.waitForElement
  389. * @param {String} selector The CSS selector string or a jQuery object
  390. * to find before executing the callback.
  391. * @param {Function} callback The function to call when the page
  392. * element is detected.
  393. * @param {Object} [context] The context in which to call the callback.
  394. */
  395. this.waitForElement = function (selector, callback, context) {
  396. var jqObj;
  397.  
  398. if (!selector || typeof callback !== 'function') {
  399. return;
  400. }
  401.  
  402. jqObj = typeof selector === 'string' ?
  403. $(selector) : selector instanceof $ ? selector : null;
  404.  
  405. if (!jqObj.size()) {
  406. window.requestAnimationFrame(function () {
  407. WazeWrap.Util.waitForElement(selector, callback, context);
  408. });
  409. } else {
  410. callback.call(context || callback);
  411. }
  412. };
  413.  
  414. /**
  415. * Function to track the ready state of the map.
  416. * @function WazeWrap.Util.mapReady
  417. * @return {Boolean} Whether or not a map operation is pending or
  418. * undefined if the function has not yet seen a map ready event fired.
  419. */
  420. this.mapReady = function () {
  421. var mapReady = true;
  422. W.vent.on('operationPending', function () {
  423. mapReady = false;
  424. });
  425. W.vent.on('operationDone', function () {
  426. mapReady = true;
  427. });
  428. return function () {
  429. return mapReady;
  430. };
  431. } ();
  432.  
  433. /**
  434. * Function to track the ready state of the model.
  435. * @function WazeWrap.Util.modelReady
  436. * @return {Boolean} Whether or not the model has loaded objects or
  437. * undefined if the function has not yet seen a model ready event fired.
  438. */
  439. this.modelReady = function () {
  440. var modelReady = true;
  441. W.model.events.register('mergestart', null, function () {
  442. modelReady = false;
  443. });
  444. W.model.events.register('mergeend', null, function () {
  445. modelReady = true;
  446. });
  447. return function () {
  448. return modelReady;
  449. };
  450. } ();
  451. };
  452.  
  453. function Interface() {
  454. /**
  455. * Generates id for message bars.
  456. * @private
  457. */
  458. var getNextID = function () {
  459. var id = 1;
  460. return function () {
  461. return id++;
  462. };
  463. } ();
  464. this.Shortcut = OL.Class(this, /** @lends WazeWrap.Interface.Shortcut.prototype */ {
  465. name: null,
  466. group: null,
  467. shortcut: {},
  468. callback: null,
  469. scope: null,
  470. groupExists: false,
  471. actionExists: false,
  472. eventExists: false,
  473. defaults: {
  474. group: 'default'
  475. },
  476. /**
  477. * Creates a new {WazeWrap.Interface.Shortcut}.
  478. * @class
  479. * @name WazeWrap.Interface.Shortcut
  480. * @param name {String} The name of the shortcut.
  481. * @param group {String} The name of the shortcut group.
  482. * @param shortcut {String} The shortcut key(s). The shortcut
  483. * should be of the form 'i' where i is the keyboard shortuct or
  484. * include modifier keys such as 'CSA+i', where C = the control
  485. * key, S = the shift key, A = the alt key, and i = the desired
  486. * keyboard shortcut. The modifier keys are optional.
  487. * @param callback {Function} The function to be called by the
  488. * shortcut.
  489. * @param scope {Object} The object to be used as this by the
  490. * callback.
  491. * @return {WazeWrap.Interface.Shortcut} The new shortcut object.
  492. * @example //Creates new shortcut and adds it to the map.
  493. * shortcut = new WazeWrap.Interface.Shortcut('myName', 'myGroup', 'C+p', callbackFunc, null).add();
  494. */
  495. initialize: function (name, group, shortcut, callback, scope) {
  496. if ('string' === typeof name && name.length > 0 &&
  497. 'string' === typeof shortcut && shortcut.length > 0 &&
  498. 'function' === typeof callback) {
  499. this.name = name;
  500. this.group = group || this.defaults.group;
  501. this.callback = callback;
  502. this.shortcut[shortcut] = name;
  503. if ('object' !== typeof scope) {
  504. this.scope = null;
  505. } else {
  506. this.scope = scope;
  507. }
  508. return this;
  509. }
  510. },
  511. /**
  512. * Determines if the shortcut's group already exists.
  513. * @private
  514. */
  515. doesGroupExist: function () {
  516. this.groupExists = 'undefined' !== typeof W.accelerators.Groups[this.group] &&
  517. undefined !== typeof W.accelerators.Groups[this.group].members &&
  518. W.accelerators.Groups[this.group].length > 0;
  519. return this.groupExists;
  520. },
  521. /**
  522. * Determines if the shortcut's action already exists.
  523. * @private
  524. */
  525. doesActionExist: function () {
  526. this.actionExists = 'undefined' !== typeof W.accelerators.Actions[this.name];
  527. return this.actionExists;
  528. },
  529. /**
  530. * Determines if the shortcut's event already exists.
  531. * @private
  532. */
  533. doesEventExist: function () {
  534. this.eventExists = 'undefined' !== typeof W.accelerators.events.listeners[this.name] &&
  535. W.accelerators.events.listeners[this.name].length > 0 &&
  536. this.callback === W.accelerators.events.listeners[this.name][0].func &&
  537. this.scope === W.accelerators.events.listeners[this.name][0].obj;
  538. return this.eventExists;
  539. },
  540. /**
  541. * Creates the shortcut's group.
  542. * @private
  543. */
  544. createGroup: function () {
  545. W.accelerators.Groups[this.group] = [];
  546. W.accelerators.Groups[this.group].members = [];
  547. },
  548. /**
  549. * Registers the shortcut's action.
  550. * @private
  551. */
  552. addAction: function () {
  553. W.accelerators.addAction(this.name, { group: this.group });
  554. },
  555. /**
  556. * Registers the shortcut's event.
  557. * @private
  558. */
  559. addEvent: function () {
  560. W.accelerators.events.register(this.name, this.scope, this.callback);
  561. },
  562. /**
  563. * Registers the shortcut's keyboard shortcut.
  564. * @private
  565. */
  566. registerShortcut: function () {
  567. W.accelerators._registerShortcuts(this.shortcut);
  568. },
  569. /**
  570. * Adds the keyboard shortcut to the map.
  571. * @return {WazeWrap.Interface.Shortcut} The keyboard shortcut.
  572. */
  573. add: function () {
  574. /* If the group is not already defined, initialize the group. */
  575. if (!this.doesGroupExist()) {
  576. this.createGroup();
  577. }
  578.  
  579. /* Clear existing actions with same name */
  580. if (this.doesActionExist()) {
  581. W.accelerators.Actions[this.name] = null;
  582. }
  583. this.addAction();
  584.  
  585. /* Register event only if it's not already registered */
  586. if (!this.doesEventExist()) {
  587. this.addEvent();
  588. }
  589.  
  590. /* Finally, register the shortcut. */
  591. this.registerShortcut();
  592. return this;
  593. },
  594. /**
  595. * Removes the keyboard shortcut from the map.
  596. * @return {WazeWrap.Interface.Shortcut} The keyboard shortcut.
  597. */
  598. remove: function () {
  599. if (this.doesEventExist()) {
  600. W.accelerators.events.unregister(this.name, this.scope, this.callback);
  601. }
  602. if (this.doesActionExist()) {
  603. delete W.accelerators.Actions[this.name];
  604. }
  605. //remove shortcut?
  606. return this;
  607. },
  608. /**
  609. * Changes the keyboard shortcut and applies changes to the map.
  610. * @return {WazeWrap.Interface.Shortcut} The keyboard shortcut.
  611. */
  612. change: function (shortcut) {
  613. if (shortcut) {
  614. this.shortcut = {};
  615. this.shortcut[shortcut] = this.name;
  616. this.registerShortcut();
  617. }
  618. return this;
  619. }
  620. }),
  621.  
  622. this.Tab = OL.Class(this, {
  623. /** @lends WazeWrap.Interface.Tab */
  624. TAB_SELECTOR: '#user-tabs ul.nav-tabs',
  625. CONTENT_SELECTOR: '#user-info div.tab-content',
  626. callback: null,
  627. $content: null,
  628. context: null,
  629. $tab: null,
  630. /**
  631. * Creates a new WazeWrap.Interface.Tab. The tab is appended to the WME
  632. * editor sidebar and contains the passed HTML content.
  633. * @class
  634. * @name WazeWrap.Interface.Tab
  635. * @param {String} name The name of the tab. Should not contain any
  636. * special characters.
  637. * @param {String} content The HTML content of the tab.
  638. * @param {Function} [callback] A function to call upon successfully
  639. * appending the tab.
  640. * @param {Object} [context] The context in which to call the callback
  641. * function.
  642. * @return {WazeWrap.Interface.Tab} The new tab object.
  643. * @example //Creates new tab and adds it to the page.
  644. * new WazeWrap.Interface.Tab('thebestscriptever', '<div>Hello World!</div>');
  645. */
  646. initialize: function (name, content, callback, context) {
  647. var idName, i = 0;
  648. if (name && 'string' === typeof name &&
  649. content && 'string' === typeof content) {
  650. if (callback && 'function' === typeof callback) {
  651. this.callback = callback;
  652. this.context = context || callback;
  653. }
  654. /* Sanitize name for html id attribute */
  655. idName = name.toLowerCase().replace(/[^a-z-_]/g, '');
  656. /* Make sure id will be unique on page */
  657. while (
  658. $('#sidepanel-' + (i ? idName + i : idName)).length > 0) {
  659. i++;
  660. }
  661. if (i) {
  662. idName = idName + i;
  663. }
  664. /* Create tab and content */
  665. this.$tab = $('<li/>')
  666. .append($('<a/>')
  667. .attr({
  668. 'href': '#sidepanel-' + idName,
  669. 'data-toggle': 'tab',
  670. })
  671. .text(name));
  672. this.$content = $('<div/>')
  673. .addClass('tab-pane')
  674. .attr('id', 'sidepanel-' + idName)
  675. .html(content);
  676.  
  677. this.appendTab();
  678. }
  679. },
  680.  
  681. append: function (content) {
  682. this.$content.append(content);
  683. },
  684.  
  685. appendTab: function () {
  686. WazeWrap.Util.waitForElement(
  687. this.TAB_SELECTOR + ',' + this.CONTENT_SELECTOR,
  688. function () {
  689. $(this.TAB_SELECTOR).append(this.$tab);
  690. $(this.CONTENT_SELECTOR).first().append(this.$content);
  691. if (this.callback) {
  692. this.callback.call(this.context);
  693. }
  694. }, this);
  695. },
  696.  
  697. clearContent: function () {
  698. this.$content.empty();
  699. },
  700.  
  701. destroy: function () {
  702. this.$tab.remove();
  703. this.$content.remove();
  704. }
  705. });
  706. };
  707.  
  708. }.call(this));

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址