Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript对象通信并从其他对象获取参数_Javascript_Methods_Javascript Objects_Prototype Programming - Fatal编程技术网

Javascript对象通信并从其他对象获取参数

Javascript对象通信并从其他对象获取参数,javascript,methods,javascript-objects,prototype-programming,Javascript,Methods,Javascript Objects,Prototype Programming,我在将参数从一个对象共享到另一个对象时遇到问题 我有一个最新的视频对象和选项我的视频库和其他对象的方法分页,渲染,类别和本地存储,巫婆手所有的功能,但我使用这许多我需要这作为分离对象 (function (window, document, none) { "use strict"; var LatestVideos = window.LatestVideos = function (option) { /* object to init puglin data JSON

我在将参数从一个对象共享到另一个对象时遇到问题 我有一个最新的视频对象和选项我的视频库和其他对象的方法分页,渲染,类别和本地存储,巫婆手所有的功能,但我使用这许多我需要这作为分离对象

    (function (window, document, none) {
  "use strict";
  var LatestVideos = window.LatestVideos = function (option) {
   /* object to init puglin data JSON FORMAT keys Jsondata or url , container, 
   actual page wrapper on paggination, number of item per page, categorywrapper*/
    this.fragments = document.createDocumentFragment();
    this.categories = ["Favorite"];
    this.statusLoad = 0;
    this.allid = [];
    this.categoryid = [];
    this.actual = [];
    //this.categoryChecked=[];
    this.page = 0;
    loadJSON(option.url,this.initData.bind(this));     
    this.settings = { /// init data from options object from parameter constructor      
        JsonData :option.data || 0,       
        container : option.container,
        actpage : option.actpage || 1, 
        buttonwrapper : option.paginationwrapper,
        categorywrapper : option.categorywrapper,
        itemperpage : option.itemperpage,  // get value from prev Selection or default        
    };      
  }; 
  LatestVideos.prototype.initData = function (data) { // assinchrounous call json with ajax
      this.settings.JsonData = data;
      this.settings.lengthData = data.length;
      Render.setData(this);
      Render.getCategories();
  };
  var Render = { // need this data from LASTESTVIDEOS    data,conteiner,paginationwrapper,categorywrapper
    /// object with method  to render articles to my website
  };
  var Pagination = function(){
    //   from LASTESTVIDEOS I need JsonData, actPage overide page and paginatorwrapper
    // object with method to calculate number of pages and paginate my articles
  };
  var Cateogry = function(){
     //   from LASTESTVIDEOS categoryid change actual and allid 
    // object with method to changeCategory and get category from data atribut 
   };
  var LocalStoraget = function (){
    // I JSON data from LASTESTVIDEOS
    // object with method to getFavorite item form localstorage and add to localstorage
};
})(window, document);


function loadJSON(url, callback) {  
  /* function to load ajax from url input(url- form and callback function),
 output function call and post (ARRAY JSON OBJECTS)*/
  var xmlhttp =0;
  if (typeof XMLHttpRequest !== 'undefined') {
    xmlhttp = new XMLHttpRequest();
  } else {
    var versions = ["Microsoft.XmlHttp",
        "MSXML2.XmlHttp",
        "MSXML2.XmlHttp.3.0",
        "MSXML2.XmlHttp.4.0",
        "MSXML2.XmlHttp.5.0"];
    var len =  versions.length;
    for (var i = 0; i < len; i++) {
      try {
        xmlhttp = new ActiveXObject(versions[i]);
        break;
      }
      catch(e){}
  } 
}
xmlhttp.onreadystatechange = ensureReadiness;
function ensureReadiness(){
  if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
  {
    JSONObject = JSON.parse(xmlhttp.responseText);
    callback (JSONObject);
  }else{
    return;
  }
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
var options = {url:"someURL",container:"videox",paginationwrapper:"pages"};
var opp = new LatestVideos(options);
(函数(窗口、文档、无){
“严格使用”;
var LatestVideos=window.LatestVideos=function(选项){
/*对象初始化puglin数据JSON格式键Jsondata或url,容器,
分页时的实际页面包装器、每页的项目数、类别包装器*/
this.fragments=document.createDocumentFragment();
this.categories=[“收藏夹”];
this.statusLoad=0;
this.allid=[];
this.categoryid=[];
this.actual=[];
//this.categoryChecked=[];
本页=0;
loadJSON(option.url,this.initData.bind(this));
this.settings={///init参数构造函数中选项对象的数据
JsonData:option.data | | 0,
容器:option.container,
actpage:option.actpage | | 1,
按钮包装器:option.paginationwrapper,
categorywrapper:option.categorywrapper,
itemperpage:option.itemperpage,//从上一个选择或默认值中获取值
};      
}; 
LatestVideos.prototype.initData=函数(数据){//assinchrounous使用ajax调用json
this.settings.JsonData=数据;
this.settings.lengthData=data.length;
Render.setData(这个);
Render.getCategories();
};
var Render={//需要来自LastTestVideos数据、contenner、paginationwrapper、categorywrapper的此数据
///对象的方法将文章呈现到我的网站
};
变量分页=函数(){
//从最新的视频中,我需要JsonData、actPage overide page和paginatorwrapper
//对象的方法来计算页数并为我的文章分页
};
var Cateogry=函数(){
//从最新视频类别ID更改实际和所有ID
//对象的方法更改类别并从数据中获取类别
};
var LocalStoraget=函数(){
//我从最近的视频中获取JSON数据
//对象,方法从localstorage获取收藏夹项并添加到localstorage
};
})(窗口、文件);
函数loadJSON(url,回调){
/*函数从url输入加载ajax(url-表单和回调函数),
输出函数调用和post(数组JSON对象)*/
var xmlhttp=0;
if(XMLHttpRequest的类型!=“未定义”){
xmlhttp=新的XMLHttpRequest();
}否则{
var versions=[“Microsoft.XmlHttp”,
“MSXML2.XmlHttp”,
“MSXML2.XmlHttp.3.0”,
“MSXML2.XmlHttp.4.0”,
“MSXML2.XmlHttp.5.0”];
var len=versions.length;
对于(变量i=0;i

这是一个插件,我需要创建具有不同选项的X时间,有时我需要单独渲染或分页对象或本地存储,我可能会对其进行一些更改:

var Render = function (options) { 
  this.options = $.extend({ //default options
    data: [],
    container: null
  }, options);

  // use internal logic here
  var getCategories = function(){
    ...
  };
  // and return public methods

  return {
    getCategories: getCategories
  };
};
并将最新视频中的代码更改为以下内容:

LatestVideos.prototype.initData = function (data) { // assinchrounous call json with ajax
      this.settings.JsonData = data;
      this.settings.lengthData = data.length;
      var renderer = new Render({
          data: this.settings.JsonData,
          container: this.settings.container
      });
      renderer.getCategories();
  };

问题是什么?我现在不知道如何从该对象获取数据,为每个config/LastTestVideos实例创建分页和类别的实例,并对用户更改页面做出反应我必须更改LastTestVideos中的act页面在调用render object方法渲染新视频后,以及如何为同一实例共享此数据