Best JavaScript code snippet using fast-check-monorepo
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 ...');...
profile.js
Source:profile.js
...124function submitValidNewUser() {125 126 validatePhoneNumber('shipToPhoneRequired', 'shipToContactNumber', 'shipToCountryCode', 'shipToAreaCode');127 validatePhoneNumber('billToPhoneRequired', 'billToContactNumber', 'billToCountryCode', 'billToAreaCode');128 if (jQuery("#newUserForm").valid()) {129 document.getElementById('newUserForm').submit();130 }131}132function submitValidEditUser() {133 document.getElementById('editUserForm').submit();134}135function submitValidPostalAddress() {136 document.getElementById('createPostalAddressForm').submit();137}138function setUserNameFromEmail() {139 if (document.getElementById('username').value == "") {140 document.getElementById('username').value = document.getElementById('emailAddress').value;141 }142}143function useShippingAddressAsBillingToggle() {144 if (document.getElementById('useShippingAddressForBilling').checked) {145 document.getElementById('billToAddress1').value = document.getElementById('shipToAddress1').value;146 document.getElementById('billToAddress2').value = document.getElementById('shipToAddress2').value;147 document.getElementById('billToCity').value = document.getElementById('shipToCity').value;148 document.getElementById('billToCountryGeoId').value = document.getElementById('shipToCountryGeoId').value;149 getAssociatedStateList('billToCountryGeoId', 'billToStateProvinceGeoId', 'advice-required-billToStateProvinceGeoId', 'billToStates');150 document.getElementById('billToStateProvinceGeoId').value = document.getElementById('shipToStateProvinceGeoId').value;151 document.getElementById('billToPostalCode').value = document.getElementById('shipToPostalCode').value;152 document.getElementById('billToAddress1').disabled = true ;153 document.getElementById('billToAddress2').disabled = true ;154 document.getElementById('billToCity').disabled = true ;155 document.getElementById('billToCountryGeoId').disabled = true ;156 document.getElementById('billToStateProvinceGeoId').disabled = true ;157 document.getElementById('billToPostalCode').disabled = true;158 copyShipToBillAddress();159 hideErrorMessage();160 } else {161 stopObservingShipToBillAddress();162 document.getElementById('billToAddress1').disabled = false ;163 document.getElementById('billToAddress2').disabled = false ;164 document.getElementById('billToCity').disabled = false ;165 document.getElementById('billToCountryGeoId').disabled = false ;166 document.getElementById('billToStateProvinceGeoId').disabled = false ;167 document.getElementById('billToPostalCode').disabled = false;168 }169}170function getServerError(data) {171 var serverErrorHash = [];172 var serverError = "";173 if (data._ERROR_MESSAGE_LIST_ != undefined) {174 serverErrorHash = data._ERROR_MESSAGE_LIST_;175 var CommonErrorMessage2 = getJSONuiLabel("CommonUiLabels", "CommonErrorMessage2");176 showErrorAlert(CommonErrorMessage2, serverErrorHash);177 jQuery.each(serverErrorHash, function(error, message){178 if (error != undefined) {179 serverError += message;180 }181 });182 if (serverError == "") {183 serverError = serverErrorHash;184 }185 }186 if (data._ERROR_MESSAGE_ != undefined) {187 serverError += data._ERROR_MESSAGE_;188 }189 return serverError;190}191function doAjaxRequest(formId, errorId, popupId, requestUrl) {192 if (jQuery("#" + formId).valid()) { 193 jQuery.ajax({194 url: requestUrl,195 type: 'POST',196 async: false,197 data: jQuery("#" + formId).serialize(),198 success: function(data) {199 var serverError = getServerError(data);200 if (serverError != "") {201 jQuery("#" + errorId).fadeIn("fast");202 jQuery("#" + popupId).fadeIn("fast");203 jQuery("#" + errorId).html(serverError);204 } else {205 jQuery("#" + errorId).fadeIn("slow");206 jQuery("#" + popupId).fadeIn("slow");...
directors.js
Source:directors.js
1'use strict';2var _ = require('underscore');3var directors = [{4 "id": 1,5 "name": "Alexander Payne"6}, {7 "id": 2,8 "name": "Sydney Pollack"9}, {10 "id": 3,11 "name": "George Cukor"12}, {13 "id": 4,14 "name": "Spike Jonze"15}, {16 "id": 5,17 "name": "Atom Egoyan"18}, {19 "id": 6,20 "name": "Michael Curtiz"21}, {22 "id": 7,23 "name": "Paul Schrader"24}, {25 "id": 8,26 "name": "John Huston"27}, {28 "id": 9,29 "name": "Luis Bunuel"30}, {31 "id": 10,32 "name": "Werner Herzog"33}, {34 "id": 11,35 "name": "Steven Spielberg"36}, {37 "id": 12,38 "name": "Jim Abrahams"39}, {40 "id": 13,41 "name": "John Musker"42}, {43 "id": 14,44 "name": "Sergei Eisenstein"45}, {46 "id": 15,47 "name": "Martin Scorsese"48}, {49 "id": 16,50 "name": "Arthur Penn"51}, {52 "id": 17,53 "name": "James Cameron"54}, {55 "id": 18,56 "name": "Joseph L. Mankiewicz"57}, {58 "id": 19,59 "name": "Pedro Almodovar"60}, {61 "id": 20,62 "name": "Lewis Milestone"63}, {64 "id": 21,65 "name": "Douglas Sirk"66}, {67 "id": 22,68 "name": "Robert Rossen"69}, {70 "id": 23,71 "name": "Alan J. Pakula"72}, {73 "id": 24,74 "name": "Milos Forman"75}, {76 "id": 25,77 "name": "Federico Fellini"78}, {79 "id": 26,80 "name": "Jean-Pierre Jeunet"81}, {82 "id": 27,83 "name": "Elia Kazan"84}, {85 "id": 28,86 "name": "Wim Wenders"87}, {88 "id": 29,89 "name": "George Lucas"90}, {91 "id": 30,92 "name": "Vincente Minnelli"93}, {94 "id": 31,95 "name": "Arthur Hiller"96}, {97 "id": 32,98 "name": "Chris Smith"99}, {100 "id": 33,101 "name": "Alejandro Gonzalez Inarritu"102}, {103 "id": 34,104 "name": "Anatole Litvak"105}, {106 "id": 35,107 "name": "Otto Preminger"108}, {109 "id": 36,110 "name": "Guy Green"111}, {112 "id": 37,113 "name": "John Cromwell"114}, {115 "id": 38,116 "name": "Woody Allen"117}, {118 "id": 39,119 "name": "Billy Wilder"120}, {121 "id": 40,122 "name": "Francis Ford Coppola"123}, {124 "id": 41,125 "name": "Ron Howard"126}, {127 "id": 42,128 "name": "Robert Duvall"129}, {130 "id": 43,131 "name": "Robert Bresson"132}, {133 "id": 44,134 "name": "Andrzej Wajda"135}, {136 "id": 45,137 "name": "Jean Vigo"138}, {139 "id": 46,140 "name": "Louis Malle"141}, {142 "id": 47,143 "name": "Michelangelo Antonioni"144}, {145 "id": 48,146 "name": "Leo McCarey"147}, {148 "id": 49,149 "name": "Gabriel Axel"150}, {151 "id": 50,152 "name": "Robert Zemeckis"153}, {154 "id": 51,155 "name": "John Sturges"156}, {157 "id": 52,158 "name": "Terrence Malick"159}, {160 "id": 53,161 "name": "Howard Hawks"162}, {163 "id": 54,164 "name": "Sam Peckinpah"165}, {166 "id": 55,167 "name": "James Algar"168}, {169 "id": 56,170 "name": "John D. Hancock"171}, {172 "id": 57,173 "name": "Edward F. Cline"174}, {175 "id": 58,176 "name": "Barbet Schroeder"177}, {178 "id": 59,179 "name": "Stanley Kubrick"180}, {181 "id": 60,182 "name": "Joel Coen"183}, {184 "id": 61,185 "name": "Gillo Pontecorvo"186}, {187 "id": 62,188 "name": "Eric Rohmer"189}, {190 "id": 63,191 "name": "Jasmin Dizdar"192}, {193 "id": 64,194 "name": "Kirk Wise"195}, {196 "id": 65,197 "name": "Francois Truffaut"198}, {199 "id": 66,200 "name": "Tim Burton"201}, {202 "id": 67,203 "name": "Julian Schnabel"204}, {205 "id": 68,206 "name": "Milcho Manchevski"207}, {208 "id": 69,209 "name": "Hal Ashby"210}, {211 "id": 70,212 "name": "William Wyler"213}, {214 "id": 71,215 "name": "Martin Brest"216}, {217 "id": 72,218 "name": "Vittorio De Sica"219}, {220 "id": 73,221 "name": "Lawrence Kasdan"222}, {223 "id": 74,224 "name": "Mario Monicelli"225}, {226 "id": 75,227 "name": "Fritz Lang"228}, {229 "id": 76,230 "name": "Campbell Scott"231}, {232 "id": 77,233 "name": "Samuel Fuller"234}, {235 "id": 78,236 "name": "John Schlesinger"237}, {238 "id": 79,239 "name": "Mike Nichols"240}, {241 "id": 80,242 "name": "Alfred Hitchcock"243}, {244 "id": 81,245 "name": "Alan Parker"246}, {247 "id": 82,248 "name": "Michael Powell"249}, {250 "id": 83,251 "name": "Marcel Camus"252}, {253 "id": 84,254 "name": "Bruce Beresford"255}, {256 "id": 85,257 "name": "Mel Brooks"258}, {259 "id": 86,260 "name": "Paul Greengrass"261}, {262 "id": 87,263 "name": "David Lynch"264}, {265 "id": 88,266 "name": "Paul Mazursky"267}, {268 "id": 89,269 "name": "Jean-Pierre Melville"270}, {271 "id": 90,272 "name": "Paul Thomas Anderson"273}, {274 "id": 91,275 "name": "Oliver Stone"276}, {277 "id": 92,278 "name": "Claude Chabrol"279}, {280 "id": 93,281 "name": "Kimberly Peirce"282}, {283 "id": 94,284 "name": "John Singleton"285}, {286 "id": 95,287 "name": "Terry Gilliam"288}, {289 "id": 96,290 "name": "Luigi Comencini"291}, {292 "id": 97,293 "name": "John Hughes"294}, {295 "id": 98,296 "name": "Peter Yates"297}, {298 "id": 99,299 "name": "Lars von Trier"300}, {301 "id": 100,302 "name": "Jean-Luc Godard"303}, {304 "id": 101,305 "name": "David Lean"306}, {307 "id": 102,308 "name": "Errol Morris"309}, {310 "id": 103,311 "name": "James L. Brooks"312}, {313 "id": 104,314 "name": "Joe Berlinger"315}, {316 "id": 105,317 "name": "Steve Rash"318}, {319 "id": 106,320 "name": "Ron Shelton"321}, {322 "id": 107,323 "name": "Joshua Logan"324}, {325 "id": 108,326 "name": "George Roy Hill"327}, {328 "id": 109,329 "name": "Neil Jordan"330}, {331 "id": 110,332 "name": "Carlos Diegues"333}, {334 "id": 111,335 "name": "Max Ophuls"336}, {337 "id": 112,338 "name": "Bob Fosse"339}, {340 "id": 113,341 "name": "Edward Dmytryk"342}, {343 "id": 114,344 "name": "Herbert Ross"345}, {346 "id": 115,347 "name": "Fernando Trueba"348}, {349 "id": 116,350 "name": "Victor Fleming"351}, {352 "id": 117,353 "name": "Richard Brooks"354}, {355 "id": 118,356 "name": "Frank Lloyd"357}, {358 "id": 119,359 "name": "Thomas Vinterberg"360}, {361 "id": 120,362 "name": "Wayne Wang"363}, {364 "id": 121,365 "name": "Hugh Hudson"366}, {367 "id": 122,368 "name": "Don Siegel"369}, {370 "id": 123,371 "name": "Rob Marshall"372}, {373 "id": 124,374 "name": "Nick Park"375}, {376 "id": 125,377 "name": "Jean Renoir"378}, {379 "id": 126,380 "name": "Roman Polanski"381}, {382 "id": 127,383 "name": "Claire Denis"384}, {385 "id": 128,386 "name": "Lasse Hallström"387}, {388 "id": 129,389 "name": "King Vidor"390}, {391 "id": 130,392 "name": "Orson Welles"393}, {394 "id": 131,395 "name": "Bertrand Tavernier"396}, {397 "id": 132,398 "name": "Abbas Kiarostami"399}, {400 "id": 133,401 "name": "Amy Heckerling"402}, {403 "id": 134,404 "name": "Michael Apted"405}, {406 "id": 135,407 "name": "Daniel Mann"408}, {409 "id": 136,410 "name": "Bernardo Bertolucci"411}, {412 "id": 137,413 "name": "Stuart Rosenberg"414}, {415 "id": 138,416 "name": "Rowland V. Lee"417}, {418 "id": 139,419 "name": "George Seaton"420}, {421 "id": 140,422 "name": "Mikhail Kalatozov"423}, {424 "id": 141,425 "name": "Ingmar Bergman"426}, {427 "id": 142,428 "name": "Terry Zwigoff"429}, {430 "id": 143,431 "name": "Zoltan Korda"432}, {433 "id": 144,434 "name": "George Abbott"435}, {436 "id": 145,437 "name": "Luchino Visconti"438}, {439 "id": 146,440 "name": "Mike Newell"441}, {442 "id": 147,443 "name": "Stephen Frears"444}, {445 "id": 148,446 "name": "Sidney Lumet"447}, {448 "id": 149,449 "name": "Nikita Mikhalkov"450}, {451 "id": 150,452 "name": "Edmund Goulding"453}, {454 "id": 151,455 "name": "Jim McBride"456}, {457 "id": 152,458 "name": "George Romero"459}, {460 "id": 153,461 "name": "Fred Zinnemann"462}, {463 "id": 154,464 "name": "Robert Wise"465}, {466 "id": 155,467 "name": "Blake Edwards"468}, {469 "id": 156,470 "name": "Phillip Noyce"471}, {472 "id": 157,473 "name": "Tim Robbins"474}, {475 "id": 158,476 "name": "Basil Dearden"477}, {478 "id": 159,479 "name": "David Cronenberg"480}, {481 "id": 160,482 "name": "Laslo Benedek"483}, {484 "id": 161,485 "name": "Jerzy Skolimowski"486}, {487 "id": 162,488 "name": "Michael Cimino"489}, {490 "id": 163,491 "name": "Stanley Kramer"492}, {493 "id": 164,494 "name": "John Boorman"495}, {496 "id": 165,497 "name": "Susan Seidelman"498}, {499 "id": 166,500 "name": "George Marshall"501}, {502 "id": 167,503 "name": "Henri-Georges Clouzot"504}, {505 "id": 168,506 "name": "John McTiernan"507}, {508 "id": 169,509 "name": "Barry Levinson"510}, {511 "id": 170,512 "name": "Robert Aldrich"513}, {514 "id": 171,515 "name": "Frank Oz"516}, {517 "id": 172,518 "name": "Alfred E. Green"519}, {520 "id": 173,521 "name": "Satyajit Ray"522}, {523 "id": 174,524 "name": "Jean-Jacques Beineix"525}, {526 "id": 175,527 "name": "Pietro Germi"528}, {529 "id": 176,530 "name": "Spike Lee"531}, {532 "id": 177,533 "name": "Rouben Mamoulian"534}, {535 "id": 178,536 "name": "Erick Zonca"537}, {538 "id": 179,539 "name": "Peter Greenaway"540}, {541 "id": 180,542 "name": "Ridley Scott"543}, {544 "id": 181,545 "name": "Ang Lee"546}, {547 "id": 182,548 "name": "John Sayles"549}, {550 "id": 183,551 "name": "Anthony Minghella"552}, {553 "id": 184,554 "name": "Yoshimitsu Morita"555}, {556 "id": 185,557 "name": "Chen Kaige"558}, {559 "id": 186,560 "name": "Todd Haynes"561}, {562 "id": 187,563 "name": "Zacharias Kunuk"564}, {565 "id": 188,566 "name": "Luc Besson"567}, {568 "id": 189,569 "name": "Marco Bellocchio"570}, {571 "id": 190,572 "name": "Peter Cattaneo"573}, {574 "id": 191,575 "name": "Kenji Mizoguchi"576}, {577 "id": 192,578 "name": "Agnes Varda"579}, {580 "id": 193,581 "name": "Sergio Leone"582}, {583 "id": 194,584 "name": "Robert Altman"585}, {586 "id": 195,587 "name": "John Ford"588}, {589 "id": 196,590 "name": "Preston Sturges"591}, {592 "id": 197,593 "name": "Sidney Gilliat"594}, {595 "id": 198,596 "name": "Michael Almereyda"597}, {598 "id": 199,599 "name": "Todd Solondz"600}, {601 "id": 200,602 "name": "Barbara Kopple"603}, {604 "id": 201,605 "name": "Elaine May"606}, {607 "id": 202,608 "name": "Ralph Bakshi"609}, {610 "id": 203,611 "name": "Hal Hartley"612}, {613 "id": 204,614 "name": "Akira Kurosawa"615}, {616 "id": 205,617 "name": "Lisa Cholodenko"618}, {619 "id": 206,620 "name": "Peter Hall"621}, {622 "id": 207,623 "name": "Steve James"624}, {625 "id": 208,626 "name": "Stephen Daldry"627}, {628 "id": 209,629 "name": "Nancy Savoca"630}, {631 "id": 210,632 "name": "Todd Field"633}, {634 "id": 211,635 "name": "Michael Mann"636}, {637 "id": 212,638 "name": "Mike Figgis"639}, {640 "id": 213,641 "name": "Norman Z. McLeod"642}, {643 "id": 214,644 "name": "Richard Thorpe"645}, {646 "id": 215,647 "name": "Alan Crosland"648}, {649 "id": 216,650 "name": "Claude Berri"651}, {652 "id": 217,653 "name": "Cameron Crowe"654}, {655 "id": 218,656 "name": "Bob Rafelson"657}, {658 "id": 219,659 "name": "Curtis Hanson"660}, {661 "id": 220,662 "name": "Ken Loach"663}, {664 "id": 221,665 "name": "Gianni Amelio"666}, {667 "id": 222,668 "name": "John Dahl"669}, {670 "id": 223,671 "name": "Charles Crichton"672}, {673 "id": 224,674 "name": "Penny Marshall"675}, {676 "id": 225,677 "name": "Alfonso Arau"678}, {679 "id": 226,680 "name": "Charles Walters"681}, {682 "id": 227,683 "name": "Gillian Armstrong"684}, {685 "id": 228,686 "name": "Tom DiCillo"687}, {688 "id": 229,689 "name": "Ken Annakin"690}, {691 "id": 230,692 "name": "Nicole Holofcener"693}, {694 "id": 231,695 "name": "Nicholas Hytner"696}, {697 "id": 232,698 "name": "Marcel Ophuls"699}, {700 "id": 233,701 "name": "Pete Docter"702}, {703 "id": 234,704 "name": "Norman Jewison"705}, {706 "id": 235,707 "name": "Frank Borzage"708}, {709 "id": 236,710 "name": "Albert Brooks"711}, {712 "id": 237,713 "name": "Elliott Nugent"714}, {715 "id": 238,716 "name": "Ildiko Enyedi"717}, {718 "id": 239,719 "name": "Jacques Tati"720}, {721 "id": 240,722 "name": "John Landis"723}, {724 "id": 241,725 "name": "Robert Benton"726}, {727 "id": 242,728 "name": "Irving Rapper"729}, {730 "id": 243,731 "name": "Victor Schertzinger"732}, {733 "id": 244,734 "name": "Donald Roos"735}, {736 "id": 245,737 "name": "Robert Redford"738}, {739 "id": 246,740 "name": "Harry Watt"741}, {742 "id": 247,743 "name": "Roberto Rossellini"744}, {745 "id": 248,746 "name": "Roger Michell"747}, {748 "id": 249,749 "name": "Jacques Doillon"750}, {751 "id": 250,752 "name": "Michael Radford"753}, {754 "id": 251,755 "name": "Alexander Korda"756}, {757 "id": 252,758 "name": "Quentin Tarantino"759}, {760 "id": 253,761 "name": "Krzysztof Kieslowski"762}, {763 "id": 254,764 "name": "Laurence Olivier"765}, {766 "id": 255,767 "name": "Michael Moore"768}, {769 "id": 256,770 "name": "Franco Zeffirelli"771}, {772 "id": 257,773 "name": "Wes Anderson"774}, {775 "id": 258,776 "name": "Jerry Zucker"777}, {778 "id": 259,779 "name": "David Maysles"780}, {781 "id": 260,782 "name": "Karel Reisz"783}, {784 "id": 261,785 "name": "Mike Leigh"786}, {787 "id": 262,788 "name": "Joseph Losey"789}, {790 "id": 263,791 "name": "Jonathan Glazer"792}, {793 "id": 264,794 "name": "John Madden"795}, {796 "id": 265,797 "name": "Ross McElwee"798}, {799 "id": 266,800 "name": "Andrew Adamson"801}, {802 "id": 267,803 "name": "Jacques-Yves Cousteau"804}, {805 "id": 268,806 "name": "Walter Lang"807}, {808 "id": 269,809 "name": "Lloyd Bacon"810}, {811 "id": 270,812 "name": "Hayao Miyazaki"813}, {814 "id": 271,815 "name": "Jonathan Demme"816}, {817 "id": 272,818 "name": "George Stevens"819}, {820 "id": 273,821 "name": "Tony Richardson"822}, {823 "id": 274,824 "name": "Cecil B. DeMille"825}, {826 "id": 275,827 "name": "Nicholas Ray"828}, {829 "id": 276,830 "name": "Mervyn LeRoy"831}, {832 "id": 277,833 "name": "Rainer Werner Fassbinder"834}, {835 "id": 278,836 "name": "Carol Reed"837}, {838 "id": 279,839 "name": "François Girard"840}, {841 "id": 280,842 "name": "Lindsay Anderson"843}, {844 "id": 281,845 "name": "Alexander MacKendrick"846}, {847 "id": 282,848 "name": "Robert Mulligan"849}, {850 "id": 283,851 "name": "Zhang Yimou"852}, {853 "id": 284,854 "name": "John Lasseter"855}, {856 "id": 285,857 "name": "Steven Soderbergh"858}, {859 "id": 286,860 "name": "John Frankenheimer"861}, {862 "id": 287,863 "name": "Danny Boyle"864}, {865 "id": 288,866 "name": "Bryan Singer"867}, {868 "id": 289,869 "name": "Richard Linklater"870}, {871 "id": 290,872 "name": "Peter Watkins"873}, {874 "id": 291,875 "name": "Walter Hill"876}, {877 "id": 292,878 "name": "Herman Shumlin"879}, {880 "id": 293,881 "name": "Neal Jimenez"882}, {883 "id": 294,884 "name": "Andre Techine"885}, {886 "id": 295,887 "name": "Clarence Brown"888}, {889 "id": 296,890 "name": "Kenneth Lonergan"891}, {892 "id": 297,893 "name": "Alfonso Cuaron"894}];895module.exports = {896 getAll: function () {897 return _.sortBy(directors, function (c) {898 return c.name;899 });900 },901 get: function (id) {902 id = +id;903 return _.find(directors, function (p) {904 return p.id === id;905 });906 }...
dhtmlxmenu_effects.js
Source:dhtmlxmenu_effects.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// effects: opacity, slide9dhtmlXMenuObject.prototype.enableEffect = function(name, maxOpacity, effectSpeed) {10 11 this._menuEffect = (name=="opacity"||name=="slide"||name=="slide+"?name:false);12 13 this._pOpStyleIE = (navigator.userAgent.search(/MSIE\s[678]\.0/gi)>=0); // opacity was added in IE914 15 for (var a in this.idPull) {16 if (a.search(/polygon/) === 0) {17 this._pOpacityApply(a,(this._pOpStyleIE?100:1));18 this.idPull[a].style.height = "";19 }20 21 }22 23 // opacity max value24 this._pOpMax = (typeof(maxOpacity)=="undefined"?100:maxOpacity)/(this._pOpStyleIE?1:100);25 26 // opacity css styles27 this._pOpStyleName = (this._pOpStyleIE?"filter":"opacity");28 this._pOpStyleValue = (this._pOpStyleIE?"progid:DXImageTransform.Microsoft.Alpha(Opacity=#)":"#");29 30 31 // count of steps to open full polygon32 this._pSlSteps = (this._pOpStyleIE?10:20);33 34 // timeout to open polygon35 this._pSlTMTimeMax = effectSpeed||50;36 37};38// extended show39dhtmlXMenuObject.prototype._showPolygonEffect = function(pId) {40 this._pShowHide(pId, true);41};42// extended hide43dhtmlXMenuObject.prototype._hidePolygonEffect = function(pId) {44 this._pShowHide(pId, false);45};46// apply opacity css47dhtmlXMenuObject.prototype._pOpacityApply = function(pId, val) {48 this.idPull[pId].style[this._pOpStyleName] = String(this._pOpStyleValue).replace("#", val||this.idPull[pId]._op);49};50dhtmlXMenuObject.prototype._pShowHide = function(pId, mode) {51 52 if (!this.idPull) return;53 54 // check if mode in progress55 if (this.idPull[pId]._tmShow != null) {56 if ((this.idPull[pId]._step_h > 0 && mode == true) || (this.idPull[pId]._step_h < 0 && mode == false)) return;57 window.clearTimeout(this.idPull[pId]._tmShow);58 this.idPull[pId]._tmShow = null;59 this.idPull[pId]._max_h = null;60 }61 62 if (mode == false && (this.idPull[pId].style.visibility == "hidden" || this.idPull[pId].style.display == "none")) return;63 64 if (mode == true && this.idPull[pId].style.display == "none") {65 this.idPull[pId].style.visibility = "hidden";66 this.idPull[pId].style.display = "";67 }68 69 // init values or show-hide revert70 if (this.idPull[pId]._max_h == null) {71 72 this.idPull[pId]._max_h = parseInt(this.idPull[pId].offsetHeight);73 this.idPull[pId]._h = (mode==true?0:this.idPull[pId]._max_h);74 this.idPull[pId]._step_h = Math.round(this.idPull[pId]._max_h/this._pSlSteps)*(mode==true?1:-1);75 if (this.idPull[pId]._step_h == 0) return;76 this.idPull[pId]._step_tm = Math.round(this._pSlTMTimeMax/this._pSlSteps);77 78 if (this._menuEffect == "slide+" || this._menuEffect == "opacity") {79 this.idPull[pId].op_tm = this.idPull[pId]._step_tm;80 this.idPull[pId].op_step = (this._pOpMax/this._pSlSteps)*(mode==true?1:-1);81 if (this._pOpStyleIE) this.idPull[pId].op_step = Math.round(this.idPull[pId].op_step);82 this.idPull[pId]._op = (mode==true?0:this._pOpMax);83 this._pOpacityApply(pId);84 } else {85 this.idPull[pId]._op = (this._pOpStyleIE?100:1);86 this._pOpacityApply(pId);87 }88 89 // show first time90 if (this._menuEffect.search(/slide/) === 0) this.idPull[pId].style.height = "0px";91 this.idPull[pId].style.visibility = "visible";92 93 }94 95 // run cycle96 this._pEffectSet(pId, this.idPull[pId]._h+this.idPull[pId]._step_h);97 98};99dhtmlXMenuObject.prototype._pEffectSet = function(pId, t) {100 101 if (!this.idPull) return;102 103 if (this.idPull[pId]._tmShow) window.clearTimeout(this.idPull[pId]._tmShow);104 105 // check and apply next step106 this.idPull[pId]._h = Math.max(0,Math.min(t,this.idPull[pId]._max_h));107 if (this._menuEffect.search(/slide/) === 0) this.idPull[pId].style.height = this.idPull[pId]._h+"px";108 109 t += this.idPull[pId]._step_h;110 111 if (this._menuEffect == "slide+" || this._menuEffect == "opacity") {112 this.idPull[pId]._op = Math.max(0,Math.min(this._pOpMax,this.idPull[pId]._op+this.idPull[pId].op_step));113 this._pOpacityApply(pId);114 }115 116 if ((this.idPull[pId]._step_h > 0 && t <= this.idPull[pId]._max_h) || (this.idPull[pId]._step_h < 0 && t >= 0)) {117 // continue118 var k = this;119 this.idPull[pId]._tmShow = window.setTimeout(function(){k._pEffectSet(pId,t);}, this.idPull[pId]._step_tm);120 } else {121 122 // clear height123 if (this._menuEffect.search(/slide/) === 0) this.idPull[pId].style.height = "";124 125 // hide completed126 if (this.idPull[pId]._step_h < 0) this.idPull[pId].style.visibility = "hidden";127 128 if (this._menuEffect == "slide+" || this._menuEffect == "opacity") {129 this.idPull[pId]._op = (this.idPull[pId]._step_h<0?(this._pOpStyleIE?100:1):this._pOpMax);130 this._pOpacityApply(pId);131 }132 133 // clear values134 this.idPull[pId]._tmShow = null;135 this.idPull[pId]._h = null;136 this.idPull[pId]._max_h = null;137 ///this.idPull[pId]._step_h = null;138 this.idPull[pId]._step_tm = null;139 }140 ...
media_field_admin.js
Source:media_field_admin.js
1function meSelectOrRemoveMedia(action, name)2{3 MediaExplorer.field_id ='id__' + name;4 MediaExplorer.media_info_id='id__media_info_' + name;5 MediaExplorer.current_image_id='id__current_image_' + name;6 MediaExplorer.type_input_id='id__type_' + name;7 MediaExplorer.media_input_id='id__id_' + name;8 MediaExplorer.image_info_id = 'id__image_info_' + name;9 MediaExplorer.caption_input_id = "id__caption_" + name;10 MediaExplorer.temp_caption_input_id = "id__temp_caption_" + name;11 MediaExplorer.credit_input_id = "id__credit_" + name;12 MediaExplorer.temp_credit_input_id = "id__temp_credit_" + name;13 MediaExplorer.callback = 'meProcessMedia';14 MediaExplorer.caption_input_ids = [MediaExplorer.caption_input_id,MediaExplorer.temp_caption_input_id];15 MediaExplorer.credit_input_ids = [MediaExplorer.credit_input_id,MediaExplorer.temp_credit_input_id];16 if ( action == "select" )17 {18 MediaExplorer.openWindow();19 }20 else if ( action == "remove" )21 {22 MediaExplorer.remove();23 }24}25function meProcessMedia(name)26{27 var media_info_id = MediaExplorer.media_info_id;28 var media_input_id = MediaExplorer.media_input_id;29 var type_input_id = MediaExplorer.type_input_id;30 var image_info_id = MediaExplorer.image_info_id;31 var current_image_id = MediaExplorer.current_image_id;32 if ( typeof(name) !== "undefined" )33 {34 media_info_id='id__media_info_' + name;35 current_image_id='id__current_image_' + name;36 type_input_id='id__type_' + name;37 media_input_id='id__id_' + name;38 image_info_id = 'id__image_info_' + name;39 }40 41 $("#"+media_info_id).html("");42 $("#"+media_info_id).hide();43 $("#"+image_info_id).hide();44 var id = $("#"+media_input_id).val();45 var type = $("#"+type_input_id).val();46 if ( id && type )47 {48 var url = "/api/media/elements/" + id;49 if ( type == "gallery" )50 {51 url = "/api/media/galleries/" + id;52 }53 else if ( type == "image" )54 {55 $("#"+image_info_id).show();56 }57 $.ajax({58 url: url59 }).done(function(data) {60 var html = "";61 html = "<div>";62 html += "<b>Media name:</b> ";63 if ( type == "image" )64 {65 html += "<a target='_blank' href='" + data.image_url + "'>"66 html += data.name;67 html += "</a>";68 }69 else if ( type == "video" )70 {71 html += "<a target='_blank' href='" + data.video_url + "'>"72 html += data.name;73 html += "</a>";74 }75 else if ( type == "gallery" )76 {77 html += data.name;78 }79 html += "</div>";80 html += "<div>";81 html += "<b>Media type:</b> " + type;82 html += "</div>";83 $("#"+media_info_id).html(html);84 $("#"+media_info_id).show();85 var html2 = "<img style='max-width:150px' src='";86 html2 += data.thumbnail_image_url;87 html2 += "' >";88 $("#"+current_image_id).html(html2);89 });90 }91 meBuildField(name);92}93function meBuildField(name)94{95 var field_id = MediaExplorer.field_id;96 var media_input_id = MediaExplorer.media_input_id;97 var type_input_id = MediaExplorer.type_input_id;98 var caption_input_id = MediaExplorer.caption_input_id;99 var credit_input_id = MediaExplorer.credit_input_id;100 if ( typeof(name) !== "undefined" )101 {102 field_id = 'id__' + name;103 type_input_id='id__type_' + name;104 media_input_id='id__id_' + name;105 caption_input_id = "id__caption_" + name;106 credit_input_id = "id__credit_" + name;107 }108 $("#"+field_id).val("");109 var media_id = $("#"+media_input_id).val();110 var media_type = $("#"+type_input_id).val();111 var media_caption = $("#"+caption_input_id).val();112 var media_credit = $("#"+credit_input_id).val();113 var data = {};114 if ( media_id )115 {116 data["id"] = media_id;117 data["type"] = media_type;118 data["caption"] = media_caption;119 data["credit"] = media_credit;120 $("#"+field_id).val(JSON.stringify(data));121 }...
Using AI Code Generation
1const id = require('fast-check-monorepo').id;2const id = require('fast-check-monorepo').id;3const id = require('fast-check-monorepo').id;4const id = require('fast-check-monorepo').id;5const id = require('fast-check-monorepo').id;6const id = require('fast-check-monorepo').id;7const id = require('fast-check-monorepo').id;8const id = require('fast-check-monorepo').id;9const id = require('fast-check-monorepo').id;10const id = require('fast-check-monorepo').id;11const id = require('fast-check-monorepo').id;12const id = require('fast-check-monorepo').id;13const id = require('fast-check-monorepo').id;14const id = require('fast-check-monorepo').id;15const id = require('fast-check-monorepo').id;16const id = require('fast-check-monorepo').id;17const id = require('fast-check-monorepo').id;
Using AI Code Generation
1const fc = require('fast-check');2const { id } = require('fast-check-monorepo');3fc.assert(4 fc.property(fc.integer(), (i) => {5 return id(i) === i;6 })7);
Using AI Code Generation
1const fc = require('fast-check');2const {id} = require('fast-check-monorepo');3fc.assert(4 fc.property(fc.integer(), id, (x, y) => x === y),5 {numRuns: 100}6);7const fc = require('fast-check');8const {id} = require('fast-check-monorepo');9fc.assert(10 fc.property(fc.integer(), id, (x, y) => x === y),11 {numRuns: 100}12);13const fc = require('fast-check');14const {id} = require('fast-check-monorepo');15fc.assert(16 fc.property(fc.integer(), id, (x, y) => x === y),17 {numRuns: 100}18);19const fc = require('fast-check');20const {id} = require('fast-check-monorepo');21fc.assert(22 fc.property(fc.integer(), id, (x, y) => x === y),23 {numRuns: 100}24);25const fc = require('fast-check');26const {id} = require('fast-check-monorepo');27fc.assert(28 fc.property(fc.integer(), id, (x, y) => x === y),29 {numRuns: 100}30);31const fc = require('fast-check');32const {id} = require('fast-check-monorepo');33fc.assert(34 fc.property(fc.integer(), id, (x, y) => x === y),35 {numRuns: 100}36);37const fc = require('fast-check');38const {id} = require('fast-check-monorepo');39fc.assert(40 fc.property(fc.integer(), id, (x, y) => x === y),41 {numRuns: 100}42);
Using AI Code Generation
1const id = require('fast-check-monorepo').id;2const fc = require('fast-check');3fc.assert(4 fc.property(fc.integer(), (i) => id(i) === i),5 { numRuns: 100 }6);
Using AI Code Generation
1const fc = require('fast-check');2const id = require('fast-check-monorepo').id;3const add = (a, b) => a + b;4fc.assert(5 fc.property(6 fc.integer(), fc.integer(),7 (a, b) => {8 return id(add(a, b)) === add(id(a), id(b));9 }
Using AI Code Generation
1const fc = require('fast-check');2const id = x => x;3const arb = fc.integer(1, 100);4const test = fc.assert(5 fc.property(arb, id)6);7test.then(x => console.log(x));8const fc = require('fast-check');9const id = x => x;10const arb = fc.integer(1, 100);11const test = fc.assert(12 fc.property(arb, id)13);14test.then(x => console.log(x));15const fc = require('fast-check');16const id = x => x;17const arb = fc.integer(1, 100);18const test = fc.assert(19 fc.property(arb, id)20);21test.then(x => console.log(x));22const fc = require('fast-check');23const id = x => x;24const arb = fc.integer(1, 100);25const test = fc.assert(26 fc.property(arb, id)27);28test.then(x => console.log(x));29const fc = require('fast-check');30const id = x => x;31const arb = fc.integer(1, 100);32const test = fc.assert(33 fc.property(arb, id)34);35test.then(x => console.log(x));36const fc = require('fast-check');
Using AI Code Generation
1var fastCheck = require('fast-check');2var id = fastCheck.id;3var arb = fastCheck.fc.integer();4var arb2 = id(arb);5console.log(arb === arb2);6var fastCheck = require('fast-check');7var id = fastCheck.id;8var arb = fastCheck.fc.integer();9var arb2 = id(arb);10console.log(arb === arb2);11var fastCheck = require('fast-check');12var id = fastCheck.id;13var arb = fastCheck.fc.integer();14var arb2 = id(arb);15console.log(arb === arb2);16var fastCheck = require('fast-check');17var id = fastCheck.id;18var arb = fastCheck.fc.integer();19var arb2 = id(arb);20console.log(arb === arb2);21var fastCheck = require('fast-check');22var id = fastCheck.id;23var arb = fastCheck.fc.integer();24var arb2 = id(arb);25console.log(arb === arb2);26var fastCheck = require('fast-check');27var id = fastCheck.id;28var arb = fastCheck.fc.integer();29var arb2 = id(arb);30console.log(arb === arb2);31var fastCheck = require('fast-check');32var id = fastCheck.id;33var arb = fastCheck.fc.integer();34var arb2 = id(arb);35console.log(arb === arb2);36var fastCheck = require('fast-check');37var id = fastCheck.id;38var arb = fastCheck.fc.integer();39var arb2 = id(arb);40console.log(arb === arb2);
Using AI Code Generation
1const id = require('fast-check-monorepo').id;2const myFunction = require('./myFunction');3const myString = id();4myFunction(myString);5const { myFunction } = require('./myFunction');6test('myFunction', () => {7 expect(myFunction).toBeDefined();8 expect(myFunction('test')).toBe('test');9 expect(myFunction('test')).not.toBe('test2');10});11exports.myFunction = myFunction;12function myFunction(input) {13 return input;14}15const { myFunction } = require('./myFunction');16exports.myFunction = myFunction;17const id = require('fast-check-monorepo').id;18const myFunction = require('./myFunction');19const myString = id();20myFunction(myString);21const { myFunction } = require('./myFunction');22test('myFunction', () => {23 expect(myFunction).toBeDefined();24 expect(myFunction('test')).toBe('test');25 expect(myFunction('test')).not.toBe('test2');26});27exports.myFunction = myFunction;28function myFunction(input) {29 return input;30}31const { myFunction } = require('./myFunction');32exports.myFunction = myFunction;33const id = require('fast-check-monorepo').id;34const myFunction = require('./myFunction');
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!!