skyline TE b/s下批量修改message的url

   只貼代碼了,具體用法請在實踐中應用。
     var _num;
   function OnLoadFinished() {
       _num = 0;
                  var SiblingItemID = SGWorld.ProjectTree.GetNextItem(0, 11);
                    if (SiblingItemID == 0) {
                        return;
                    }
                    while (SiblingItemID > 0) {
                        if (SGWorld.ProjectTree.IsGroup(SiblingItemID) > 0) {
                            TraverseBranch(SiblingItemID);
                        }
                        else {
                            var _item = SGWorld.ProjectTree.GetObject(SiblingItemID);
                            if (_item.Message.MessageID != "0_-1") {
                                var _item2 = SGWorld.Creator.GetObject(_item.Message.MessageID);
                                ModifyURL(_item2);
                            }
                        }

                        SiblingItemID = SGWorld.ProjectTree.GetNextItem(SiblingItemID, 13);
                    }
                    alert("共修改 " + _num.toString() + " ......");
                }
                function ModifyURL(_item) {
                    var text1 = document.getElementById("Text1");
                  m_OldURLPath = text1.value;
                  var text2 = document.getElementById("Text2");
                  m_NewURLPath = text2.value;

                  if (_item != null) {
                      if ((_item.Src != "") && (_item.Src.indexOf(m_OldURLPath)>0)) {
                          var reg = new RegExp(m_OldURLPath,"g");//創建正則RegExp對象    
                          _item.Src = _item.Src.replace(reg, m_NewURLPath);                         
                          _num = _num + 1;
                      }                     
       }
   }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章