Best Python code snippet using autotest_python
dhtmlxmenu_ext.js
Source:dhtmlxmenu_ext.js
1/*2Product Name: dhtmlxSuite 3Version: 5.0 4Edition: Standard 5License: content of this file is covered by GPL. Usage outside GPL terms is prohibited. To obtain Commercial or Enterprise license contact sales@dhtmlx.com6Copyright UAB Dinamenta http://www.dhtmlx.com7*/8// enable/disable9dhtmlXMenuObject.prototype.setItemEnabled = function(id) {10 this._changeItemState(id, "enabled", this._getItemLevelType(id));11};12dhtmlXMenuObject.prototype.setItemDisabled = function(id) {13 this._changeItemState(id, "disabled", this._getItemLevelType(id));14};15dhtmlXMenuObject.prototype.isItemEnabled = function(id) {16 return (this.itemPull[this.idPrefix+id]!=null?(this.itemPull[this.idPrefix+id]["state"]=="enabled"):false);17};18// enable/disable sublevel item19dhtmlXMenuObject.prototype._changeItemState = function(id, newState, levelType) {20 var t = false;21 var j = this.idPrefix + id;22 if ((this.itemPull[j] != null) && (this.idPull[j] != null)) {23 if (this.itemPull[j]["state"] != newState) {24 this.itemPull[j]["state"] = newState;25 if (this.itemPull[j]["parent"] == this.idPrefix+this.topId && !this.conf.context) {26 this.idPull[j].className = "dhtmlxMenu_"+this.conf.skin+"_TopLevel_Item_"+(this.itemPull[j]["state"]=="enabled"?"Normal":"Disabled");27 } else {28 this.idPull[j].className = "sub_item"+(this.itemPull[j]["state"]=="enabled"?"":"_dis");29 }30 31 this._updateItemComplexState(this.idPrefix+id, this.itemPull[this.idPrefix+id]["complex"], false);32 this._updateItemImage(id, levelType);33 // if changeItemState attached to onClick event and changing applies to selected item all selection should be reparsed34 if ((this.idPrefix + this.conf.last_click == j) && (levelType != "TopLevel")) {35 this._redistribSubLevelSelection(j, this.itemPull[j]["parent"]);36 }37 if (levelType == "TopLevel" && !this.conf.context) { // rebuild style.left and show nested polygons38 // this._redistribTopLevelSelection(id, "parent");39 }40 }41 }42 return t;43};44// set-get text45dhtmlXMenuObject.prototype.getItemText = function(id) {46 return (this.itemPull[this.idPrefix+id]!=null?this.itemPull[this.idPrefix+id]["title"]:"");47};48dhtmlXMenuObject.prototype.setItemText = function(id, text) {49 id = this.idPrefix + id;50 if ((this.itemPull[id] != null) && (this.idPull[id] != null)) {51 this._clearAndHide();52 this.itemPull[id]["title"] = text;53 if (this.itemPull[id]["parent"] == this.idPrefix+this.topId && !this.conf.context) {54 // top level55 var tObj = null;56 for (var q=0; q<this.idPull[id].childNodes.length; q++) {57 try { if (this.idPull[id].childNodes[q].className == "top_level_text") tObj = this.idPull[id].childNodes[q]; } catch(e) {}58 }59 if (String(this.itemPull[id]["title"]).length == "" || this.itemPull[id]["title"] == null) {60 if (tObj != null) tObj.parentNode.removeChild(tObj);61 } else {62 if (!tObj) {63 tObj = document.createElement("DIV");64 tObj.className = "top_level_text";65 if (this.conf.rtl && this.idPull[id].childNodes.length > 0) this.idPull[id].insertBefore(tObj,this.idPull[id].childNodes[0]); else this.idPull[id].appendChild(tObj);66 }67 tObj.innerHTML = this.itemPull[id]["title"];68 }69 } else {70 // sub level71 var tObj = null;72 for (var q=0; q<this.idPull[id].childNodes[1].childNodes.length; q++) {73 if (String(this.idPull[id].childNodes[1].childNodes[q].className||"") == "sub_item_text") tObj = this.idPull[id].childNodes[1].childNodes[q];74 }75 if (String(this.itemPull[id]["title"]).length == "" || this.itemPull[id]["title"] == null) {76 if (tObj) {77 tObj.parentNode.removeChild(tObj);78 tObj = null;79 this.idPull[id].childNodes[1].innerHTML = " ";80 }81 } else {82 if (!tObj) {83 tObj = document.createElement("DIV");84 tObj.className = "sub_item_text";85 this.idPull[id].childNodes[1].innerHTML = "";86 this.idPull[id].childNodes[1].appendChild(tObj);87 }88 tObj.innerHTML = this.itemPull[id]["title"];89 }90 }91 }92};93// load from html94dhtmlXMenuObject.prototype.loadFromHTML = function(objId, clearAfterAdd, onLoad) {95 96 var t = this.conf.tags.item;97 this.conf.tags.item = "div";98 99 var node = (typeof(objId)=="string"?document.getElementById(objId):objId);100 var items = this._xmlToJson(node, this.idPrefix+this.topId);101 this._initObj(items);102 103 this.conf.tags.item = t;104 105 if (clearAfterAdd) node.parentNode.removeChild(node);106 node = objOd = null;107 108 if (onload != null) {109 if (typeof(onLoad) == "function") {110 onLoad();111 } else if (typeof(window[onLoad]) == "function") {112 window[onLoad]();113 }114 }115};116// show/hide items117dhtmlXMenuObject.prototype.hideItem = function(id) {118 this._changeItemVisible(id, false);119};120dhtmlXMenuObject.prototype.showItem = function(id) {121 this._changeItemVisible(id, true);122};123dhtmlXMenuObject.prototype.isItemHidden = function(id) {124 var isHidden = null;125 if (this.idPull[this.idPrefix+id] != null) { isHidden = (this.idPull[this.idPrefix+id].style.display == "none"); }126 return isHidden;127};128dhtmlXMenuObject.prototype._changeItemVisible = function(id, visible) {129 var itemId = this.idPrefix+id;130 if (this.itemPull[itemId] == null) return;131 if (this.itemPull[itemId]["type"] == "separator") { itemId = "separator_"+itemId; }132 if (this.idPull[itemId] == null) return;133 this.idPull[itemId].style.display = (visible?"":"none");134 this._redefineComplexState(this.itemPull[this.idPrefix+id]["parent"]);135};136// userdata137dhtmlXMenuObject.prototype.setUserData = function(id, name, value) {138 this.userData[this.idPrefix+id+"_"+name] = value;139};140dhtmlXMenuObject.prototype.getUserData = function(id, name) {141 return (this.userData[this.idPrefix+id+"_"+name]!=null?this.userData[this.idPrefix+id+"_"+name]:null);142};143// open-mode (win/web)144dhtmlXMenuObject.prototype.setOpenMode = function(mode) {145 this.conf.mode = (mode=="win"?"win":"web");146};147// web-mode timeout148dhtmlXMenuObject.prototype.setWebModeTimeout = function(tm) {149 this.conf.tm_sec = (!isNaN(tm)?tm:400);150};151// icons152dhtmlXMenuObject.prototype.getItemImage = function(id) {153 var imgs = new Array(null, null);154 id = this.idPrefix+id;155 if (this.itemPull[id]["type"] == "item") {156 imgs[0] = this.itemPull[id]["imgen"];157 imgs[1] = this.itemPull[id]["imgdis"];158 }159 return imgs;160};161dhtmlXMenuObject.prototype.setItemImage = function(id, img, imgDis) {162 if (this.itemPull[this.idPrefix+id]["type"] != "item") return;163 this.itemPull[this.idPrefix+id]["imgen"] = img;164 this.itemPull[this.idPrefix+id]["imgdis"] = imgDis;165 this._updateItemImage(id, this._getItemLevelType(id));166};167dhtmlXMenuObject.prototype.clearItemImage = function(id) {168 this.setItemImage(id, "", "");169};170// visible area171dhtmlXMenuObject.prototype.setVisibleArea = function(x1, x2, y1, y2) {172 this.conf.v_enabled = true;173 this.conf.v.x1 = x1;174 this.conf.v.x2 = x2;175 this.conf.v.y1 = y1;176 this.conf.v.y2 = y2;177};178// tooltips179dhtmlXMenuObject.prototype.setTooltip = function(id, tip) {180 id = this.idPrefix+id;181 if (!(this.itemPull[id] != null && this.idPull[id] != null)) return;182 this.idPull[id].title = (tip.length > 0 ? tip : null);183 this.itemPull[id]["tip"] = tip;184};185dhtmlXMenuObject.prototype.getTooltip = function(id) {186 if (this.itemPull[this.idPrefix+id] == null) return null;187 return this.itemPull[this.idPrefix+id]["tip"];188};189dhtmlXMenuObject.prototype.setTopText = function(text) {190 if (this.conf.context) return;191 if (this._topText == null) {192 this._topText = document.createElement("DIV");193 this._topText.className = "dhtmlxMenu_TopLevel_Text_"+(this.conf.rtl?"left":(this.conf.align=="left"?"right":"left"));194 this.base.appendChild(this._topText);195 }196 this._topText.innerHTML = text;197};198dhtmlXMenuObject.prototype.setAlign = function(align) {199 if (this.conf.align == align) return;200 if (align == "left" || align == "right") {201 // if (this.setRTL) this.setRTL(false);202 this.conf.align = align;203 if (this.cont) this.cont.className = (this.conf.align=="right"?"align_right":"align_left");204 if (this._topText != null) this._topText.className = "dhtmlxMenu_TopLevel_Text_"+(this.conf.align=="left"?"right":"left");205 }206};207dhtmlXMenuObject.prototype.setHref = function(itemId, href, target) {208 if (this.itemPull[this.idPrefix+itemId] == null) return;209 this.itemPull[this.idPrefix+itemId]["href_link"] = href;210 if (target != null) this.itemPull[this.idPrefix+itemId]["href_target"] = target;211};212dhtmlXMenuObject.prototype.clearHref = function(itemId) {213 if (this.itemPull[this.idPrefix+itemId] == null) return;214 delete this.itemPull[this.idPrefix+itemId]["href_link"];215 delete this.itemPull[this.idPrefix+itemId]["href_target"];216};217/*218File [id="file"] -> Open [id="open"] -> Last Save [id="lastsave"]219getCircuit("lastsave") will return Array("file", "open", "lastsave");220*/221dhtmlXMenuObject.prototype.getCircuit = function(id) {222 var parents = new Array(id);223 while (this.getParentId(id) != this.topId) {224 id = this.getParentId(id);225 parents[parents.length] = id;226 }227 return parents.reverse();228};229// checkboxes230dhtmlXMenuObject.prototype._getCheckboxState = function(id) {231 if (this.itemPull[this.idPrefix+id] == null) return null;232 return this.itemPull[this.idPrefix+id]["checked"];233};234dhtmlXMenuObject.prototype._setCheckboxState = function(id, state) {235 if (this.itemPull[this.idPrefix+id] == null) return;236 this.itemPull[this.idPrefix+id]["checked"] = state;237};238dhtmlXMenuObject.prototype._updateCheckboxImage = function(id) {239 if (this.idPull[this.idPrefix+id] == null) return;240 this.itemPull[this.idPrefix+id]["imgen"] = "chbx_"+(this._getCheckboxState(id)?"1":"0");241 this.itemPull[this.idPrefix+id]["imgdis"] = this.itemPull[this.idPrefix+id]["imgen"];242 try { this.idPull[this.idPrefix+id].childNodes[(this.conf.rtl?2:0)].childNodes[0].className = "sub_icon "+this.itemPull[this.idPrefix+id]["imgen"]; } catch(e){}243};244dhtmlXMenuObject.prototype._checkboxOnClickHandler = function(id, type, casState) {245 if (type.charAt(1)=="d") return;246 if (this.itemPull[this.idPrefix+id] == null) return;247 var state = this._getCheckboxState(id);248 if (this.checkEvent("onCheckboxClick")) {249 if (this.callEvent("onCheckboxClick", [id, state, this.conf.ctx_zoneid, casState])) {250 this.setCheckboxState(id, !state);251 }252 } else {253 this.setCheckboxState(id, !state);254 }255 // call onClick if exists256 if (this.checkEvent("onClick")) this.callEvent("onClick", [id]);257};258dhtmlXMenuObject.prototype.setCheckboxState = function(id, state) {259 this._setCheckboxState(id, state);260 this._updateCheckboxImage(id);261};262dhtmlXMenuObject.prototype.getCheckboxState = function(id) {263 return this._getCheckboxState(id);264};265dhtmlXMenuObject.prototype.addCheckbox = function(mode, nextToId, pos, itemId, itemText, state, disabled) {266 // checks267 if (this.conf.context && nextToId == this.topId) {268 // adding checkbox as first element to context menu269 // do nothing270 } else {271 if (this.itemPull[this.idPrefix+nextToId] == null) return;272 if (mode == "child" && this.itemPull[this.idPrefix+nextToId]["type"] != "item") return;273 }274 //275 var img = "chbx_"+(state?"1":"0");276 var imgDis = img;277 //278 279 if (mode == "sibling") {280 281 var id = this.idPrefix+(itemId!=null?itemId:this._genStr(24));282 var parentId = this.idPrefix+this.getParentId(nextToId);283 this._addItemIntoGlobalStrorage(id, parentId, itemText, "checkbox", disabled, img, imgDis);284 this.itemPull[id]["checked"] = state;285 this._renderSublevelItem(id, this.getItemPosition(nextToId));286 } else {287 288 var id = this.idPrefix+(itemId!=null?itemId:this._genStr(24));289 var parentId = this.idPrefix+nextToId;290 this._addItemIntoGlobalStrorage(id, parentId, itemText, "checkbox", disabled, img, imgDis);291 this.itemPull[id]["checked"] = state;292 if (this.idPull["polygon_"+parentId] == null) { this._renderSublevelPolygon(parentId, parentId); }293 this._renderSublevelItem(id, pos-1);294 this._redefineComplexState(parentId);295 }296};297// hot-keys298dhtmlXMenuObject.prototype.setHotKey = function(id, hkey) {299 300 id = this.idPrefix+id;301 302 if (!(this.itemPull[id] != null && this.idPull[id] != null)) return;303 if (this.itemPull[id]["parent"] == this.idPrefix+this.topId && !this.conf.context) return;304 if (this.itemPull[id]["complex"]) return;305 var t = this.itemPull[id]["type"];306 if (!(t == "item" || t == "checkbox" || t == "radio")) return;307 308 // retrieve obj309 var hkObj = null;310 try { if (this.idPull[id].childNodes[this.conf.rtl?0:2].childNodes[0].className == "sub_item_hk") hkObj = this.idPull[id].childNodes[this.conf.rtl?0:2].childNodes[0]; } catch(e){}311 312 if (hkey.length == 0) {313 // remove if exists314 this.itemPull[id]["hotkey_backup"] = this.itemPull[id]["hotkey"];315 this.itemPull[id]["hotkey"] = "";316 if (hkObj != null) hkObj.parentNode.removeChild(hkObj);317 318 } else {319 320 // add if needed or change321 this.itemPull[id]["hotkey"] = hkey;322 this.itemPull[id]["hotkey_backup"] = null;323 //324 if (hkObj == null) {325 hkObj = document.createElement("DIV");326 hkObj.className = "sub_item_hk";327 var item = this.idPull[id].childNodes[this.conf.rtl?0:2];328 while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]);329 item.appendChild(hkObj);330 }331 hkObj.innerHTML = hkey;332 }333};334dhtmlXMenuObject.prototype.getHotKey = function(id) {335 if (this.itemPull[this.idPrefix+id] == null) return null;336 return this.itemPull[this.idPrefix+id]["hotkey"];337};338// overflow control339dhtmlXMenuObject.prototype._clearAllSelectedSubItemsInPolygon = function(polygon) {340 var subIds = this._getSubItemToDeselectByPolygon(polygon);341 // hide opened polygons and selected items342 for (var q=0; q<this.conf.opened_poly.length; q++) {343 if (this.conf.opened_poly[q] != polygon) this._hidePolygon(this.conf.opened_poly[q]);344 }345 for (var q=0; q<subIds.length; q++) {346 if (this.idPull[subIds[q]] != null && this.itemPull[subIds[q]]["state"] == "enabled") {347 this.idPull[subIds[q]].className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_Item_Normal";348 }349 }350};351// define normal/disabled arrows in polygon352dhtmlXMenuObject.prototype._checkArrowsState = function(id) {353 var polygon = this.idPull["polygon_"+id].childNodes[1];354 var arrowUp = this.idPull["arrowup_"+id];355 var arrowDown = this.idPull["arrowdown_"+id];356 if (polygon.scrollTop == 0) {357 arrowUp.className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_ArrowUp_Disabled";358 } else {359 arrowUp.className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_ArrowUp" + (arrowUp.over ? "_Over" : "");360 }361 if (polygon.scrollTop + polygon.offsetHeight < polygon.scrollHeight) {362 arrowDown.className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_ArrowDown" + (arrowDown.over ? "_Over" : "");363 } else {364 arrowDown.className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_ArrowDown_Disabled";365 }366 polygon = arrowUp = arrowDown = null;367};368// add up-limit-arrow369dhtmlXMenuObject.prototype._addUpArrow = function(id) {370 var that = this;371 var arrow = document.createElement("DIV");372 arrow.pId = this.idPrefix+id;373 arrow.id = "arrowup_"+this.idPrefix+id;374 arrow.className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_ArrowUp";375 376 arrow.over = false;377 arrow.onselectstart = function(e) { e = e||event; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }378 arrow.oncontextmenu = function(e) { e = e||event; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }379 // actions380 arrow.onmouseover = function() {381 if (that.conf.mode == "web") { window.clearTimeout(that.conf.tm_handler); }382 that._clearAllSelectedSubItemsInPolygon(this.pId);383 if (this.className == "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowUp_Disabled") return;384 this.className = "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowUp_Over";385 this.over = true;386 that._canScrollUp = true;387 that._doScrollUp(this.pId, true);388 }389 arrow.onmouseout = function() {390 if (that.conf.mode == "web") {391 window.clearTimeout(that.conf.tm_handler);392 that.conf.tm_handler = window.setTimeout(function(){that._clearAndHide();}, that.conf.tm_sec, "JavaScript");393 }394 this.over = false;395 that._canScrollUp = false;396 if (this.className == "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowUp_Disabled") return;397 this.className = "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowUp";398 window.clearTimeout(that.conf.of_utm);399 }400 arrow.onclick = function(e) {401 e = e||event;402 if (e.preventDefault) e.preventDefault(); else e.returnValue = false;403 e.cancelBubble = true;404 return false;405 }406 407 var polygon = this.idPull["polygon_"+this.idPrefix+id];408 polygon.childNodes[0].appendChild(arrow);409 410 this.idPull[arrow.id] = arrow;411 polygon = arrow = null;412};413dhtmlXMenuObject.prototype._addDownArrow = function(id) {414 415 var that = this;416 var arrow = document.createElement("DIV");417 arrow.pId = this.idPrefix+id;418 arrow.id = "arrowdown_"+this.idPrefix+id;419 arrow.className = "dhtmlxMenu_"+this.conf.skin+"_SubLevelArea_ArrowDown";420 421 arrow.over = false;422 arrow.onselectstart = function(e) { e = e||event; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }423 arrow.oncontextmenu = function(e) { e = e||event; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; return false; }424 425 // actions426 arrow.onmouseover = function() {427 if (that.conf.mode == "web") { window.clearTimeout(that.conf.tm_handler); }428 that._clearAllSelectedSubItemsInPolygon(this.pId);429 if (this.className == "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowDown_Disabled") return;430 this.className = "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowDown_Over";431 this.over = true;432 that._canScrollDown = true;433 that._doScrollDown(this.pId, true);434 }435 arrow.onmouseout = function() {436 if (that.conf.mode == "web") {437 window.clearTimeout(that.conf.tm_handler);438 that.conf.tm_handler = window.setTimeout(function(){that._clearAndHide();}, that.conf.tm_sec, "JavaScript");439 }440 this.over = false;441 that._canScrollDown = false;442 if (this.className == "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowDown_Disabled") return;443 this.className = "dhtmlxMenu_"+that.conf.skin+"_SubLevelArea_ArrowDown";444 window.clearTimeout(that.conf.of_dtm);445 }446 arrow.onclick = function(e) {447 e = e||event;448 if (e.preventDefault) e.preventDefault(); else e.returnValue = false;449 e.cancelBubble = true;450 return false;451 }452 453 var polygon = this.idPull["polygon_"+this.idPrefix+id];454 polygon.childNodes[2].appendChild(arrow);455 456 this.idPull[arrow.id] = arrow;457 polygon = arrow = null;458};459dhtmlXMenuObject.prototype._removeUpArrow = function(id) {460 var fullId = "arrowup_"+this.idPrefix+id;461 this._removeArrow(fullId);462};463dhtmlXMenuObject.prototype._removeDownArrow = function(id) {464 var fullId = "arrowdown_"+this.idPrefix+id;465 this._removeArrow(fullId);466};467dhtmlXMenuObject.prototype._removeArrow = function(fullId) {468 var arrow = this.idPull[fullId];469 arrow.onselectstart = null;470 arrow.oncontextmenu = null;471 arrow.onmouseover = null;472 arrow.onmouseout = null;473 arrow.onclick = null;474 if (arrow.parentNode) arrow.parentNode.removeChild(arrow);475 arrow = null;476 this.idPull[fullId] = null;477 try { delete this.idPull[fullId]; } catch(e) {}478};479dhtmlXMenuObject.prototype._isArrowExists = function(id) {480 if (this.idPull["arrowup_"+id] != null && this.idPull["arrowdown_"+id] != null) return true;481 return false;482};483// scroll down484dhtmlXMenuObject.prototype._doScrollUp = function(id, checkArrows) {485 var polygon = this.idPull["polygon_"+id].childNodes[1];486 if (this._canScrollUp && polygon.scrollTop > 0) {487 var theEnd = false;488 var nextScrollTop = polygon.scrollTop - this.conf.of_ustep;489 if (nextScrollTop < 0) {490 theEnd = true;491 nextScrollTop = 0;492 }493 polygon.scrollTop = nextScrollTop;494 if (!theEnd) {495 var that = this;496 this.conf.of_utm = window.setTimeout(function() {497 that._doScrollUp(id, false);498 that = null;499 }, this.conf.of_utime);500 } else {501 checkArrows = true;502 }503 } else {504 this._canScrollUp = false;505 this._checkArrowsState(id);506 }507 if (checkArrows) {508 this._checkArrowsState(id);509 }510};511dhtmlXMenuObject.prototype._doScrollDown = function(id, checkArrows) {512 var polygon = this.idPull["polygon_"+id].childNodes[1];513 if (this._canScrollDown && polygon.scrollTop + polygon.offsetHeight <= polygon.scrollHeight) {514 var theEnd = false;515 var nextScrollTop = polygon.scrollTop + this.conf.of_dstep;516 if (nextScrollTop + polygon.offsetHeight >= polygon.scrollHeight) {517 theEnd = true;518 nextScrollTop = polygon.scrollHeight - polygon.offsetHeight;519 }520 polygon.scrollTop = nextScrollTop;521 if (!theEnd) {522 var that = this;523 this.conf.of_dtm = window.setTimeout(function() {524 that._doScrollDown(id, false);525 that = null;526 }, this.conf.of_dtime);527 } else {528 checkArrows = true;529 }530 } else {531 this._canScrollDown = false;532 this._checkArrowsState(id);533 }534 if (checkArrows) {535 this._checkArrowsState(id);536 }537};538dhtmlXMenuObject.prototype._countPolygonItems = function(id) {539 var count = 0;540 for (var a in this.itemPull) {541 var par = this.itemPull[a]["parent"];542 var tp = this.itemPull[a]["type"];543 if (par == this.idPrefix+id && (tp == "item" || tp == "radio" || tp == "checkbox")) { count++; }544 }545 return count;546};547dhtmlXMenuObject.prototype.setOverflowHeight = function(itemsNum) {548 549 // set auto overflow mode550 if (itemsNum === "auto") {551 this.conf.overflow_limit = 0;552 this.conf.auto_overflow = true;553 return;554 }555 556 // no existing limitation, now new limitation557 if (this.conf.overflow_limit == 0 && itemsNum <= 0) return;558 559 // hide menu to prevent visible changes560 this._clearAndHide();561 562 // redefine existing limitation, arrows will added automatically with showPlygon563 if (this.conf.overflow_limit >= 0 && itemsNum > 0) {564 this.conf.overflow_limit = itemsNum;565 return;566 }567 568 // remove existing limitation569 if (this.conf.overflow_limit > 0 && itemsNum <= 0) {570 for (var a in this.itemPull) {571 if (this._isArrowExists(a)) {572 var b = String(a).replace(this.idPrefix, "");573 this._removeUpArrow(b);574 this._removeDownArrow(b);575 // remove polygon's height576 this.idPull["polygon_"+a].childNodes[1].style.height = "";577 }578 }579 this.conf.overflow_limit = 0;580 return;581 }582};583// radiobuttons584dhtmlXMenuObject.prototype._getRadioImgObj = function(id) {585 try { var imgObj = this.idPull[this.idPrefix+id].childNodes[(this.conf.rtl?2:0)].childNodes[0] } catch(e) { var imgObj = null; }586 return imgObj;587};588dhtmlXMenuObject.prototype._setRadioState = function(id, state) {589 // if (this.itemPull[this.idPrefix+id]["state"] != "enabled") return;590 var imgObj = this._getRadioImgObj(id);591 if (imgObj != null) {592 // fix, added in 0.4593 var rObj = this.itemPull[this.idPrefix+id];594 rObj["checked"] = state;595 rObj["imgen"] = "rdbt_"+(rObj["checked"]?"1":"0");596 rObj["imgdis"] = rObj["imgen"];597 imgObj.className = "sub_icon "+rObj["imgen"];598 }599};600dhtmlXMenuObject.prototype._radioOnClickHandler = function(id, type, casState) {601 if (type.charAt(1)=="d" || this.itemPull[this.idPrefix+id]["group"]==null) return;602 // deselect all from the same group603 var group = this.itemPull[this.idPrefix+id]["group"];604 if (this.checkEvent("onRadioClick")) {605 if (this.callEvent("onRadioClick", [group, this.getRadioChecked(group), id, this.conf.ctx_zoneid, casState])) {606 this.setRadioChecked(group, id);607 }608 } else {609 this.setRadioChecked(group, id);610 }611 // call onClick if exists612 if (this.checkEvent("onClick")) this.callEvent("onClick", [id]);613};614dhtmlXMenuObject.prototype.getRadioChecked = function(group) {615 var id = null;616 for (var q=0; q<this.radio[group].length; q++) {617 var itemId = this.radio[group][q].replace(this.idPrefix, "");618 var imgObj = this._getRadioImgObj(itemId);619 if (imgObj != null) {620 var checked = (imgObj.className).match(/rdbt_1$/gi);621 if (checked != null) id = itemId;622 }623 }624 return id;625};626dhtmlXMenuObject.prototype.setRadioChecked = function(group, id) {627 if (this.radio[group] == null) return;628 for (var q=0; q<this.radio[group].length; q++) {629 var itemId = this.radio[group][q].replace(this.idPrefix, "");630 this._setRadioState(itemId, (itemId==id));631 }632}633dhtmlXMenuObject.prototype.addRadioButton = function(mode, nextToId, pos, itemId, itemText, group, state, disabled) {634 // radiobutton635 if (this.conf.context && nextToId == this.topId) {636 // adding radiobutton as first element to context menu637 // do nothing638 } else {639 if (this.itemPull[this.idPrefix+nextToId] == null) return;640 if (mode == "child" && this.itemPull[this.idPrefix+nextToId]["type"] != "item") return;641 }642 643 var id = this.idPrefix+(itemId!=null?itemId:this._genStr(24));644 var img = "rdbt_"+(state?"1":"0");645 var imgDis = img;646 //647 if (mode == "sibling") {648 var parentId = this.idPrefix+this.getParentId(nextToId);649 this._addItemIntoGlobalStrorage(id, parentId, itemText, "radio", disabled, img, imgDis);650 this._renderSublevelItem(id, this.getItemPosition(nextToId));651 } else {652 var parentId = this.idPrefix+nextToId;653 this._addItemIntoGlobalStrorage(id, parentId, itemText, "radio", disabled, img, imgDis);654 if (this.idPull["polygon_"+parentId] == null) { this._renderSublevelPolygon(parentId, parentId); }655 this._renderSublevelItem(id, pos-1);656 this._redefineComplexState(parentId);657 }658 //659 var gr = (group!=null?group:this._genStr(24));660 this.itemPull[id]["group"] = gr;661 //662 if (this.radio[gr]==null) { this.radio[gr] = new Array(); }663 this.radio[gr][this.radio[gr].length] = id;664 //665 if (state == true) this.setRadioChecked(gr, String(id).replace(this.idPrefix, ""));666};667// serialize668dhtmlXMenuObject.prototype.serialize = function() {669 var xml = "<menu>"+this._readLevel(this.idPrefix+this.topId)+"</menu>";670 return xml;671};672dhtmlXMenuObject.prototype._readLevel = function(parentId) {673 var xml = "";674 for (var a in this.itemPull) {675 if (this.itemPull[a]["parent"] == parentId) {676 var imgEn = "";677 var imgDis = "";678 var hotKey = "";679 var itemId = String(this.itemPull[a]["id"]).replace(this.idPrefix,"");680 var itemType = "";681 var itemText = (this.itemPull[a]["title"]!=""?' text="'+this.itemPull[a]["title"]+'"':"");682 var itemState = "";683 if (this.itemPull[a]["type"] == "item") {684 if (this.itemPull[a]["imgen"] != "") imgEn = ' img="'+this.itemPull[a]["imgen"]+'"';685 if (this.itemPull[a]["imgdis"] != "") imgDis = ' imgdis="'+this.itemPull[a]["imgdis"]+'"';686 if (this.itemPull[a]["hotkey"] != "") hotKey = '<hotkey>'+this.itemPull[a]["hotkey"]+'</hotkey>';687 }688 if (this.itemPull[a]["type"] == "separator") {689 itemType = ' type="separator"';690 } else {691 if (this.itemPull[a]["state"] == "disabled") itemState = ' enabled="false"';692 }693 if (this.itemPull[a]["type"] == "checkbox") {694 itemType = ' type="checkbox"'+(this.itemPull[a]["checked"]?' checked="true"':"");695 }696 if (this.itemPull[a]["type"] == "radio") {697 itemType = ' type="radio" group="'+this.itemPull[a]["group"]+'" '+(this.itemPull[a]["checked"]?' checked="true"':"");698 }699 xml += "<item id='"+itemId+"'"+itemText+itemType+imgEn+imgDis+itemState+">";700 xml += hotKey;701 if (this.itemPull[a]["complex"]) xml += this._readLevel(a);702 xml += "</item>";703 }704 }705 return xml;...
menu.js
Source:menu.js
1module.exports = [2 {3 name:'çé²é£å',4 id:'5',5 category:"sx",6 children:[7 {8 name:'ç²¾åèç±»',9 id:'6',10 children:[11 {12 name:'ç¾è',13 id:'7',14 },15 {16 name:'禽类',17 id:'8',18 },19 {20 name:'çªè',21 id:'9',22 },23 {24 name:'çè',25 id:'10',26 }27 ]28 },29 {30 name:'æµ·é²æ°´äº§',31 id:'6',32 children:[33 {34 name:'åé²',35 id:'7',36 },37 {38 name:'é±¼',39 id:'8',40 },41 {42 name:'è¾',43 id:'9',44 },45 {46 name:'è¹/è´',47 id:'10',48 }49 ]50 },51 {52 name:'èå¶å',53 id:'6',54 children:[55 {56 name:'æ¾è±è',57 id:'7',58 },59 {60 name:'å¸é¸è',61 id:'8',62 },63 {64 name:'鸡è',65 id:'9',66 }67 ]68 },69 {70 name:'å¶èç±»',71 id:'6',72 children:[73 {74 name:'çè',75 id:'7',76 },77 {78 name:'è è',79 id:'8',80 },81 {82 name:'åæ¤',83 id:'9',84 },85 {86 name:'西å
°è±',87 id:'9',88 }89 ]90 },91 {92 name:'æ ¹èç±»',93 id:'6',94 children:[95 ]96 },97 {98 name:'èæç±»',99 id:'6',100 children:[101 ]102 },103 {104 name:'èèç±»',105 id:'6',106 children:[107 ]108 },109 {110 name:'è¿å£çé²',111 id:'6',112 children:[113 ]114 }115 ]116 },117 {118 name:'粮油å¯é£',119 id:'5',120 category:"lyfs",121 children:[122 {123 name:'ç²¾åèç±»2',124 id:'6',125 children:[126 {127 name:'ç¾è2',128 id:'7',129 },130 {131 name:'禽类2',132 id:'8',133 },134 {135 name:'çªè2',136 id:'9',137 },138 {139 name:'çè2',140 id:'10',141 }142 ]143 },144 {145 name:'æµ·é²æ°´äº§2',146 id:'6',147 children:[148 {149 name:'åé²2',150 id:'7',151 },152 {153 name:'é±¼2',154 id:'8',155 },156 {157 name:'è¾2',158 id:'9',159 },160 {161 name:'è¹/è´2',162 id:'10',163 }164 ]165 },166 {167 name:'èå¶å2',168 id:'6',169 children:[170 {171 name:'æ¾è±è',172 id:'7',173 },174 {175 name:'å¸é¸è',176 id:'8',177 },178 {179 name:'鸡è',180 id:'9',181 }182 ]183 },184 {185 name:'å¶èç±»',186 id:'6',187 children:[188 {189 name:'çè',190 id:'7',191 },192 {193 name:'è è',194 id:'8',195 },196 {197 name:'åæ¤',198 id:'9',199 },200 {201 name:'西å
°è±',202 id:'9',203 }204 ]205 },206 {207 name:'æ ¹èç±»',208 id:'6',209 children:[210 ]211 },212 {213 name:'èæç±»',214 id:'6',215 children:[216 ]217 },218 {219 name:'èèç±»',220 id:'6',221 children:[222 ]223 },224 {225 name:'è¿å£çé²',226 id:'6',227 children:[228 ]229 }230 ]231 },232 {233 name:'è¬èæ°´æ',234 id:'5',235 category:"scsg",236 children:[237 {238 name:'ç²¾åèç±»3',239 id:'6',240 children:[241 {242 name:'ç¾è3',243 id:'7',244 },245 {246 name:'禽类3',247 id:'8',248 },249 {250 name:'çªè3',251 id:'9',252 },253 {254 name:'çè3',255 id:'10',256 }257 ]258 },259 {260 name:'æµ·é²æ°´äº§3',261 id:'6',262 children:[263 {264 name:'åé²3',265 id:'7',266 },267 {268 name:'é±¼3',269 id:'8',270 },271 {272 name:'è¾3',273 id:'9',274 },275 {276 name:'è¹/è´3',277 id:'10',278 }279 ]280 },281 {282 name:'èå¶å3',283 id:'6',284 children:[285 {286 name:'æ¾è±è3',287 id:'7',288 },289 {290 name:'å¸é¸è3',291 id:'8',292 },293 {294 name:'鸡è3',295 id:'9',296 }297 ]298 },299 {300 name:'å¶èç±»3',301 id:'6',302 children:[303 {304 name:'çè3',305 id:'7',306 },307 {308 name:'è è3',309 id:'8',310 },311 {312 name:'åæ¤3',313 id:'9',314 },315 {316 name:'西å
°è±3',317 id:'9',318 }319 ]320 },321 {322 name:'æ ¹èç±»',323 id:'6',324 children:[325 ]326 },327 {328 name:'èæç±»',329 id:'6',330 children:[331 ]332 },333 {334 name:'èèç±»',335 id:'6',336 children:[337 ]338 },339 {340 name:'è¿å£çé²',341 id:'6',342 children:[343 ]344 }345 ]346 },347 {348 name:'ä¼é²é£å',349 id:'5',350 category:"xxsp",351 children:[352 {353 name:'ç²¾åèç±»4',354 id:'6',355 children:[356 {357 name:'ç¾è4',358 id:'7',359 },360 {361 name:'禽类4',362 id:'8',363 },364 {365 name:'çªè4',366 id:'9',367 },368 {369 name:'çè4',370 id:'10',371 }372 ]373 },374 {375 name:'æµ·é²æ°´äº§4',376 id:'6',377 children:[378 {379 name:'åé²4',380 id:'7',381 },382 {383 name:'é±¼4',384 id:'8',385 },386 {387 name:'è¾4',388 id:'9',389 },390 {391 name:'è¹/è´4',392 id:'10',393 }394 ]395 },396 {397 name:'èå¶å4',398 id:'6',399 children:[400 {401 name:'æ¾è±è4',402 id:'7',403 },404 {405 name:'å¸é¸è4',406 id:'8',407 },408 {409 name:'鸡è4',410 id:'9',411 }412 ]413 },414 {415 name:'å¶èç±»',416 id:'6',417 children:[418 {419 name:'çè4',420 id:'7',421 },422 {423 name:'è è4',424 id:'8',425 },426 {427 name:'åæ¤4',428 id:'9',429 },430 {431 name:'西å
°è±4',432 id:'9',433 }434 ]435 },436 {437 name:'æ ¹èç±»',438 id:'6',439 children:[440 ]441 },442 {443 name:'èæç±»',444 id:'6',445 children:[446 ]447 },448 {449 name:'èèç±»',450 id:'6',451 children:[452 ]453 },454 {455 name:'è¿å£çé²',456 id:'6',457 children:[458 ]459 }460 ]461 },462 {463 name:'奶类å¶å',464 id:'5',465 category:"nlzp",466 children:[467 {468 name:'ç²¾åèç±»',469 id:'6',470 children:[471 {472 name:'ç¾è',473 id:'7',474 },475 {476 name:'禽类',477 id:'8',478 },479 {480 name:'çªè',481 id:'9',482 },483 {484 name:'çè',485 id:'10',486 }487 ]488 },489 {490 name:'æµ·é²æ°´äº§',491 id:'6',492 children:[493 {494 name:'åé²',495 id:'7',496 },497 {498 name:'é±¼',499 id:'8',500 },501 {502 name:'è¾',503 id:'9',504 },505 {506 name:'è¹/è´',507 id:'10',508 }509 ]510 },511 {512 name:'èå¶å',513 id:'6',514 children:[515 {516 name:'æ¾è±è',517 id:'7',518 },519 {520 name:'å¸é¸è',521 id:'8',522 },523 {524 name:'鸡è',525 id:'9',526 }527 ]528 },529 {530 name:'å¶èç±»',531 id:'6',532 children:[533 {534 name:'çè',535 id:'7',536 },537 {538 name:'è è',539 id:'8',540 },541 {542 name:'åæ¤',543 id:'9',544 },545 {546 name:'西å
°è±',547 id:'9',548 }549 ]550 },551 {552 name:'æ ¹èç±»',553 id:'6',554 children:[555 ]556 },557 {558 name:'èæç±»',559 id:'6',560 children:[561 ]562 },563 {564 name:'èèç±»',565 id:'6',566 children:[567 ]568 },569 {570 name:'è¿å£çé²',571 id:'6',572 children:[573 ]574 }575 ]576 },577 {578 name:'天ç¶å¹²è´§',579 id:'5',580 category:"trgh",581 children:[582 {583 name:'ç²¾åèç±»',584 id:'6',585 children:[586 {587 name:'ç¾è',588 id:'7',589 },590 {591 name:'禽类',592 id:'8',593 },594 {595 name:'çªè',596 id:'9',597 },598 {599 name:'çè',600 id:'10',601 }602 ]603 },604 {605 name:'æµ·é²æ°´äº§',606 id:'6',607 children:[608 {609 name:'åé²',610 id:'7',611 },612 {613 name:'é±¼',614 id:'8',615 },616 {617 name:'è¾',618 id:'9',619 },620 {621 name:'è¹/è´',622 id:'10',623 }624 ]625 },626 {627 name:'èå¶å',628 id:'6',629 children:[630 {631 name:'æ¾è±è',632 id:'7',633 },634 {635 name:'å¸é¸è',636 id:'8',637 },638 {639 name:'鸡è',640 id:'9',641 }642 ]643 },644 {645 name:'å¶èç±»',646 id:'6',647 children:[648 {649 name:'çè',650 id:'7',651 },652 {653 name:'è è',654 id:'8',655 },656 {657 name:'åæ¤',658 id:'9',659 },660 {661 name:'西å
°è±',662 id:'9',663 }664 ]665 },666 {667 name:'æ ¹èç±»',668 id:'6',669 children:[670 ]671 },672 {673 name:'èæç±»',674 id:'6',675 children:[676 ]677 },678 {679 name:'èèç±»',680 id:'6',681 children:[682 ]683 },684 {685 name:'è¿å£çé²',686 id:'6',687 children:[688 ]689 }690 ]691 }...
skeletonCascade.js
Source:skeletonCascade.js
1var skeleton = {};2skeleton.option={3 root:"",4 se : { id : "", def : "" , data:"", change: ""},//å¦æ®µ5 l : { id : "", def : "" , data:"", change: ""},//年级6 d : { id : "", def : "" , data:"", change: "", clear:""},//å¦ç§7 v : { id : "", def : "" , data:"", change: "", clear:""},//åå8 ch : { id : "", def : "" , data:"", change: "", clear:""},//ç« è9 kn : { parent:"" , id:"", def:"" , data:"", change:"", clear:""},//ç¥è¯ç¹10 tc : { parent:"" , id:"", def:"" , data:"", change:"", clear:"", type:""}//ç®å½11};12skeleton.load = function() {13 if (skeleton.option.se.id == "" || skeleton.option.d.id == "") return;14 if (skeleton.option.se.id != "") {15 $("#" + skeleton.option.se.id).bind("change", skeleton.onSemesterChange); //å¦æ®µæ´æ°ç»å®16 }17 18 if (skeleton.option.l.id != "") {19 $("#" + skeleton.option.l.id).bind("change", skeleton.onClasslevelChange); //年级æ´æ°ç»å®20 }21 22 if (skeleton.option.d.id != "") {23 $("#" + skeleton.option.d.id).bind("change", skeleton.onDisciplineChange); //å¦ç§æ´æ°ç»å®24 }25 26 if (skeleton.option.v.id != "") {27 $("#" + skeleton.option.v.id).bind("change", skeleton.onVolumeChange); //ååæ´æ°ç»å®28 }29 30 if (skeleton.option.ch.id != "" && skeleton.option.ch.change != "") {31 $("#" + skeleton.option.ch.id).bind("change", skeleton.option.ch.change);32 }33 34 if (skeleton.option.kn.id != "") {35 $("#" + skeleton.option.kn.id).bind("change", skeleton.onKnowledgeChange);36 }37 38 if (skeleton.option.tc.id != "") {39 $("#" + skeleton.option.tc.id).bind("change", skeleton.onTeachCatalogChange);40 }41 42// if (skeleton.option.et.id != "") {43// $("#" + skeleton.option.et.id).bind("change", skeleton.onExamTypeChange);44// }45 46 $.post(skeleton.option.root + "/skeleton/getSkeletonInfos.do",47 {'semesterId': skeleton.option.se.def,48 'classlevelId': skeleton.option.l.def,49 'disciplineId': skeleton.option.d.def,50 'volumeId': skeleton.option.v.def},51 function(data) {52 var semesters = data.semesters;53 if (skeleton.option.se.id != "" && semesters != undefined && semesters.length > 0) {54 skeleton.appendOptions(skeleton.option.se.id, semesters, "semesterName", skeleton.option.se.def);55 }56 57 var classlevels = data.classlevels;58 if (skeleton.option.l.id != "") {59 if (classlevels != undefined && classlevels.length > 0) {60 skeleton.appendOptions(skeleton.option.l.id, classlevels, "classLevelName", skeleton.option.l.def);61 } else {62 $("#" + skeleton.option.l.id).val("");63 }64 }65 66 var disciplines = data.disciplines;67 if (skeleton.option.d.id !="") {68 if (disciplines != undefined && disciplines.length > 0) {69 skeleton.appendOptions(skeleton.option.d.id, disciplines, "disciplineName", skeleton.option.d.def);70 } else {71 $("#" + skeleton.option.d.id).val("");72 }73 }74 75 var volumes = data.volumes;76 if (skeleton.option.v.id != "") {77 if (volumes != undefined && volumes.length > 0) {78 skeleton.appendOptions(skeleton.option.v.id, volumes, "volumeName", skeleton.option.v.def);79 } else {80 $("#" + skeleton.option.v.id).val("");81 }82 }83 84 var chapters = data.chapters;85 if (skeleton.option.ch.id != "") {86 if (chapters != undefined && chapters.length > 0) {87 skeleton.appendOptions(skeleton.option.ch.id, chapters, "chapterName", skeleton.option.ch.def);88 } else {89 $("#" + skeleton.option.ch.id).val("");90 }91 }92 93 var knowledges = data.knowledges;94 if (skeleton.option.kn.id != "" && knowledges != undefined && knowledges.length > 0) {95 skeleton.appendOptions(skeleton.option.kn.id, knowledges, "knowledgeName", skeleton.option.kn.def);96 }97 98 var teachCatalogs = data.teachCatalogs;99 if (skeleton.option.tc.id != "" && teachCatalogs != undefined && teachCatalogs.length > 0) {100 skeleton.appendOptions(skeleton.option.tc.id, teachCatalogs, skeleton.option.tc.def, "");101 }102 }103 );104};105skeleton.onSemesterChange = function() {106 skeleton.clearClasslevels();107 skeleton.obtainClasslevels();108 if (skeleton.option.se.change != "") {109 skeleton.option.se.change();110 }111};112skeleton.onClasslevelChange = function() {113 skeleton.clearDisciplines();114 skeleton.obtainDisciplines();115 if (skeleton.option.l.change != "") {116 skeleton.option.l.change();117 }118};119skeleton.onDisciplineChange = function() {120 skeleton.clearVolumes();121 skeleton.clearKnowledges();122 skeleton.clearTeacherCatalogs();123 skeleton.obtainInfosByDiscipline();124 if (skeleton.option.d.change != "") {125 skeleton.option.d.change();126 }127};128skeleton.onVolumeChange = function() {129 skeleton.clearChapters();130 skeleton.obtainChapters();131 if (skeleton.option.v.change != "") {132 skeleton.option.v.change();133 }134};135skeleton.onKnowledgeChange = function() {136 var knowledgeId = $(this).val();137 138 var $currItem = {};139 if (this.id == skeleton.option.kn.id) {140 $currItem = $(this);141 } else {142 $currItem = $(this).parent();143 }144 145 //æ¸
é¤åç¥è¯ç¹select146 var knCount = $(".kns").length;147 if (knCount > 0) {148 var currIdStr = this.id;149 if (currIdStr == skeleton.option.kn.id) {150 $(".kns:eq(0) select option").remove();151 $(".kns:eq(0) select").append("<option value=\"\">请éæ©</option>");152 $(".kns:gt(0)").remove();153 } else {154 $currItem.next(".kns").find("select option:gt(0)").remove();155 $currItem.nextAll(".kns").filter(":gt(0)").remove();156 }157 }158 159 if (knowledgeId == 0 || knowledgeId == "") {160 $currItem.next(".kns").remove();161 return;162 }163 164 $.post(skeleton.option.root + "/skeleton/getKnowledges.do", {"parentId": knowledgeId}, function(data) {165 if (data.length == 0) {166 $currItem.next(".kns").remove();167 return;168 }169 if ($currItem.next(".kns").length == 0) {170 $("#" + skeleton.option.kn.parent).append("<span class='kns'><label>åç¥è¯ç¹ï¼ </label><select>"171 + "<option value=\"\">请éæ©</option></select></span>");172 }173 174 var nameProperty = "knowledgeName";175 var $select = $currItem.next(".kns").children("select");176 $select.children("option:gt(0)").remove();177 for (var i=0; i < data.length; i++) {178 var item = data[i];179 $select.append("<option value=\"" + item.id + "\">" + item[ nameProperty] + "</option>");180 }181 $select.bind("change", skeleton.onKnowledgeChange);182 });183};184skeleton.onTeachCatalogChange = function() {185 var teachCatalogId = $(this).val();186 187 var $currItem = {};188 if (this.id == skeleton.option.tc.id) {189 $currItem = $(this);190 } else {191 $currItem = $(this).parent();192 }193 194 //æ¸
é¤åç¥è¯ç¹select195 var tcCount = $(".tcs").length;196 if (tcCount > 0) {197 var currIdStr = this.id;198 if (currIdStr == skeleton.option.tc.id) {199 $(".tcs:eq(0) select option").remove();200 $(".tcs:eq(0) select").append("<option value=\"\">请éæ©</option>");201 $(".tcs:gt(0)").remove();202 } else {203 $currItem.next(".tcs").find("select option:gt(0)").remove();204 $currItem.nextAll(".tcs").filter(":gt(0)").remove();205 }206 }207 208 if (teachCatalogId == 0 || teachCatalogId == "") {209 $currItem.next(".tcs").remove();210 return;211 }212 213 $.post(skeleton.option.root + "/skeleton/getTeachCatalogs.do", {"parentId": teachCatalogId}, function(data) {214 if (data.length == 0) {215 $currItem.next(".tcs").remove();216 return;217 }218 if ($currItem.next(".tcs").length == 0) {219 $("#" + skeleton.option.tc.parent).append("<span class='tcs'><label>åç±»åï¼ </label><select>"220 + "<option value=\"\">请éæ©</option></select></span>");221 }222 223 var nameProperty = "catalogName";224 var $select = $currItem.next(".tcs").children("select");225 $select.children("option:gt(0)").remove();226 for (var i=0; i < data.length; i++) {227 var item = data[i];228 $select.append("<option value=\"" + item.id + "\">" + item[ nameProperty] + "</option>");229 }230 $select.bind("change", skeleton.onTeachCatalogChange);231 });232};233skeleton.onExamTypeChange = function() {234 var examTypeId = $(this).val();235 236 var $currItem = {};237 if (this.id == skeleton.option.et.id) {238 $currItem = $(this);239 } else {240 $currItem = $(this).parent();241 }242 243 //æ¸
é¤åè¯å·ç±»å244 var knCount = $(".ets").length;245 if (knCount > 0) {246 var currIdStr = this.id;247 if (currIdStr == skeleton.option.kn.id) {248 $(".ets:eq(0) select option").remove();249 $(".ets:eq(0) select").append("<option value=\"\">请éæ©</option>");250 $(".ets:gt(0)").remove();251 } else {252 $currItem.next(".ets").find("select option:gt(0)").remove();253 $currItem.nextAll(".ets").filter(":gt(0)").remove();254 }255 }256 257 if (examTypeId == 0 || examTypeId == "") {258 $currItem.next(".ets").remove();259 return;260 }261 262 $.post(skeleton.option.root + "/skeleton/getExamTypes.do", {"parentId": examTypeId}, function(data) {263 if (data.length == 0) {264 $currItem.next(".ets").remove();265 return;266 }267 if ($currItem.next(".ets").length == 0) {268 $("#" + skeleton.option.et.parent).append("<span class='ets'><label>åèè¯ç±»åï¼ </label><select>"269 + "<option value=\"0\">请éæ©</option></select></span>");270 }271 272 var $select = $currItem.next(".ets").children("select");273 $select.children("option:gt(0)").remove();274 for (var i=0; i < data.length; i++) {275 var item = data[i];276 $select.append("<option value=\"" + item.id + "\">" + item.name + "</option>");277 }278 $select.bind("change", skeleton.onExamTypeChange);279 });280};281skeleton.clearClasslevels = function() {282 skeleton.clearDisciplines();283 skeleton.clearOption( skeleton.option.l.id);284};285skeleton.clearDisciplines = function() {286 skeleton.clearVolumes(); // æ¸
é¤åå287 skeleton.clearKnowledges(); // æ¸
é¤ç¥è¯ç¹288 skeleton.clearTeacherCatalogs();289 skeleton.clearOption( skeleton.option.d.id);290 if (skeleton.option.d.clear != "") {291 skeleton.option.d.clear();292 }293};294skeleton.clearVolumes = function() {295 skeleton.clearChapters();296 skeleton.clearOption( skeleton.option.v.id);297};298skeleton.clearChapters = function() {299 skeleton.clearOption( skeleton.option.ch.id);300};301skeleton.clearKnowledges = function() {302 skeleton.clearChildKnSelects();//æ¸
é¤åç¥è¯ç¹select303 skeleton.clearOption( skeleton.option.kn.id);304};305skeleton.clearTeacherCatalogs = function() {306 skeleton.clearChildTcSelects();307 skeleton.clearOption( skeleton.option.tc.id);308};309skeleton.obtainClasslevels = function() {310 var semesterId = $("#" + skeleton.option.se.id).val();311 if (semesterId == 0) return;312 $.post(skeleton.option.root + "/skeleton/getClasslevels.do", {"semesterId": semesterId}, function(data) {313 skeleton.appendOptions(skeleton.option.l.id, data, "classLevelName");314 });315};316skeleton.obtainDisciplines = function() {317 var classlevelId = $("#" + skeleton.option.l.id).val();318 if (classlevelId == 0) return;319 $.post(skeleton.option.root + "/skeleton/getDisciplines.do", {"classlevelId": classlevelId}, function(data) {320 skeleton.appendOptions(skeleton.option.d.id, data, "disciplineName");321 });322};323//è·ååå324skeleton.obtainVolumes = function() {325 var classlevelId = $("#" + skeleton.option.l.id).val();326 var disciplineId = $("#" + skeleton.option.d.id).val();327 if (classlevelId == 0 || disciplineId == 0) return;328 $.post(skeleton.option.root + "/skeleton/getVolumes.do", {"classlevelId": classlevelId, "disciplineId": disciplineId}, function(data) {329 skeleton.appendOptions(skeleton.option.v.id, data, "volumeName");330 });331};332//è·åç« è333skeleton.obtainChapters = function() {334 var volumeId = $("#" + skeleton.option.v.id).val();335 if (volumeId == 0 || volumeId == "") return;336 $.post(skeleton.option.root + "/skeleton/getChapters.do", {"volumeId": volumeId}, function(data) {337 skeleton.appendOptions(skeleton.option.ch.id, data, "chapterName");338 });339};340skeleton.obtainKnowledges = function() {341 var semesterId = $("#" + skeleton.option.se.id).val();342 var disciplineId = $("#" + skeleton.option.d.id).val();343 if (semesterId == 0 || disciplineId == 0 || semesterId == "" || disciplineId == "") return;344 $.post(skeleton.option.root + "/skeleton/getRootKnowledges.do", 345 {"semesterId": semesterId, "disciplineId": disciplineId},346 function(data) {347 skeleton.appendOptions(skeleton.option.kn.id, data, "knowledgeName");348 }349 );350};351skeleton.obtainTeachCatalogs = function() {352 var semesterId = $("#" + skeleton.option.se.id).val();353 var disciplineId = $("#" + skeleton.option.d.id).val();354 if (semesterId == 0 || disciplineId == 0 || semesterId == "" || disciplineId == "") return;355 $.post(skeleton.option.root + "/skeleton/getRootTeachCatalogs.do", 356 {"semesterId": semesterId, "disciplineId": disciplineId},357 function(data) {358 skeleton.appendOptions(skeleton.option.tc.id, data, "catalogName");359 }360 );361};362skeleton.obtainInfosByDiscipline = function() {363 var semesterId = $("#" + skeleton.option.se.id).val();364 var classlevelId = $("#" + skeleton.option.l.id).val();365 var disciplineId = $("#" + skeleton.option.d.id).val();366 if (semesterId == 0 || semesterId == "" 367 || classlevelId == 0 || classlevelId == ""368 || disciplineId == 0 || disciplineId == "") return;369 var needVolume = false;370 var needKnowledge = false;371 var needTeachCatalog = false;372 if (skeleton.option.v.id != "") needVolume = true;373 if (skeleton.option.kn.id != "") needKnowledge = true;374 if (skeleton.option.tc.id != "") needTeachCatalog = true;375 var teachCatalogType = skeleton.option.tc.type;376 $.post(skeleton.option.root + "/skeleton/getInfosByDiscipline.do", 377 {"semesterId": semesterId, "classlevelId": classlevelId, "disciplineId": disciplineId, 378 "needVolume" : needVolume, "needKnowledge" : needKnowledge,379 "needTeachCatalog": needTeachCatalog, "type": teachCatalogType},380 function(data) {381 var volumes = data.volumes;382 if (skeleton.option.v.id != "" && volumes != undefined && volumes.length > 0) {383 skeleton.appendOptions(skeleton.option.v.id, volumes, "volumeName");384 }385 386 var knowledges = data.knowledges;387 if (skeleton.option.kn.id != "" && knowledges != undefined && knowledges.length > 0) {388 skeleton.appendOptions(skeleton.option.kn.id, knowledges, "knowledgeName");389 }390 391 var teachCatalogs = data.teachCatalogs;392 if (skeleton.option.tc.id != "" && teachCatalogs != undefined && teachCatalogs.length > 0) {393 skeleton.appendOptions(skeleton.option.tc.id, teachCatalogs, "catalogName");394 }395 }396 );397};398skeleton.obtainChildKnowledges = function(knowledgeId) {399 $.post(skeleton.option.root + "/skeleton/getKnowledges.do", {"parentId": knowledgeId}, function(data) {400 if (data.length == 0) return;401 var appendId = "knowledge" + $(".kns").length;402 $("#" + skeleton.option.kn.parent).append("<label>åç¥è¯ç¹ï¼ </label><select id=\""403 + appendId404 + "\" class='kns'><option value=\"\">请éæ©</option></select>");405 skeleton.appendOptions( appendId, data);406 $("#" + appendId).bind("change", skeleton.onKnowledgeChange);407 });408};409skeleton.obtainChildTeachCatalogs = function(teachCatalogId) {410 $.post(skeleton.option.root + "/skeleton/getTeachCatalogs.do", {"parentId": teachCatalogId}, function(data) {411 if (data.length == 0) return;412 var appendId = "teachCatalog" + $(".tcs").length;413 $("#" + skeleton.option.tc.parent).append("<label>åç±»åï¼ </label><select id=\""414 + appendId415 + "\" class='tcs'><option value=\"\">请éæ©</option></select>");416 skeleton.appendOptions( appendId, data);417 $("#" + appendId).bind("change", skeleton.onTeachCatalogChange);418 });419};420skeleton.clearChildKnSelects = function() {421 $(".kns").remove();422};423skeleton.clearChildTcSelects = function() {424 $(".tcs").remove();425};426skeleton.appendOptions = function(_selectId, _items, proname, _def) {427 if (proname == undefined) proname = "name";428 for (var i=0; i < _items.length; i++) {429 var item = _items[i];430 $("#" + _selectId).append("<option value=\"" + item.id + "\" " + (item.id==_def ? "selected":"") + ">" + item[proname] + "</option>");431 }432};433skeleton.clearOption = function(_id) {434 if (_id == undefined || _id == "") return;435 436 $("#" + _id + " option:gt(0)").remove();//å é¤é¤äºâ请éæ©âçå
¶å®ææ项...
images.js
Source:images.js
1// display all users collections2import { Mongo } from 'meteor/mongo';3//export const Usrs = Accounts.users;//Accounts.users;4//export const Tasks = new Mongo.Collection('tasks');//Accounts.users;5 Images = new Mongo.Collection('images');6 Rating = new Mongo.Collection('rating');7 Docs = new Mongo.Collection('docs');8 songs = new Mongo.Collection('songs');9 blogs = new Mongo.Collection('blogs');10 venues = new Mongo.Collection('venues');11 Calendars = new Mongo.Collection('calendars');12 chat = new Mongo.Collection('chat');13/*Calendars.insert({14 "_id": "myCalendarId2",15 events: [ {"bandname" : "britneySpears",16 "start":"2016-09-26",17 "end": "2016-09-26",18 "title": "all day events",19 "venueId":"venue 1",20 "owner": "agent1" } ]21 });*/22 Notifications = new Mongo.Collection('notifications');23 Users = Meteor.users;24/*Meteor.publish('images', function(){ 25 return Images.find({}, 26 { fields: {_id:1, imageurl:1, time: 1, uploadedBy: 1,imageName: 1, imageFolder: 1 } } ); });*/27Meteor.publish('images', function(){ return Images.find({}); });28Meteor.publish('docs', function(){ return Docs.find({}); });29Meteor.publish('rating', function(){ return Rating.find({}); });30Meteor.publish('songs', function(){ return songs.find({}); });31Meteor.publish('blogs', function(){ return blogs.find({}); });32Meteor.publish('venues', function(){ return venues.find({}); });33Meteor.publish('Calendars', function(){ return Calendars.find({}); });34Meteor.publish('chat', function(){ return chat.find({}); });35Meteor.publish('notifications', function(){ return Notifications.find({},{_id: 1, owner: 1, reciever: 1 , type: 1, status :1 ,time :1}); });36Meteor.publish('USERS', function(){ 37 return Users.find({}, { fields: {_id:1, profile: 1 , emails: 1, username: 1 , agent: 1, whishlist: 1} });38 //return Users.find({});39 });40Meteor.methods({41addAgent: function(obj)42{43//Images.insert({imageName: "imageName", imageurl: "imageurl", imageFolder: "imageFolder"});44//Photos.insert({imageName: "imageName", imageurl: "imageurl", imageFolder: "imageFolder"});45//var agent = { "agentId": recieverId,"agentName": recieverName,"time": timeStamp };46//Users.upsert({"_id": obj.artistId}, {$set : { "agent.id": obj.agentId, "agent.name":obj.agentName, "agent.time":obj.time} });47Users.upsert({"_id": obj.artistId}, {$set : { agent: { "id" : obj.agentId, "name" : obj.agentName , "time" : obj.time} } });48return ;49},50updateFirstname: function(obj)51{52 Users.update({"_id": obj.id}, {$set : {"profile.firstname" : obj.firstname} });53 Users.update({"username": "jazzBand008"}, {$set : {"profile.salary" : 100} });54 Users.update({"username": "GeomyBand"}, {$set : {"profile.salary" : 100} });55 Users.update({"username": "weddingBand006"}, {$set : {"profile.salary" : 100} });56 return ;57},58updatelastname: function(obj)59{60 Users.update({"_id": obj.id}, {$set : { "profile.lastname" : obj.lastname } });61 return;62},63uploadavatar: function(obj)64{65 Users.update({"_id": obj.id}, {$set : { "profile.avatar" : obj.url } });66 return;67},68uploadcover: function(obj)69{70 Users.update({"_id": obj.id}, {$set : { "profile.cover" : obj.url } });71 return;72},73updatestatus: function(obj)74{75 Users.update({"_id": obj.id}, {$set : { "profile.Status" : obj.status } });76 return;77},78updateallowchat: function(obj)79{80 Users.update({"_id": obj.id}, {$set : { "profile.chatFunctionnality" : obj.chat } });81 return;82},83updateoprational:function(obj) {84 Users.update({"_id": obj.id}, {$set : { "profile.oprational" : obj.operational } });85 return;86},87updatesalary: function(obj)88{89 Users.update({"_id": obj.id}, {$set : { "profile.salary" :parseInt( obj.salary) } });90 return;91},92incremetRating: function(obj)93{94 if( Rating.find({"bandId": obj.bandId , "userId": obj.userId}).count()> 0)95 {96Rating.update({"bandId": obj.bandId, "userId": obj.userId },{$set: {"ratingvalue": obj.ratingvalue}});97 console.log('justupdate the old rating value');98 }99 else100 {101 //Rating.insert({"bandId": obj.band, "userId": userId, "username": username , "ratingvalue": ratingvalue});102Rating.insert({"bandId": obj.bandId, "userId": obj.userId, "username" : obj.userId, "ratingvalue": obj.ratingvalue});103 }104 return;105},106updatesocialpage: function(obj)107{108 Users.update({"_id": obj.id}, {$set : { "profile.socialpage" : obj.socialpage } });109 console.log('socialpage :' + obj.socialpage);110 return;111},112updatebandname:function(obj)113{114 Users.update({"_id": obj.id}, {$set : { "profile.bandName" : obj.bandname } });115 return;116}117,118updatebirthdate: function(obj)119{120 Users.update({"_id": obj.id}, {$set : { "profile.birthdate" : obj.birthdate } });121 return;122},123updateyoutubevideo: function(obj)124{125 Users.update({"_id": obj.id}, {$set : { "profile.youtubevideourl" : obj.youtubevideourl } });126 return true;127},128updatephonenumber:function(obj)129{130 Users.update({"_id": obj.id}, {$set : { "profile.phoneNumber" : obj.phoneNumber } });131 return;132},133updategender:function(obj)134{135 Users.update({"_id": obj.id}, {$set : { "profile.gender" : obj.gender } });136 return;137},138updatetype:function(id)139{140 Users.update({"_id": id}, {$set : { "profile.type" : "costumer" } });141 return;142},143updatebandtype:function(obj)144{145 Users.update({"_id": obj.id}, {$set : { "profile.bandtype" : obj.bandtype } });146 return true;147}, 148updatebandsets: function(obj)149{150 Users.update({"_id": obj.id}, {$set : { "profile.sets" : obj.bandsets } });151 return true;152}, 153savebandmember: function(obj)154{155 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });156 Users.update({"_id": obj.id}, {$push : { "profile.members" : {"id" : obj.itemid, "role": obj.itemname} } });157 158 return true;159},160addfriend: function(obj)161{162 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });163 Users.update({"_id": obj.recieverId}, {$push : { "profile.friends" : {"id" : obj.senderId, "name": obj.senderName} } });164 Users.update({"_id": obj.senderId}, {$push : { "profile.friends" : {"id" : obj.recieverId, "name": obj.recieverName} } });165 166 return true;167},168savewhishlistitem: function(obj)169{170 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });171 Users.update({"_id": obj.id}, {$push : { "whishlist" : {"id" : obj.itemid, "username": obj.itemname} } });172 173 return true;174},175addDocument: function(obj)176{ 177var docId = Docs.insert({'uploadedBy' : obj.uploadedBy, "title": obj.docname, "timeStamp": obj.timeStamp, "url": obj.url });178},179removeDocument: function(id)180{ 181 Docs.remove({'_id' : id });182},183addEvent: function(obj)184{ 185//var eventId = Calendars.insert({"events" : [ {"title" : obj.title, "type": obj.type, "start" : obj.start, "end" : obj.end , "ownerId" : obj.ownerId, "bandId" : obj.bandId } ]});186var eventId = Calendars.insert({"title" : obj.title, "type": obj.type, "start" : obj.start, "end" : obj.end , "ownerId" : obj.ownerId, "bandId" : obj.bandId });187if(eventId)188{189var venueid = venues.insert({ eventId : eventId, postcode : obj.postcode, regionname : obj.regionname, cityname: obj.cityname , address: obj.address, buildingname: obj.buildingname });190console.log('venue id : ' + venueid);191return eventId;192}193},194sendMessage: function(obj)195{ 196console.log('save chat into database ...'); 197var messageId = chat.insert({"senderId" : obj.senderId, "recieverId": obj.recieverId, "timeStamp" : obj.timeStamp, "content" : obj.content , "status" : obj.status });198return messageId;199},200updatemessageStatus: function(id)201{202 chat.update({"_id" : id},{$set : {"status" : "viewed"}});203},204updateevent : function(obj)205{206console.log(obj);207var eventId = Calendars.update({"_id" : obj.id }, { $set : { "title" : obj.title , "start" : obj.start, "end" : obj.end } }); 208//var eventId = Calendars.update({"_id" : obj.id }, { $set : { "title" : obj.title, "start" : obj.start, "end" : obj.end } });209if(eventId)210{211var venueid = venues.update({ "eventId" : obj.id } , { $set :{ "postcode" : obj.postcode, "regionname" : obj.regionname, "cityname": obj.cityname , "address": obj.address, "buildingname": obj.buildingname } });212console.log('updated venue id : ' + venueid);213return venueid;214}215},216/*updateevent: function(id)217{ 218//var eventId = Calendars.update({"_id" : obj.id }, { $set : { "title" : obj.title , "start" : obj.start, "end" : obj.end } }); 219//var eventId = Calendars.update({"_id" : obj.id }, { $set : { "title" : obj.title, "start" : obj.start, "end" : obj.end } });220//if(eventId)221//{222 //console.log("obj from updateevent " + id);223 //console.log(obj);224//var venueid = venues.update({ "eventId" : obj.id, postcode : obj.postcode, regionname : obj.regionname, cityname: obj.cityname , address: obj.address, buildingname: obj.buildingname });225//console.log('updated venue id : ' + venueid);226//return ;227//}228},*/229removeimage : function(id)230{231console.log('image removed' + id);232var imageid = Images.remove({"_id": id});233console.log('venue removed' + imageid);234return imageid;235},236removeAlbum : function(albumname)237{238console.log('image removed' + albumname);239var imageid = Images.remove({"imageFolder": albumname});240console.log('venue removed' + albumname);241return albumname;242},243removeevent : function(id)244{245 eventId = Calendars.remove({"_id" : id});246console.log('event removed' + eventId);247var venueid = venues.remove({"eventId": id});248console.log('venue removed' + venueid);249return venueid;250},251addComment: function(obj)252{253 var blog = blogs.findOne({"_id": obj.id});254 var id = 0;255 if( blog.comments.length > 0)256 id = blog.comments[blog.comments.length - 1].id + 1 ;257blogs.update({"_id": obj.id}, {$push : { "comments" : {"id": id, "author" : obj.author, "content": obj.content, "time" :obj.timeStamp} } });258}, 259saverepertoire: function(obj)260{261 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });262 Users.update({"_id": obj.id}, {$push : { "profile.repertoire" : {"songname" : obj.songname, "singername": obj.singername} } });263 264 return true;265}, 266savehighlight:function(obj){267 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });268 Users.update({"_id": obj.id}, {$push : { "profile.highlights" : {"id" : obj.highlightId, "content": obj.highlightcontent} } });269 270 return true;271},272savepostecode: function(obj){273 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });274 Users.update({"_id": obj.id}, {$set : { "profile.address.postecode" : obj.postecode } });275 276 return true;277},278savecity: function(obj){279 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });280 Users.update({"_id": obj.id}, {$set : { "profile.address.city" : obj.city } });281 282 return true;283},284saveaddress:function(obj){285 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });286 Users.update({"_id": obj.id}, {$set : { "profile.address.address" : obj.address } });287 return true;288},289saveregion: function(obj){290 //Users.update({"_id": obj.id}, {$push : { "profile.members" : {"memeber name" : obj.membername , "role": obj.memberrole} } });291 Users.update({"_id": obj.id}, {$set : { "profile.address.region" : obj.region } });292 293 return true;294},295removememeber: function(obj)296{297 Users.update({"_id": obj.id} , { $pull : { "profile.members" : {"name": obj.membername, "role" :obj.memberrole } } });298},299removewishlistitem: function(obj)300{301 Users.update({"_id": obj.id} , { $pull : { "whishlist" : {"id": obj.itemid} } });302}, 303removecomment: function(obj)304{305 console.log(obj.blogid + " comment id " + obj.commentid);306 blogs.update({"_id": obj.blogid} , { $pull : { "comments" : {"id": parseInt(obj.commentid) } } });307}, 308removesonglist: function(obj)309{310 Users.update({"_id": obj.id} , { $pull : { "profile.repertoire" : {"songname": obj.songname, "singername" :obj.singername } } });311},312removeHighlight: function(obj)313{314 Users.update({"_id": obj.id} , { $pull : { "profile.highlights" : {"id": obj.highlightId } } });315},316addBlog: function( obj){317return blogs.insert({318 title: obj.title,319 content: obj.content,320 imageurl: obj.imageurl,321 time: obj.timeStamp,322 author: obj.author /*, 323 file : obj.file,*/324 });325return "inserted";326//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });327},328addImage: function( obj){329return Images.insert({330 imageurl: obj.imageurl,331 uploadedBy: obj.uploadedBy,332 timeStamp: obj.timeStamp,333 imageName: obj.imageName , 334 imageFolder : obj.imageFolder,335 });336return "inserted";337//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });338},339addSong: function( obj){340return songs.insert({341 songurl: obj.songurl,342 uploadedBy: obj.uploadedBy,343 timeStamp: obj.timeStamp,344 songname: obj.songname , 345 duration : obj.duration346 });347return "inserted";348//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });349},350addNotification: function(obj){351 Notifications.insert({ "ownerId" : obj.ownerId,352 "ownerName" : obj.ownerName,353 "recieverId": obj.recieverId ,354 "recieverName": obj.recieverName ,355 "time": obj.time,356 "type": obj.typ , 357 "status" : obj.status,358 "viewed" : obj.viewed359 });360 if(obj.status === "accepted")361 Notifications.update({ "recieverId" : obj.ownerId,362 "ownerId": obj.recieverId }, { $set : {"status" : "accept"} });363return "inserted";364//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });365},366rejectNotification: function(obj){367 Notifications.insert({ "ownerId" : obj.ownerId,368 "ownerName" : obj.ownerName,369 "recieverId": obj.recieverId ,370 "recieverName": obj.recieverName ,371 "time": obj.time,372 "type": obj.typ , 373 "status" : obj.status,374 "viewed" : obj.viewed375 });376 if(obj.status === "rejected")377 Notifications.update({ "recieverId" : obj.ownerId,378 "ownerId": obj.recieverId }, { $set : {"status" : "reject"} });379return "rejected";380//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });381},382removeNotification: function(id){383 Notifications.remove({ "_id" : id });384return "removed";385//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });386},387 viewedNotification: function(id){388 console.log('id : '+ id);389 Notifications.update({"_id" : id }, {$set : { "viewed" : true} });390return "viewed"; 391//Users.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });392},393display: function(){394 //return "hello";395return Users.find({396 /*$or:[397 {"profile.type" : "band"},398 {"profile.type" : "artist"},399 ]*/400 });401},402modify: function(name){403Images.upsert({"_id": "hnCoTgyqB84894uCz"}, {$set : { "agent.name":name} });404},405});406 407/*Meteor.setInterval(function(){408Usrs.forEach( function(USR){409console.log(USR._id);410okokokif (USR.status.online === false ) {411Meteor.users.update( {"_id": USR._id}, { $set : {"services.resume.loginTokens": [] } } , { multi: true });412 console.log("deconnected " + USR._id);413 };414});415}, 1000*3600*12);*/416//console.log('tasks are the next ...');...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!